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

📄 fw.lst

📁 usb固件程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 183   1      
 184   1         // Task Dispatcher
 185   1         while(TRUE)               // Main Loop
 186   1         {
 187   2            if(GotSUD)            // Wait for SUDAV
 188   2            {
 189   3               SetupCommand();          // Implement setup command
 190   3                 GotSUD = FALSE;            // Clear SUDAV flag
 191   3            }
 192   2      
 193   2            // Poll User Device
 194   2            // NOTE: Idle mode stops the processor clock.  There are only two
 195   2            // ways out of idle mode, the WAKEUP pin, and detection of the USB
 196   2            // resume state on the USB bus.  The timers will stop and the
 197   2            // processor will not wake up on any other interrupts.
 198   2            if (Sleep)
 199   2                {
 200   3                if(TD_Suspend())
 201   3                    { 
 202   4                    Sleep = FALSE;            // Clear the "go to sleep" flag.  Do it here to prevent any race c
             -ondition between wakeup and the next sleep.
 203   4                    do
 204   4                        {
 205   5                          EZUSB_Susp();         // Place processor in idle mode.
 206   5                        }
 207   4                      while(!Rwuen && EZUSB_EXTWAKEUP());
 208   4                      // Must continue to go back into suspend if the host has disabled remote wakeup
 209   4                      // *and* the wakeup was caused by the external wakeup pin.
 210   4                      
 211   4                   // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
 212   4                   EZUSB_Resume();   // If source is the Wakeup# pin, signal the host to Resume.      
 213   4                   TD_Resume();
 214   4                    }   
 215   3                }
 216   2            TD_Poll();
 217   2         }
 218   1      }
 219          
 220          // Device request parser
 221          void SetupCommand(void)
 222          {
 223   1         void   *dscr_ptr;
 224   1      
 225   1         switch(SETUPDAT[1])
 226   1         {
 227   2            case SC_GET_DESCRIPTOR:                  // *** Get Descriptor
 228   2               if(DR_GetDescriptor())
 229   2                  switch(SETUPDAT[3])         
 230   2                  {
 231   3                     case GD_DEVICE:            // Device
 232   3                        SUDPTRH = MSB(pDeviceDscr);
 233   3                        SUDPTRL = LSB(pDeviceDscr);
 234   3                        break;
 235   3                     case GD_DEVICE_QUALIFIER:            // Device Qualifier
 236   3                        SUDPTRH = MSB(pDeviceQualDscr);
 237   3                        SUDPTRL = LSB(pDeviceQualDscr);
 238   3                        break;
 239   3                     case GD_CONFIGURATION:         // Configuration
 240   3                        SUDPTRH = MSB(pConfigDscr);
C51 COMPILER V6.10  FW                                                                     04/10/2008 17:22:30 PAGE 5   

 241   3                        SUDPTRL = LSB(pConfigDscr);
 242   3                        break;
 243   3                     case GD_OTHER_SPEED_CONFIGURATION:  // Other Speed Configuration
 244   3                        SUDPTRH = MSB(pOtherConfigDscr);
 245   3                        SUDPTRL = LSB(pOtherConfigDscr);
 246   3                        break;
 247   3                     case GD_STRING:            // String
 248   3                        if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
 249   3                        {
 250   4                           SUDPTRH = MSB(dscr_ptr);
 251   4                           SUDPTRL = LSB(dscr_ptr);
 252   4                        }
 253   3                        else 
 254   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 255   3                        break;
 256   3                     default:            // Invalid request
 257   3                        EZUSB_STALL_EP0();      // Stall End Point 0
 258   3                  }
 259   2               break;
 260   2            case SC_GET_INTERFACE:                  // *** Get Interface
 261   2               DR_GetInterface();
 262   2               break;
 263   2            case SC_SET_INTERFACE:                  // *** Set Interface
 264   2               DR_SetInterface();
 265   2               break;
 266   2            case SC_SET_CONFIGURATION:               // *** Set Configuration
 267   2               DR_SetConfiguration();
 268   2               break;
 269   2            case SC_GET_CONFIGURATION:               // *** Get Configuration
 270   2               DR_GetConfiguration();
 271   2               break;
 272   2            case SC_GET_STATUS:                  // *** Get Status
 273   2               if(DR_GetStatus())
 274   2                  switch(SETUPDAT[0])
 275   2                  {
 276   3                     case GS_DEVICE:            // Device
 277   3                        EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
 278   3                        EP0BUF[1] = 0;
 279   3                        EP0BCH = 0;
 280   3                        EP0BCL = 2;
 281   3                        break;
 282   3                     case GS_INTERFACE:         // Interface
 283   3                        EP0BUF[0] = 0;
 284   3                        EP0BUF[1] = 0;
 285   3                        EP0BCH = 0;
 286   3                        EP0BCL = 2;
 287   3                        break;
 288   3                     case GS_ENDPOINT:         // End Point
 289   3                        EP0BUF[0] = *(BYTE xdata *) epcs(SETUPDAT[4]) & bmEPSTALL;
 290   3                        EP0BUF[1] = 0;
 291   3                        EP0BCH = 0;
 292   3                        EP0BCL = 2;
 293   3                        break;
 294   3                     default:            // Invalid Command
 295   3                        EZUSB_STALL_EP0();      // Stall End Point 0
 296   3                  }
 297   2               break;
 298   2            case SC_CLEAR_FEATURE:                  // *** Clear Feature
 299   2               if(DR_ClearFeature())
 300   2                  switch(SETUPDAT[0])
 301   2                  {
 302   3                     case FT_DEVICE:            // Device
C51 COMPILER V6.10  FW                                                                     04/10/2008 17:22:30 PAGE 6   

 303   3                        if(SETUPDAT[2] == 1)
 304   3                           Rwuen = FALSE;       // Disable Remote Wakeup
 305   3                        else
 306   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 307   3                        break;
 308   3                     case FT_ENDPOINT:         // End Point
 309   3                        if(SETUPDAT[2] == 0)
 310   3                        {
 311   4                           *(BYTE xdata *) epcs(SETUPDAT[4]) &= ~bmEPSTALL;
 312   4                           EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
 313   4                        }
 314   3                        else
 315   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 316   3                        break;
 317   3                  }
 318   2               break;
 319   2            case SC_SET_FEATURE:                  // *** Set Feature
 320   2               if(DR_SetFeature())
 321   2                  switch(SETUPDAT[0])
 322   2                  {
 323   3                     case FT_DEVICE:            // Device
 324   3                        if(SETUPDAT[2] == 1)
 325   3                           Rwuen = TRUE;      // Enable Remote Wakeup
 326   3                        else if(SETUPDAT[2] == 2)
 327   3                           // Set Feature Test Mode.  The core handles this request.  However, it is
 328   3                           // necessary for the firmware to complete the handshake phase of the
 329   3                           // control transfer before the chip will enter test mode.  It is also
 330   3                           // necessary for FX2 to be physically disconnected (D+ and D-)
 331   3                           // from the host before it will enter test mode.
 332   3                           break;
 333   3                        else
 334   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 335   3                        break;
 336   3                     case FT_ENDPOINT:         // End Point
 337   3                        *(BYTE xdata *) epcs(SETUPDAT[4]) |= bmEPSTALL;
 338   3                        break;
 339   3                  }
 340   2               break;
 341   2            default:                     // *** Invalid Command
 342   2               if(DR_VendorCmnd())
 343   2                  EZUSB_STALL_EP0();            // Stall End Point 0
 344   2         }
 345   1      
 346   1         // Acknowledge handshake phase of device request
 347   1         EP0CS |= bmHSNAK;
 348   1      }
 349          
 350          // Wake-up interrupt handler
 351          void resume_isr(void) interrupt WKUP_VECT
 352          {
 353   1         EZUSB_CLEAR_RSMIRQ();
 354   1      }
 355          
 356          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1098    ----
   CONSTANT SIZE    =     10    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     14      16
C51 COMPILER V6.10  FW                                                                     04/10/2008 17:22:30 PAGE 7   

   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 + -