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

📄 fw.lst

📁 一个不错的usb加密卡的设计
💻 LST
📖 第 1 页 / 共 2 页
字号:
 162   1      	switch(SETUPDAT[1])
 163   1      	{
 164   2      		case SC_GET_DESCRIPTOR:						// *** Get Descriptor
 165   2      			if(DR_GetDescriptor())
 166   2      				switch(SETUPDAT[3])			
 167   2      				{
 168   3      					case GD_DEVICE:				// Device
 169   3      						SUDPTRH = MSB(pDeviceDscr);
 170   3      						SUDPTRL = LSB(pDeviceDscr);
 171   3      						break;
 172   3      					case GD_CONFIGURATION:			// Configuration
 173   3      						if(dscr_ptr = (void *)EZUSB_GetConfigDscr(SETUPDAT[2]))
 174   3      						{
 175   4      							SUDPTRH = MSB(dscr_ptr);
 176   4      							SUDPTRL = LSB(dscr_ptr);
 177   4      						}
 178   3      						else
C51 COMPILER V6.10  FW                                                                     11/29/2002 10:53:59 PAGE 4   

 179   3      							EZUSB_STALL_EP0(); 	// Stall End Point 0
 180   3      						break;
 181   3      					case GD_STRING:				// String
 182   3      						if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
 183   3      						{
 184   4      							// Workaround for rev D errata number 8
 185   4      							// If you're certain that you will never run on rev D,
 186   4      							// you can just do this:
 187   4      							// SUDPTRH = MSB(dscr_ptr);
 188   4      							// SUDPTRL = LSB(dscr_ptr);
 189   4      							STRINGDSCR *sdp;
 190   4      							BYTE len;
 191   4      
 192   4      							sdp = dscr_ptr;
 193   4      
 194   4      							len = sdp->length;
 195   4      							if (len > SETUPDAT[6]) 
 196   4      								len = SETUPDAT[6]; //limit to the requested length
 197   4      							
 198   4      							while (len)
 199   4      							{
 200   5      								for(i=0; i<min(len,64); i++)
 201   5      									*(IN0BUF+i) = *((BYTE xdata *)sdp+i);
 202   5      
 203   5      								//set length and arm Endpoint
 204   5      								EZUSB_SET_EP_BYTES(IN0BUF_ID,min(len,64));	
 205   5      								len -= min(len,64);
 206   5                              (BYTE *)sdp += 64;
 207   5      
 208   5      								// Wait for it to go out (Rev C and above)
 209   5      								while(EP0CS & 0x04)
 210   5      									;
 211   5      							}
 212   4      
 213   4      							// Arm a 0 length packet just in case.  There was some reflector traffic about
 214   4      							// Apple hosts asking for too much data.  This will keep them happy and will
 215   4      							// not hurt valid hosts because the next SETUP will clear this.
 216   4      							EZUSB_SET_EP_BYTES(IN0BUF_ID,0);	
 217   4      							// Clear the HS-nak bit
 218   4      							EP0CS = bmHS;
 219   4      						}
 220   3      						else 
 221   3      							EZUSB_STALL_EP0();	// Stall End Point 0
 222   3      						break;
 223   3      					default:				// Invalid request
 224   3      						EZUSB_STALL_EP0();		// Stall End Point 0
 225   3      				}
 226   2      			break;
 227   2      		case SC_GET_INTERFACE:						// *** Get Interface
 228   2      			DR_GetInterface();
 229   2      			break;
 230   2      		case SC_SET_INTERFACE:						// *** Set Interface
 231   2      			DR_SetInterface();
 232   2      			break;
 233   2      		case SC_SET_CONFIGURATION:					// *** Set Configuration
 234   2      			DR_SetConfiguration();
 235   2      			break;
 236   2      		case SC_GET_CONFIGURATION:					// *** Get Configuration
 237   2      			DR_GetConfiguration();
 238   2      			break;
 239   2      		case SC_GET_STATUS:						// *** Get Status
 240   2      			if(DR_GetStatus())
C51 COMPILER V6.10  FW                                                                     11/29/2002 10:53:59 PAGE 5   

 241   2      				switch(SETUPDAT[0])
 242   2      				{
 243   3      					case GS_DEVICE:				// Device
 244   3      						IN0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
 245   3      						IN0BUF[1] = 0;
 246   3      						EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
 247   3      						break;
 248   3      					case GS_INTERFACE:			// Interface
 249   3      						IN0BUF[0] = 0;
 250   3      						IN0BUF[1] = 0;
 251   3      						EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
 252   3      						break;
 253   3      					case GS_ENDPOINT:			// End Point
 254   3      						IN0BUF[0] = EPIO[EPID(SETUPDAT[4])].cntrl & bmEPSTALL;
 255   3      						IN0BUF[1] = 0;
 256   3      						EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
 257   3      						break;
 258   3      					default:				// Invalid Command
 259   3      						EZUSB_STALL_EP0();		// Stall End Point 0
 260   3      				}
 261   2      			break;
 262   2      		case SC_CLEAR_FEATURE:						// *** Clear Feature
 263   2      			if(DR_ClearFeature())
 264   2      				switch(SETUPDAT[0])
 265   2      				{
 266   3      					case FT_DEVICE:				// Device
 267   3      						if(SETUPDAT[2] == 1)
 268   3      							Rwuen = FALSE; 		// Disable Remote Wakeup
 269   3      						else
 270   3      							EZUSB_STALL_EP0();	// Stall End Point 0
 271   3      						break;
 272   3      					case FT_ENDPOINT:			// End Point
 273   3      						if(SETUPDAT[2] == 0)
 274   3                        {
 275   4      							EZUSB_UNSTALL_EP( EPID(SETUPDAT[4]) );
 276   4                           EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
 277   4                        }
 278   3      						else
 279   3      							EZUSB_STALL_EP0();	// Stall End Point 0
 280   3      						break;
 281   3      				}
 282   2      			break;
 283   2      		case SC_SET_FEATURE:						// *** Set Feature
 284   2      			if(DR_SetFeature())
 285   2      				switch(SETUPDAT[0])
 286   2      				{
 287   3      					case FT_DEVICE:				// Device
 288   3      						if(SETUPDAT[2] == 1)
 289   3      							Rwuen = TRUE;		// Enable Remote Wakeup
 290   3      						else
 291   3      							EZUSB_STALL_EP0();	// Stall End Point 0
 292   3      						break;
 293   3      					case FT_ENDPOINT:			// End Point
 294   3      						if(SETUPDAT[2] == 0)
 295   3      							EZUSB_STALL_EP( EPID(SETUPDAT[4]) );
 296   3      						else
 297   3      							EZUSB_STALL_EP0();	 // Stall End Point 0
 298   3      						break;
 299   3      				}
 300   2      			break;
 301   2      		default:							// *** Invalid Command
 302   2      			if(DR_VendorCmnd())
C51 COMPILER V6.10  FW                                                                     11/29/2002 10:53:59 PAGE 6   

 303   2      				EZUSB_STALL_EP0();				// Stall End Point 0
 304   2      	}
 305   1      
 306   1      	// Acknowledge handshake phase of device request
 307   1      	// Required for rev C does not effect rev B
 308   1      	EP0CS |= bmBIT1;
 309   1      }
 310          
 311          // Wake-up interrupt handler
 312          void resume_isr(void) interrupt WKUP_VECT
 313          {
 314   1      	EZUSB_CLEAR_RSMIRQ();
 315   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1121    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      6      27
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      4    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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