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

📄 fw.lst

📁 用于进行Cypress USB FX2控制
💻 LST
📖 第 1 页 / 共 2 页
字号:
 196   2            // check for and handle suspend.
 197   2            // NOTE: Idle mode stops the processor clock.  There are only two
 198   2            // ways out of idle mode, the WAKEUP pin, and detection of the USB
 199   2            // resume state on the USB bus.  The timers will stop and the
 200   2            // processor will not wake up on any other interrupts.
 201   2            if (Sleep)
 202   2            {
 203   3               if(TD_Suspend())
 204   3               { 
 205   4                  Sleep = FALSE;     // Clear the "go to sleep" flag.  Do it here to prevent any race condition 
             -between wakeup and the next sleep.
 206   4                  do
 207   4                  {
 208   5                     EZUSB_Susp();         // Place processor in idle mode.
 209   5                  }
 210   4                  while(!Rwuen && EZUSB_EXTWAKEUP());
 211   4                  // above.  Must continue to go back into suspend if the host has disabled remote wakeup
 212   4                  // *and* the wakeup was caused by the external wakeup pin.
 213   4      
 214   4                  // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
 215   4                  EZUSB_Resume();   // If source is the Wakeup# pin, signal the host to Resume.      
 216   4                  TD_Resume();
 217   4               }   
 218   3            }
 219   2      
 220   2         }
 221   1      }
 222          
 223          BOOL HighSpeedCapable()
 224          {
 225   1         // this function determines if the chip is high-speed capable.
 226   1         // FX2 and FX2LP are high-speed capable. FX1 is not - it does
 227   1         // not have a high-speed transceiver.
 228   1      
 229   1         if (GPCR2 & bmFULLSPEEDONLY)
 230   1            return FALSE;
 231   1         else
 232   1            return TRUE;
 233   1      }   
 234          
 235          // Device request parser
 236          void SetupCommand(void)
 237          {
 238   1         void   *dscr_ptr;
 239   1      
 240   1         switch(SETUPDAT[1])
C51 COMPILER V8.05a   FW                                                                   04/30/2008 16:42:26 PAGE 5   

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

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

 365   3                  }
 366   2               break;
 367   2            default:                     // *** Invalid Command
 368   2               if(DR_VendorCmnd())
 369   2                  EZUSB_STALL_EP0();            // Stall End Point 0
 370   2         }
 371   1      
 372   1         // Acknowledge handshake phase of device request
 373   1         EP0CS |= bmHSNAK;
 374   1      }
 375          
 376          // Wake-up interrupt handler
 377          void resume_isr(void) interrupt WKUP_VECT
 378          {
 379   1         EZUSB_CLEAR_RSMIRQ();
 380   1      }
 381          
 382          


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