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

📄 fw.lst

📁 CY7c68013 GPIF程序绝对可用
💻 LST
📖 第 1 页 / 共 2 页
字号:
 191   1         USBCS &=~bmDISCON;
 192   1      
 193   1         CKCON = (CKCON&(~bmSTRETCH)) | FW_STRETCH_VALUE; // Set stretch to 0 (after renumeration)
 194   1      
 195   1         // clear the Sleep flag.
 196   1         Sleep = FALSE;
 197   1      
 198   1         // Task Dispatcher
 199   1         while(TRUE)               // Main Loop
 200   1         {
 201   2            if(GotSUD)            // Wait for SUDAV
 202   2            {
 203   3               SetupCommand();          // Implement setup command
 204   3                 GotSUD = FALSE;            // Clear SUDAV flag
 205   3                          
 206   3            }
 207   2              
 208   2       // Poll User Device
 209   2            // NOTE: Idle mode stops the processor clock.  There are only two
 210   2            // ways out of idle mode, the WAKEUP pin, and detection of the USB
 211   2            // resume state on the USB bus.  The timers will stop and the
 212   2            // processor will not wake up on any other interrupts.
 213   2            if (Sleep)
 214   2                {
 215   3                if(TD_Suspend())
 216   3                    { 
 217   4                    Sleep = FALSE;            // Clear the "go to sleep" flag.  Do it here to prevent any race c
             -ondition between wakeup and the next sleep.
 218   4                    do
 219   4                        {
 220   5                          EZUSB_Susp();         // Place processor in idle mode.
 221   5                        }
 222   4                      while(!Rwuen && EZUSB_EXTWAKEUP());
 223   4                      // Must continue to go back into suspend if the host has disabled remote wakeup
 224   4                      // *and* the wakeup was caused by the external wakeup pin.
 225   4                      
 226   4                   // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
 227   4                   EZUSB_Resume();   // If source is the Wakeup# pin, signal the host to Resume.      
 228   4                   TD_Resume();
 229   4                    }   
 230   3                }
 231   2               TD_Poll();
 232   2           
 233   2         }
 234   1      }
 235          
 236          // Device request parser
 237          void SetupCommand(void)
 238          {
 239   1         void   *dscr_ptr;
 240   1              
C51 COMPILER V7.20   FW                                                                    01/14/2008 15:01:54 PAGE 5   

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

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

 365   1         // Acknowledge handshake phase of device request
 366   1         EP0CS |= bmHSNAK;
 367   1      }
 368          
 369          // Wake-up interrupt handler
 370          void resume_isr(void) interrupt WKUP_VECT
 371          {
 372   1         EZUSB_CLEAR_RSMIRQ();
 373   1      }


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