📄 fw.lst
字号:
251 1 #ifndef NO_RENUM
252 1 // Renumerate if necessary. Do this by checking the renum bit. If it
253 1 // is already set, there is no need to renumerate. The renum bit will
254 1 // already be set if this firmware was loaded from an eeprom.
255 1 if(!(USBCS & bmRENUM))
256 1 {
257 2 EZUSB_Discon(TRUE); // renumerate
258 2 }
259 1 #endif
260 1
261 1 // unconditionally re-connect. If we loaded from eeprom we are
262 1 // disconnected and need to connect. If we just renumerated this
263 1 // is not necessary but doesn't hurt anything
264 1 USBCS &=~bmDISCON;
265 1
266 1 CKCON = (CKCON&(~bmSTRETCH)) | FW_STRETCH_VALUE; // Set stretch to 0 (after renumeration)
267 1
268 1 // clear the Sleep flag.
269 1 Sleep = FALSE;
270 1 memset(DispBuf,16,4);//无显示数据
271 1 // Task Dispatcher
272 1 while(TRUE) // Main Loop
273 1 {
274 2 if(GotSUD) // Wait for SUDAV
275 2 {
276 3 SetupCommand(); // Implement setup command
277 3 GotSUD = FALSE; // Clear SUDAV flag
278 3 }
279 2
280 2 // Poll User Device
281 2 // NOTE: Idle mode stops the processor clock. There are only two
282 2 // ways out of idle mode, the WAKEUP pin, and detection of the USB
283 2 // resume state on the USB bus. The timers will stop and the
284 2 // processor will not wake up on any other interrupts.
285 2 /* if (Sleep)
286 2 {
287 2 if(TD_Suspend())
288 2 {
289 2 Sleep = FALSE; // Clear the "go to sleep" flag. Do it here to prevent any race c
-ondition between wakeup and the next sleep.
290 2 do
291 2 {
292 2 EZUSB_Susp(); // Place processor in idle mode.
293 2 }
294 2 while(!Rwuen && EZUSB_EXTWAKEUP());
295 2 // Must continue to go back into suspend if the host has disabled remote wakeup
296 2 // *and* the wakeup was caused by the external wakeup pin.
297 2
298 2 // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
299 2 EZUSB_Resume(); // If source is the Wakeup# pin, signal the host to Resume.
300 2 TD_Resume();
301 2 }
302 2 }*/
C51 COMPILER V7.02b FW 06/13/2004 13:35:24 PAGE 6
303 2 TD_Poll();
304 2 Led_Display();
305 2 temp_data = Analyse_OTimerID(); //查询逻辑定时器
306 2 if(temp_data == OTimerID0) //1S定时到
307 2 {
308 3 Second++;
309 3 if(Second == 60)
310 3 {
311 4 Second = 0;
312 4 Mini++;
313 4 if(Mini == 60)
314 4 {
315 5 Mini = 0;
316 5 }
317 4 }
318 3 Disp_Updata();
319 3 }
320 2 else if(temp_data == OTimerID1) //WORD LED 闪烁定时器
321 2 {
322 3 IOE ^= WORK_LED;
323 3 }
324 2 ////////////////////////////////////////////////////////////
325 2 temp_data = OKey_RP_Scan(); //键盘扫描
326 2 switch(temp_data)
327 2 {
328 3 case 3:
329 3 Clock_Updata(0,0); //分钟加1
330 3 break;
331 3 case 1:
332 3 Clock_Updata(0,1); //分钟减1
333 3 break;
334 3 case 7:
335 3 Clock_Updata(1,0); //秒加1
336 3 break;
337 3 case 5:
338 3 Clock_Updata(1,1); //秒减1
339 3 break;
340 3 case 2:
341 3 Clock_Updata(0,2); //分钟清零
342 3 break;
343 3 case 4:
344 3 Clock_Updata(0,3); //分钟置‘59’
345 3 break;
346 3 case 6:
347 3 Clock_Updata(1,2); //秒清零
348 3 break;
349 3 case 8:
350 3 Clock_Updata(1,3); //秒置‘59’
351 3 break;
352 3 default:break;
353 3 }
354 2 }
355 1 }
356
357 // Device request parser
358 void SetupCommand(void)
359 {
360 1 void *dscr_ptr;
361 1
362 1 switch(SETUPDAT[1])
363 1 {
364 2 case SC_GET_DESCRIPTOR: // *** Get Descriptor
C51 COMPILER V7.02b FW 06/13/2004 13:35:24 PAGE 7
365 2 if(DR_GetDescriptor())
366 2 switch(SETUPDAT[3])
367 2 {
368 3 case GD_DEVICE: // Device
369 3 SUDPTRH = MSB(pDeviceDscr);
370 3 SUDPTRL = LSB(pDeviceDscr);
371 3 break;
372 3 case GD_DEVICE_QUALIFIER: // Device Qualifier
373 3 SUDPTRH = MSB(pDeviceQualDscr);
374 3 SUDPTRL = LSB(pDeviceQualDscr);
375 3 break;
376 3 case GD_CONFIGURATION: // Configuration
377 3 SUDPTRH = MSB(pConfigDscr);
378 3 SUDPTRL = LSB(pConfigDscr);
379 3 break;
380 3 case GD_OTHER_SPEED_CONFIGURATION: // Other Speed Configuration
381 3 SUDPTRH = MSB(pOtherConfigDscr);
382 3 SUDPTRL = LSB(pOtherConfigDscr);
383 3 break;
384 3 case GD_STRING: // String
385 3 if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
386 3 {
387 4 SUDPTRH = MSB(dscr_ptr);
388 4 SUDPTRL = LSB(dscr_ptr);
389 4 }
390 3 else
391 3 EZUSB_STALL_EP0(); // Stall End Point 0
392 3 break;
393 3 default: // Invalid request
394 3 EZUSB_STALL_EP0(); // Stall End Point 0
395 3 }
396 2 break;
397 2 case SC_GET_INTERFACE: // *** Get Interface
398 2 DR_GetInterface();
399 2 break;
400 2 case SC_SET_INTERFACE: // *** Set Interface
401 2 DR_SetInterface();
402 2 break;
403 2 case SC_SET_CONFIGURATION: // *** Set Configuration
404 2 DR_SetConfiguration();
405 2 break;
406 2 case SC_GET_CONFIGURATION: // *** Get Configuration
407 2 DR_GetConfiguration();
408 2 break;
409 2 case SC_GET_STATUS: // *** Get Status
410 2 if(DR_GetStatus())
411 2 switch(SETUPDAT[0])
412 2 {
413 3 case GS_DEVICE: // Device
414 3 EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
415 3 EP0BUF[1] = 0;
416 3 EP0BCH = 0;
417 3 EP0BCL = 2;
418 3 break;
419 3 case GS_INTERFACE: // Interface
420 3 EP0BUF[0] = 0;
421 3 EP0BUF[1] = 0;
422 3 EP0BCH = 0;
423 3 EP0BCL = 2;
424 3 break;
425 3 case GS_ENDPOINT: // End Point
426 3 EP0BUF[0] = *(BYTE xdata *) epcs(SETUPDAT[4]) & bmEPSTALL;
C51 COMPILER V7.02b FW 06/13/2004 13:35:24 PAGE 8
427 3 EP0BUF[1] = 0;
428 3 EP0BCH = 0;
429 3 EP0BCL = 2;
430 3 break;
431 3 default: // Invalid Command
432 3 EZUSB_STALL_EP0(); // Stall End Point 0
433 3 }
434 2 break;
435 2 case SC_CLEAR_FEATURE: // *** Clear Feature
436 2 if(DR_ClearFeature())
437 2 switch(SETUPDAT[0])
438 2 {
439 3 case FT_DEVICE: // Device
440 3 if(SETUPDAT[2] == 1)
441 3 Rwuen = FALSE; // Disable Remote Wakeup
442 3 else
443 3 EZUSB_STALL_EP0(); // Stall End Point 0
444 3 break;
445 3 case FT_ENDPOINT: // End Point
446 3 if(SETUPDAT[2] == 0)
447 3 {
448 4 *(BYTE xdata *) epcs(SETUPDAT[4]) &= ~bmEPSTALL;
449 4 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
450 4 }
451 3 else
452 3 EZUSB_STALL_EP0(); // Stall End Point 0
453 3 break;
454 3 }
455 2 break;
456 2 case SC_SET_FEATURE: // *** Set Feature
457 2 if(DR_SetFeature())
458 2 switch(SETUPDAT[0])
459 2 {
460 3 case FT_DEVICE: // Device
461 3 if(SETUPDAT[2] == 1)
462 3 Rwuen = TRUE; // Enable Remote Wakeup
463 3 else if(SETUPDAT[2] == 2)
464 3 // Set Feature Test Mode. The core handles this request. However, it is
465 3 // necessary for the firmware to complete the handshake phase of the
466 3 // control transfer before the chip will enter test mode. It is also
467 3 // necessary for FX2 to be physically disconnected (D+ and D-)
468 3 // from the host before it will enter test mode.
469 3 break;
470 3 else
471 3 EZUSB_STALL_EP0(); // Stall End Point 0
472 3 break;
473 3 case FT_ENDPOINT: // End Point
474 3 *(BYTE xdata *) epcs(SETUPDAT[4]) |= bmEPSTALL;
475 3 break;
476 3 }
477 2 break;
478 2 default: // *** Invalid Command
479 2 if(DR_VendorCmnd())
480 2 EZUSB_STALL_EP0(); // Stall End Point 0
481 2 }
482 1
483 1 // Acknowledge handshake phase of device request
484 1 EP0CS |= bmHSNAK;
485 1 }
486
487 // Wake-up interrupt handler
488 void resume_isr(void) interrupt WKUP_VECT
C51 COMPILER V7.02b FW 06/13/2004 13:35:24 PAGE 9
489 {
490 1 EZUSB_CLEAR_RSMIRQ();
491 1 }
492
493
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1279 ----
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 16 17
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 + -