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

📄 fw.lst

📁 针对USB开发板的HID键盘,里面有原代码,可以用KEIL直接编译通过,另外有原理图.
💻 LST
📖 第 1 页 / 共 2 页
字号:
 196   4                  {
 197   5                     EZUSB_Susp();         // Place processor in idle mode.
 198   5                  }
 199   4                  while(!Rwuen && EZUSB_EXTWAKEUP());
 200   4                  // above.  Must continue to go back into suspend if the host has disabled remote wakeup
 201   4                  // *and* the wakeup was caused by the external wakeup pin.
 202   4      
 203   4                  // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
 204   4                  EZUSB_Resume();   // If source is the Wakeup# pin, signal the host to Resume.      
 205   4                  TD_Resume();
 206   4               }   
 207   3            }
 208   2      
 209   2         }
 210   1      }
 211          
 212          BOOL HighSpeedCapable()
 213          {
 214   1         // this function determines if the chip is high-speed capable.
 215   1         // FX2 and FX2LP are high-speed capable. FX1 is not - it does
 216   1         // not have a high-speed transceiver.  The frameworks determines
 217   1         // the chip's speed capability at run time to allow fx2lp and
 218   1         // fx1 object code compatibilty.
 219   1      
 220   1         if (REVID & 0xF0)    // check for fx2lp/fx1 v. fx2.  
 221   1         {
 222   2               
 223   2            // this is a fx2lp or fx1 because non-zero upper nibble in chip rev
 224   2            // now check the capabilities register
 225   2            if (GPCR2 & bmHIGHSPEEDCAPABLE)
 226   2               return TRUE;
 227   2            else
 228   2               return FALSE;
 229   2         }
 230   1         else
 231   1         {
 232   2            // fx2 is always high-speed capable
 233   2            return TRUE;
 234   2         }
 235   1      }   
 236          
 237          // Device request parser
 238          void SetupCommand(void)
 239          {
 240   1         void   *dscr_ptr;
C51 COMPILER V7.50   FW                                                                    09/24/2007 17:04:29 PAGE 5   

 241   1      
 242   1         switch(SETUPDAT[1])
 243   1         {
 244   2            case SC_GET_DESCRIPTOR:                  // *** Get Descriptor
 245   2               if(DR_GetDescriptor())
 246   2                  switch(SETUPDAT[3])         
 247   2                  {
 248   3                     case GD_DEVICE:            // Device
 249   3                        SUDPTRH = MSB(pDeviceDscr);
 250   3                        SUDPTRL = LSB(pDeviceDscr);
 251   3                        break;
 252   3                     case GD_DEVICE_QUALIFIER:            // Device Qualifier
 253   3                                        // only retuen a device qualifier if this is a high speed
 254   3                                        // capable chip.
 255   3                                        if (HighSpeedCapable())
 256   3                                        {
 257   4                                SUDPTRH = MSB(pDeviceQualDscr);
 258   4                                SUDPTRL = LSB(pDeviceQualDscr);
 259   4                                        }
 260   3                                        else
 261   3                                        {
 262   4                                                EZUSB_STALL_EP0();
 263   4                                        }
 264   3                                        break;
 265   3                     case GD_CONFIGURATION:         // Configuration
 266   3                        SUDPTRH = MSB(pConfigDscr);
 267   3                        SUDPTRL = LSB(pConfigDscr);
 268   3                        break;
 269   3                     case GD_OTHER_SPEED_CONFIGURATION:  // Other Speed Configuration
 270   3                        SUDPTRH = MSB(pOtherConfigDscr);
 271   3                        SUDPTRL = LSB(pOtherConfigDscr);
 272   3                        break;
 273   3                     case GD_STRING:            // String
 274   3                        if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
 275   3                        {
 276   4                           SUDPTRH = MSB(dscr_ptr);
 277   4                           SUDPTRL = LSB(dscr_ptr);
 278   4                        }
 279   3                        else 
 280   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 281   3                        break;
 282   3                     default:            // Invalid request
 283   3                        EZUSB_STALL_EP0();      // Stall End Point 0
 284   3                  }
 285   2               break;
 286   2            case SC_GET_INTERFACE:                  // *** Get Interface
 287   2               DR_GetInterface();
 288   2               break;
 289   2            case SC_SET_INTERFACE:                  // *** Set Interface
 290   2               DR_SetInterface();
 291   2               break;
 292   2            case SC_SET_CONFIGURATION:               // *** Set Configuration
 293   2               DR_SetConfiguration();
 294   2               break;
 295   2            case SC_GET_CONFIGURATION:               // *** Get Configuration
 296   2               DR_GetConfiguration();
 297   2               break;
 298   2            case SC_GET_STATUS:                  // *** Get Status
 299   2               if(DR_GetStatus())
 300   2                  switch(SETUPDAT[0])
 301   2                  {
 302   3                     case GS_DEVICE:            // Device
C51 COMPILER V7.50   FW                                                                    09/24/2007 17:04:29 PAGE 6   

 303   3                        EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
 304   3                        EP0BUF[1] = 0;
 305   3                        EP0BCH = 0;
 306   3                        EP0BCL = 2;
 307   3                        break;
 308   3                     case GS_INTERFACE:         // Interface
 309   3                        EP0BUF[0] = 0;
 310   3                        EP0BUF[1] = 0;
 311   3                        EP0BCH = 0;
 312   3                        EP0BCL = 2;
 313   3                        break;
 314   3                     case GS_ENDPOINT:         // End Point
 315   3                        EP0BUF[0] = *(BYTE xdata *) epcs(SETUPDAT[4]) & bmEPSTALL;
 316   3                        EP0BUF[1] = 0;
 317   3                        EP0BCH = 0;
 318   3                        EP0BCL = 2;
 319   3                        break;
 320   3                     default:            // Invalid Command
 321   3                        EZUSB_STALL_EP0();      // Stall End Point 0
 322   3                  }
 323   2               break;
 324   2            case SC_CLEAR_FEATURE:                  // *** Clear Feature
 325   2               if(DR_ClearFeature())
 326   2                  switch(SETUPDAT[0])
 327   2                  {
 328   3                     case FT_DEVICE:            // Device
 329   3                        if(SETUPDAT[2] == 1)
 330   3                           Rwuen = FALSE;       // Disable Remote Wakeup
 331   3                        else
 332   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 333   3                        break;
 334   3                     case FT_ENDPOINT:         // End Point
 335   3                        if(SETUPDAT[2] == 0)
 336   3                        {
 337   4                           *(BYTE xdata *) epcs(SETUPDAT[4]) &= ~bmEPSTALL;
 338   4                           EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
 339   4                        }
 340   3                        else
 341   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 342   3                        break;
 343   3                  }
 344   2               break;
 345   2            case SC_SET_FEATURE:                  // *** Set Feature
 346   2               if(DR_SetFeature())
 347   2                  switch(SETUPDAT[0])
 348   2                  {
 349   3                     case FT_DEVICE:            // Device
 350   3                        if(SETUPDAT[2] == 1)
 351   3                           Rwuen = TRUE;      // Enable Remote Wakeup
 352   3                        else if(SETUPDAT[2] == 2)
 353   3                           // Set Feature Test Mode.  The core handles this request.  However, it is
 354   3                           // necessary for the firmware to complete the handshake phase of the
 355   3                           // control transfer before the chip will enter test mode.  It is also
 356   3                           // necessary for FX2 to be physically disconnected (D+ and D-)
 357   3                           // from the host before it will enter test mode.
 358   3                           break;
 359   3                        else
 360   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 361   3                        break;
 362   3                     case FT_ENDPOINT:         // End Point
 363   3                        *(BYTE xdata *) epcs(SETUPDAT[4]) |= bmEPSTALL;
 364   3                        break;
C51 COMPILER V7.50   FW                                                                    09/24/2007 17:04:29 PAGE 7   

 365   3                     default:
 366   3                        EZUSB_STALL_EP0();      // Stall End Point 0
 367   3                  }
 368   2               break;
 369   2            default:                     // *** Invalid Command
 370   2               if(DR_VendorCmnd())
 371   2                  EZUSB_STALL_EP0();            // Stall End Point 0
 372   2         }
 373   1      
 374   1         // Acknowledge handshake phase of device request
 375   1         EP0CS |= bmHSNAK;
 376   1      }
 377          
 378          // Wake-up interrupt handler
 379          void resume_isr(void) interrupt WKUP_VECT
 380          {
 381   1         EZUSB_CLEAR_RSMIRQ();
 382   1      }
 383          
 384          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    951    ----
   CONSTANT SIZE    =     10    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     14      16
   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 + -