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

📄 enum.lst

📁 some examples of EZUSB firmeware frame
💻 LST
字号:
C51 COMPILER V6.14  ENUM                                                                   08/13/2002 23:05:33 PAGE 1   


C51 COMPILER V6.14, COMPILATION OF MODULE ENUM
OBJECT MODULE PLACED IN .\Enum.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE .\Enum.c DEBUG OBJECTEXTEND

stmt level    source

   1          /* 
   2             File: enumlite.c  After enumerating as 'generic', have the 8051 field a small
   3             subset of enumeration commands as sent from the control panel: Get_Descriptor--Device,
   4             Get_Descriptor--Configuration, and Get_Descriptor--String. Note: the control panel returns
   5             only the first two strings, with indices 1 and 2.
   6          */
   7          #pragma intvector (0x17FD)	// start interrupts at 1800h
   8          #pragma interval  (4)		// four bytes per jump instr: 1800,1804,1808...
   9          #define ALLOCATE_EXTERN		// ezregs.h needs this for stand-alone programs
  10          #include "ezusb.h"			// NOTE: Set environment path for INC files..
  11          #include "ezregs.h"			// ..to c:\Cypress\USB\Target\Inc\
  12          
  13          #define VID 0x0547
  14          #define PID 0x2131
  15          #define DID 0xabcd
  16          
  17          // function prototypes
  18          void process_std_request(void);
  19          void process_descriptor(void);
  20          void process_class_request(void);
  21          void process_vendor_request(void);
  22          void display_hex (char val);
  23          	
  24          // global variables
  25          char	bmRequestType,bRequest,wValueH,wValueL;	
  26          char xdata Digit[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98,0x88,0x83,0xc6,0xa1,0x86,0x8e};
  27          
  28          code BYTE Device_Descriptor[] =
  29              {18,	       		// descriptor length = 18d
  30              1,					// type = Device (1)
  31          	0x00,0x01,			// USB spec rev (BCD)
  32          	0xFF,0xFF,0xFF, 	// Device class, sub class, protocol (vendor specific)
  33          	64,					// max packet size for EP0
  34          	LSB(VID),MSB(VID),	// VID
  35          	LSB(PID),MSB(PID),	// PID
  36          	LSB(DID),MSB(DID),	// DID
  37          	1,2,0,				// manuf, prod, serial num string indices
  38          	1};					// number of configs in this interface
  39          
  40          code BYTE Configuration_Descriptor[] =
  41           	{9,					// descriptor length = 9d
  42          	2,					// type = Configuration
  43          	32,0,				// length of this entire descriptor (config+interfaces+endpoints)
  44          	1,					// number of interfaces
  45          	1,					// value to select this configuration
  46          	0,					// string index to describe this config
  47          	0x80,				// attrib: bus powered, no remote wakeup
  48          	100,				// bus power = 100 ma
  49          // Interface Descriptor: Interface 0, Alternate Setting 0
  50          	9,					// interface descriptor length
  51          	4,					// type = Interface
  52          	0,0,				// Interface 0, Alternate Setting 0
  53          	2,					// number of endpoints not counting EP0
  54          	0xFF,0xFF,0xFF,		// class info is vendor-specific
  55          	0,					// String index for this interface
C51 COMPILER V6.14  ENUM                                                                   08/13/2002 23:05:33 PAGE 2   

  56          // I-0, AS-0: first endpoint descriptor--EP2IN
  57          	7,					// endpoint descriptor length
  58          	5,					// type = Endpoint
  59          	0x82,				// IN-2
  60          	2,					// type = BULK
  61          	50,0,				// maxPacketSize (L-H)
  62          	0,					// polling interval (int only)
  63          // I-0, AS-0: second endpoint descriptor--EP2OUT
  64          	7,					// endpoint descriptor length
  65          	5,					// type = Endpoint
  66          	0x02,				// OUT-2
  67          	2,					// type = BULK
  68          	50,0,				// maxPacketSize (L-H)
  69          	0};					// polling interval (int only)
  70          
  71          code BYTE String0[] = {4,3,9,4};	// 0 is language string: len,type,lang,sub-lang
  72          code BYTE String1[] = {16,3,'C',0,'y',0,'p',0,'r',0,'e',0,'s',0,'s',0}; // 1 is manuf
  73          code BYTE String2[] = {14,3,'E',0,'Z',0,'-',0,'U',0,'S',0,'B',0};		// 2 is product
  74          
  75          main()
  76          {
  77   1      USBCS |= bmRENUM;			// setting the RENUM bit puts the 8051 in charge
  78   1      USBBAV = bmAVEN;			// Enable autovector
  79   1      EUSB=1;						// Enable USB (INT2) interrupt
  80   1      USBIEN = bmSUDAV | bmSUSP;	// Enable SUDAV (Setup Data Available) & Suspend interrupts
  81   1      EICON |= 0x20;				// Enable Resume Interrupt
  82   1      EA = 1;						// Enable 8051 interrupts
  83   1      
  84   1      while (1);					// loop forever, waiting for an interrupt
  85   1      }
  86          
  87          static void Suspend_ISR (void) interrupt 03 	// '03' is SUSPEND interrupt number
  88          {
  89   1      	EZUSB_IRQ_CLEAR();		// Always clear INT2 flag first
  90   1      	USBIRQ = bmSUSP;		// ...then clear SUSPEND IRQ by writing "1" to IRQ bit
  91   1      	display_hex(0x7F);		// decimal point only
  92   1      	PCON |= 1;				// set bit zero only: zzzzzzzzzzzzzzzzz
  93   1      }
  94          
  95          static void SUDAV_ISR  (void) interrupt 0x00	// vector 00 is SUDAV
  96          {
  97   1      bmRequestType 	= SETUPDAT[0];
  98   1      bRequest  		= SETUPDAT[1];
  99   1      wValueL			= SETUPDAT[2];
 100   1      wValueH	  		= SETUPDAT[3];
 101   1      EZUSB_IRQ_CLEAR();				// Clear USB interrupt (INT2)
 102   1      USBIRQ = bmSUDAV;				// Clear SUDAV IRQ
 103   1      
 104   1      switch(bmRequestType & 0x60)		// 00-std, 20-class, 40-vendor, 60-reserved
 105   1      	{								// 0x60=01100000: these two bits determine request type
 106   2      	case 0x00:	
 107   2      		process_std_request();
 108   2      	break;
 109   2      	case 0x20:
 110   2      		process_class_request();
 111   2      	break;
 112   2      	case SETUP_VENDOR_REQUEST:
 113   2      		process_vendor_request();
 114   2      	break;
 115   2      	default:
 116   2      	EZUSB_STALL_EP0();
 117   2      	break;
C51 COMPILER V6.14  ENUM                                                                   08/13/2002 23:05:33 PAGE 3   

 118   2      	}
 119   1      EP0CS |= 0x02;			// Clear the HSNAK bit to ACK the STATUS stage
 120   1      } // end SUDAV_ISR
 121          
 122          void process_std_request(void)
 123          {
 124   1      switch(bRequest)
 125   1      	{
 126   2      	case SC_GET_DESCRIPTOR:		// put most common first
 127   2      		process_descriptor();
 128   2      	break;
 129   2      	case SC_SET_FEATURE:
 130   2      	break;
 131   2      	case SC_CLEAR_FEATURE:
 132   2      	break;
 133   2      	case SC_GET_STATUS:
 134   2      	break;
 135   2      	case SC_SET_INTERFACE:
 136   2      	break;
 137   2      	case SC_GET_INTERFACE:
 138   2      	break;
 139   2      	case SC_SET_CONFIGURATION:
 140   2      	break;
 141   2      	case SC_GET_CONFIGURATION:
 142   2      	break;
 143   2      	default:
 144   2      	EZUSB_STALL_EP0();
 145   2      	break;
 146   2      	}		
 147   1      }
 148          
 149          void process_descriptor(void)
 150          {
 151   1      switch(wValueH)
 152   1      	{
 153   2      	case GD_DEVICE:
 154   2      		SUDPTRH = MSB(Device_Descriptor);
 155   2      		SUDPTRL = LSB(Device_Descriptor);
 156   2      		display_hex(0x0D);
 157   2      	break;
 158   2      	case GD_CONFIGURATION:
 159   2      		SUDPTRH = MSB(Configuration_Descriptor);
 160   2      		SUDPTRL = LSB(Configuration_Descriptor);
 161   2      		display_hex(0x0C);
 162   2      	break;
 163   2      	case GD_STRING:
 164   2      		switch(wValueL)		// wValueL holds string index
 165   2      			{
 166   3      			case 0:
 167   3      			SUDPTRH = MSB(String0);
 168   3      			SUDPTRL = LSB(String0);
 169   3      			display_hex(0);
 170   3      			break;
 171   3      			case 1:
 172   3      			SUDPTRH = MSB(String1);
 173   3      			SUDPTRL = LSB(String1);
 174   3      			display_hex(1);
 175   3      			break;
 176   3      			case 2:
 177   3      			SUDPTRH = MSB(String2);
 178   3      			SUDPTRL = LSB(String2);
 179   3      			display_hex(2);
C51 COMPILER V6.14  ENUM                                                                   08/13/2002 23:05:33 PAGE 4   

 180   3      			break;
 181   3      			}
 182   2      	break;
 183   2      		default:
 184   2      	EZUSB_STALL_EP0();
 185   2      	break;
 186   2      	}		
 187   1      }
 188          void process_class_request(void)
 189          {
 190   1      	EZUSB_STALL_EP0();
 191   1      } 
 192          void process_vendor_request(void)
 193          {
 194   1      	EZUSB_STALL_EP0();
 195   1      } 
 196          void display_hex (char val)		// display one hex digit (over i2c bus)
 197          {
 198   1      	while (I2CS & bmSTOP);		// wait for STOP bit LOW--last operation complete
 199   1      	I2CS = 0x80;				// set the START bit
 200   1      	I2DAT = 0x42;				// IO expander address=42, LSB=0 for write
 201   1      	while (!(I2CS & bmDONE));	// wait for DONE=1 (i2c transmit complete)
 202   1      	I2DAT = Digit[val];				// send the data byte
 203   1      	while (!(I2CS & bmDONE));	// wait for DONE=1 (i2c transmit complete)
 204   1      	I2CS = 0x40;				// set the STOP bit
 205   1      }                        


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    443    ----
   CONSTANT SIZE    =     84    ----
   XDATA SIZE       =     16    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      4    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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