⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fw.lst

📁 CYPRESS公司SL811HS芯片 USB主机和USB设备的实现
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.10  FW                                                                     09/04/2002 22:22:08 PAGE 1   


C51 COMPILER V6.10, COMPILATION OF MODULE FW
OBJECT MODULE PLACED IN .\fw.OBJ
COMPILER INVOKED BY: f:\Keil\C51\BIN\C51.EXE .\fw.c OPTIMIZE(6,SPEED) INCDIR(c:\cypress\usb\target\inc) DEBUG OBJECTEXTE
                    -ND

stmt level    source

   1          //-----------------------------------------------------------------------------
   2          //	File:		fw.c
   3          //	Contents:	Firmware frameworks task dispatcher and device request parser
   4          //				source.
   5          //
   6          //	Copyright (c) 2002 Cypress Semiconductor, Inc. All rights reserved
   7          //
   8          // $Archive: /USB/ez811/firmware/Emb_Host/fw.c $
   9          // $Date: 4/03/02 4:32p $
  10          // $Revision: 1 $
  11          //-----------------------------------------------------------------------------
  12          #include "ezusb.h"
*** ERROR 318 IN LINE 12 OF .\fw.c: can't open file 'ezusb.h'
  13          #include "ezregs.h"
*** ERROR 318 IN LINE 13 OF .\fw.c: can't open file 'ezregs.h'
  14          
  15          //-----------------------------------------------------------------------------
  16          // Random Macros
  17          //-----------------------------------------------------------------------------
  18          #define	min(a,b) (((a)<(b))?(a):(b))
  19          #define	max(a,b) (((a)>(b))?(a):(b))
  20          
  21          //-----------------------------------------------------------------------------
  22          // Constants
  23          //-----------------------------------------------------------------------------
  24          
  25          //-----------------------------------------------------------------------------
  26          // Global Variables
  27          //-----------------------------------------------------------------------------
  28          volatile BOOL	GotSUD;
*** ERROR C129 IN LINE 28 OF .\FW.C: missing ';' before 'GotSUD'
  29          BOOL		Rwuen;
  30          BOOL		Selfpwr;
  31          volatile BOOL	Sleep;						// Sleep mode enable flag
  32          
  33          WORD	pDeviceDscr;	// Pointer to Device Descriptor; Descriptors may be moved
  34          WORD	pConfigDscr;	
  35          WORD	pStringDscr;	
  36          
  37          //-----------------------------------------------------------------------------
  38          // Prototypes
  39          //-----------------------------------------------------------------------------
  40          void SetupCommand(void);
  41          void TD_Init(void);
  42          void TD_Poll(void);
  43          BOOL TD_Suspend(void);
  44          BOOL TD_Resume(void);
  45          
  46          BOOL DR_GetDescriptor(void);
  47          BOOL DR_SetConfiguration(void);
  48          BOOL DR_GetConfiguration(void);
  49          BOOL DR_SetInterface(void);
  50          BOOL DR_GetInterface(void);
  51          BOOL DR_GetStatus(void);
