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

📄 fw.lst

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

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

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

 365   1         EZUSB_CLEAR_RSMIRQ();
 366   1      }
 367          
 368          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1144    ----
   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 + -