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

📄 fw.lst

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

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

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


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1095    ----
   CONSTANT SIZE    =     10    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     14      16
   IDATA SIZE       =   ----    ----
C51 COMPILER V7.50   FW                                                                    08/10/2005 09:49:04 PAGE 7   

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