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

📄 fw.lst

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

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

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


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    984    ----
   CONSTANT SIZE    =     10    ----
   XDATA SIZE       =   ----    ----
C51 COMPILER V7.02b   FW                                                                   06/04/2004 16:10:48 PAGE 7   

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