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

📄 fw.lst

📁 开发usb块传输的固件程序,可pc循环向下微机发数据
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.10  FW                                                                     06/30/2004 23:05:20 PAGE 1   


C51 COMPILER V6.10, COMPILATION OF MODULE FW
OBJECT MODULE PLACED IN .\FW.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\FW.C ROM(COMPACT) OPTIMIZE(6,SPEED) DEBUG OBJECTEXTEND

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/host/fw.c $
   9          // $Date: 1/23/02 11:25a $
  10          // $Revision: 4 $
  11          //-----------------------------------------------------------------------------
  12          #include "ezusb.h"
  13          #include "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;
  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);
  52          BOOL DR_ClearFeature(void);
  53          BOOL DR_SetFeature(void);
  54          BOOL DR_VendorCmnd(void);
  55          
C51 COMPILER V6.10  FW                                                                     06/30/2004 23:05:20 PAGE 2   

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

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

⌨️ 快捷键说明

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