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

📄 fw.lst

📁 EZ-USB FX2的一个单字读和单字写的程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 173   2      
 174   2            // Poll User Device
 175   2            // NOTE: Idle mode stops the processor clock.  There are only two
 176   2            // ways out of idle mode, the WAKEUP pin, and detection of the USB
 177   2            // resume state on the USB bus.  The timers will stop and the
 178   2            // processor will not wake up on any other interrupts.
 179   2            if (Sleep)
C51 COMPILER V6.10  FW                                                                     06/22/2006 16:02:23 PAGE 4   

 180   2                {
 181   3                if(TD_Suspend())
 182   3                    { 
 183   4                    Sleep = FALSE;            // Clear the "go to sleep" flag.  Do it here to prevent any race c
             -ondition between wakeup and the next sleep.
 184   4                    do
 185   4                        {
 186   5                          EZUSB_Susp();         // Place processor in idle mode.
 187   5                        }
 188   4                      while(!Rwuen && EZUSB_EXTWAKEUP());
 189   4                      // Must continue to go back into suspend if the host has disabled remote wakeup
 190   4                      // *and* the wakeup was caused by the external wakeup pin.
 191   4                      
 192   4                   // 8051 activity will resume here due to USB bus or Wakeup# pin activity.
 193   4                   EZUSB_Resume();   // If source is the Wakeup# pin, signal the host to Resume.      
 194   4                   TD_Resume();
 195   4                    }   
 196   3                }
 197   2            TD_Poll();
 198   2         }
 199   1      }
 200          
 201          // Device request parser
 202          void SetupCommand(void)
 203          {
 204   1         void   *dscr_ptr;
 205   1      
 206   1         switch(SETUPDAT[1])
 207   1         {
 208   2            case SC_GET_DESCRIPTOR:                  // *** Get Descriptor
 209   2               if(DR_GetDescriptor())
 210   2                  switch(SETUPDAT[3])         
 211   2                  {
 212   3                     case GD_DEVICE:            // Device
 213   3                        SUDPTRH = MSB(pDeviceDscr);
 214   3                        SUDPTRL = LSB(pDeviceDscr);
 215   3                        break;
 216   3                     case GD_DEVICE_QUALIFIER:            // Device Qualifier
 217   3                        SUDPTRH = MSB(pDeviceQualDscr);
 218   3                        SUDPTRL = LSB(pDeviceQualDscr);
 219   3                        break;
 220   3                     case GD_CONFIGURATION:         // Configuration
 221   3                        SUDPTRH = MSB(pConfigDscr);
 222   3                        SUDPTRL = LSB(pConfigDscr);
 223   3                        break;
 224   3                     case GD_OTHER_SPEED_CONFIGURATION:  // Other Speed Configuration
 225   3                        // fx2bug - need to support multi other configs
 226   3                        SUDPTRH = MSB(pOtherConfigDscr);
 227   3                        SUDPTRL = LSB(pOtherConfigDscr);
 228   3                        break;
 229   3                     case GD_STRING:            // String
 230   3                        if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
 231   3                        {
 232   4                           SUDPTRH = MSB(dscr_ptr);
 233   4                           SUDPTRL = LSB(dscr_ptr);
 234   4                        }
 235   3                        else 
 236   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 237   3                        break;
 238   3                     default:            // Invalid request
 239   3                        EZUSB_STALL_EP0();      // Stall End Point 0
 240   3                  }
C51 COMPILER V6.10  FW                                                                     06/22/2006 16:02:23 PAGE 5   

 241   2               break;
 242   2            case SC_GET_INTERFACE:                  // *** Get Interface
 243   2               DR_GetInterface();
 244   2               break;
 245   2            case SC_SET_INTERFACE:                  // *** Set Interface
 246   2               DR_SetInterface();
 247   2               break;
 248   2            case SC_SET_CONFIGURATION:               // *** Set Configuration
 249   2               DR_SetConfiguration();
 250   2               break;
 251   2            case SC_GET_CONFIGURATION:               // *** Get Configuration
 252   2               DR_GetConfiguration();
 253   2               break;
 254   2            case SC_GET_STATUS:                  // *** Get Status
 255   2               if(DR_GetStatus())
 256   2                  switch(SETUPDAT[0])
 257   2                  {
 258   3                     case GS_DEVICE:            // Device
 259   3                        EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
 260   3                        EP0BUF[1] = 0;
 261   3                        EP0BCH = 0;
 262   3                        EP0BCL = 2;
 263   3                        break;
 264   3                     case GS_INTERFACE:         // Interface
 265   3                        EP0BUF[0] = 0;
 266   3                        EP0BUF[1] = 0;
 267   3                        EP0BCH = 0;
 268   3                        EP0BCL = 2;
 269   3                        break;
 270   3                     case GS_ENDPOINT:         // End Point
 271   3      // fx2bug                  EP0BUF[0] = EPIO[EPID(SETUPDAT[4])].cntrl & bmEPSTALL;
 272   3      
 273   3                        EP0BUF[1] = 0;
 274   3                        EP0BCH = 0;
 275   3                        EP0BCL = 2;
 276   3                        break;
 277   3                     default:            // Invalid Command
 278   3                        EZUSB_STALL_EP0();      // Stall End Point 0
 279   3                  }
 280   2               break;
 281   2            case SC_CLEAR_FEATURE:                  // *** Clear Feature
 282   2               if(DR_ClearFeature())
 283   2                  switch(SETUPDAT[0])
 284   2                  {
 285   3                     case FT_DEVICE:            // Device
 286   3                        if(SETUPDAT[2] == 1)
 287   3                           Rwuen = FALSE;       // Disable Remote Wakeup
 288   3                        else
 289   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 290   3                        break;
 291   3                     case FT_ENDPOINT:         // End Point
 292   3                        if(SETUPDAT[2] == 0)
 293   3                        {
 294   4      // fx2bug                     EZUSB_UNSTALL_EP( EPID(SETUPDAT[4]) );
 295   4      // fx2bug                     EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
 296   4                        }
 297   3                        else
 298   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 299   3                        break;
 300   3                  }
 301   2               break;
 302   2            case SC_SET_FEATURE:                  // *** Set Feature
C51 COMPILER V6.10  FW                                                                     06/22/2006 16:02:23 PAGE 6   

 303   2               if(DR_SetFeature())
 304   2                  switch(SETUPDAT[0])
 305   2                  {
 306   3                     case FT_DEVICE:            // Device
 307   3                        if(SETUPDAT[2] == 1)
 308   3                           Rwuen = TRUE;      // Enable Remote Wakeup
 309   3                        else
 310   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 311   3                        break;
 312   3                     case FT_ENDPOINT:         // End Point
 313   3      // fx2bug                  if(SETUPDAT[2] == 0)
 314   3      // fx2bug                     EZUSB_STALL_EP( EPID(SETUPDAT[4]) );
 315   3      // fx2bug                  else
 316   3                           EZUSB_STALL_EP0();    // Stall End Point 0
 317   3                        break;
 318   3                  }
 319   2               break;
 320   2            default:                     // *** Invalid Command
 321   2               if(DR_VendorCmnd())
 322   2                  EZUSB_STALL_EP0();            // Stall End Point 0
 323   2         }
 324   1      
 325   1         // Acknowledge handshake phase of device request
 326   1         // Required for rev C does not effect rev B
 327   1      // TGE fx2bug   EP0CS |= bmBIT1; 
 328   1          EP0CS |= bmHSNAK;
 329   1      }
 330          
 331          // Wake-up interrupt handler
 332          void resume_isr(void) interrupt WKUP_VECT
 333          {
 334   1         EZUSB_CLEAR_RSMIRQ();
 335   1      }


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