C51 COMPILER V6.10  FW                                                                     09/04/2002 22:22:08 PAGE 2   

  52          BOOL DR_ClearFeature(void);
  53          BOOL DR_SetFeature(void);
  54          BOOL DR_VendorCmnd(void);
  55          
  56          //-----------------------------------------------------------------------------
  57          // Code
  58          //-----------------------------------------------------------------------------
  59          
  60          // Task dispatcher
  61          void main(void)
  62          {
  63          	DWORD	i;
  64          	WORD	offset;
  65          	DWORD	DevDescrLen;
  66          	DWORD	j=0;
  67          	WORD	IntDescrAddr;
  68          	WORD	ExtDescrAddr;
  69          
  70          	// Initialize Global States
  71          	Sleep = FALSE;					// Disable sleep mode
  72          	Rwuen = FALSE;					// Disable remote wakeup
  73          	Selfpwr = FALSE;				// Disable self powered
  74          	GotSUD = FALSE;					// Clear "Got setup data" flag
  75          
  76          	// Initialize user device
  77          	TD_Init();
  78          
  79          	// The following section of code is used to relocate the descriptor table. 
  80          	// Since the SUDPTRH and SUDPTRL are assigned the address of the descriptor 
  81          	// table, the descriptor table must be located in on-part memory.
  82          	// The 4K demo tools locate all code sections in external memory.
  83          	// The descriptor table is relocated by the frameworks ONLY if it is found 
  84          	// to be located in external memory.
  85          	pDeviceDscr = (WORD)&DeviceDscr;
  86          	pConfigDscr = (WORD)&ConfigDscr;
  87          	pStringDscr = (WORD)&StringDscr;
  88          	if ((WORD)&DeviceDscr & 0xe000)
  89          	{
  90          		IntDescrAddr = INTERNAL_DSCR_ADDR;
  91          		ExtDescrAddr = (WORD)&DeviceDscr;
  92          		DevDescrLen = (WORD)&UserDscr - (WORD)&DeviceDscr + 2;
  93          		for (i = 0; i < DevDescrLen; i++)
  94          			*((BYTE xdata *)IntDescrAddr+i) = 0xCD;
  95          		for (i = 0; i < DevDescrLen; i++)
  96          			*((BYTE xdata *)IntDescrAddr+i) = *((BYTE xdata *)ExtDescrAddr+i);
  97          		pDeviceDscr = IntDescrAddr;
  98          		offset = (WORD)&DeviceDscr - INTERNAL_DSCR_ADDR;
  99          		pConfigDscr -= offset;
 100          		pStringDscr -= offset;
 101          	}
 102          
 103          	EZUSB_IRQ_ENABLE();				// Enable USB interrupt (INT2)
 104          	EZUSB_ENABLE_RSMIRQ();				// Wake-up interrupt
 105          
 106          	// The 8051 is responsible for all USB events, even those that have happened
 107          	// before this point.  We cannot ignore pending USB interrupts.
 108          	// The chip will come out of reset with the flags all cleared.
 109          	//	USBIRQ = 0xff;				// Clear any pending USB interrupt requests
 110          	PORTCCFG |= 0xc0;				// Turn on r/w lines for external memory 
 111          
 112          	USBBAV = USBBAV | 1 & ~bmBREAK;	// Disable breakpoints and autovectoring
 113          	USBIEN |= bmSUDAV | bmSUTOK | bmSUSP | bmURES;	// Enable selected interrupts
C51 COMPILER V6.10  FW                                                                     09/04/2002 22:22:08 PAGE 3   

 114          	EA = 1;						// Enable 8051 interrupts
 115          
 116             #ifndef NO_RENUM
 117             // Note: at full speed, high speed hosts may take 5 sec to detect device
 118             EZUSB_Discon(TRUE); // Renumerate
 119             #endif
 120          
 121          
 122          	CKCON = (CKCON&(~bmSTRETCH)) | FW_STRETCH_VALUE; // Set stretch to 0 (after renumeration)
 123          
 124          	// Task Dispatcher
 125          	while(TRUE)					// Main Loop
 126          	{
 127          		if(GotSUD)				// Wait for SUDAV
 128          		{
 129          			SetupCommand();	 		// Implement setup command
 130            			GotSUD = FALSE;		   	// Clear SUDAV flag
 131          		}
 132          
 133          		// Poll User Device
 134          		// NOTE: Idle mode stops the processor clock.  There are only two
 135          		// ways out of idle mode, the WAKEUP pin, and detection of the USB
 136          		// resume state on the USB bus.  The timers will stop and the
 137          		// processor will not wake up on any other interrupts.
 138          		if (Sleep)
 139          		    {
 140              		if(TD_Suspend())
 141              		    { 
 142              		    Sleep = FALSE;	   		// Clear the "go to sleep" flag.  Do it here to prevent any race condition b
             -etween wakeup and the next sleep.
 143              		    do
 144              		        {
 145                 			    EZUSB_Susp();			// Place processor in idle mode.
 146              		        }
 147                          while(!Rwuen && EZUSB_EXTWAKEUP());
 148                          // Must continue to go back into suspend if the host has disabled remote wakeup
 149                          // *and* the wakeup was caused by the external wakeup pin.
 150                          
 151              			// 8051 activity will resume here due to USB bus or Wakeup# pin activity.
 152              			EZUSB_Resume();	// If source is the Wakeup# pin, signal the host to Resume.		
 153              			TD_Resume();
 154              		    }   
 155          		    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -