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

📄 fw.lst

📁 实现了ez-usb fx2的GPIF单字节读写功能
💻 LST
📖 第 1 页 / 共 2 页
字号:
 204   3               SetupCommand();          // Implement setup command
 205   3                 GotSUD = FALSE;            // Clear SUDAV flag
 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                if(GpifTestFlag == 0)
 233   2                {
 234   3                    Peripheral_SingleByteWrite(GpifWriteData);  //write a data to sram
 235   3                    Peripheral_SingleByteRead(&GpifReadData);   //read a data  from sram
 236   3                    if(GpifReadData != GpifWriteData)           //not equal
 237   3                    {
 238   4                             Serial_SendString((BYTE xdata *)"error",5,0);   //display error
 239   4                    }
 240   3                        GpifWriteData++;
C51 COMPILER V7.02b   FW                                                                   07/11/2004 12:05:27 PAGE 5   

 241   3                        if(GpifWriteData == 0)             //在一个单元中写完0x00~0xFF
 242   3                        {
 243   4                                GpifLowAddr++;                 //写下一个地址单元
 244   4                                GpifLowAddr&=0x01FF;
 245   4                            Peripheral_SetAddress(GpifLowAddr);       //set low address
 246   4                                if(GpifLowAddr == 0)           //写完512个地址单元
 247   4                                {
 248   5                                         GpifHighAddr++;            //写下一个512
 249   5                                         GpifHighAddr&=0x3F;
 250   5                                         *GA = GpifHighAddr;        //置SRAM的高地址
 251   5                                         if(GpifHighAddr == 0)      //测试完成
 252   5                                         {
 253   6                                                 Serial_SendString((BYTE xdata *)"\rTest Finish\r",13,0);
 254   6                                                 GpifTestFlag = 1;
 255   6                                         }
 256   5                                }
 257   4                        }
 258   3                }
 259   2         }
 260   1      }
 261          
 262          // Device request parser
 263          void SetupCommand(void)
 264          {
 265   1         void   *dscr_ptr;
 266   1      
 267   1         switch(SETUPDAT[1])
 268   1         {
 269   2            case SC_GET_DESCRIPTOR:                  // *** Get Descriptor
 270   2               if(DR_GetDescriptor())
 271   2                  switch(SETUPDAT[3])         
 272   2                  {
 273   3                     case GD_DEVICE:            // Device
 274   3                        SUDPTRH = MSB(pDeviceDscr);
 275   3                        SUDPTRL = LSB(pDeviceDscr);
 276   3                        break;
 277   3                     case GD_DEVICE_QUALIFIER:            // Device Qualifier
 278   3                        SUDPTRH = MSB(pDeviceQualDscr);
 279   3                        SUDPTRL = LSB(pDeviceQualDscr);
 280   3                        break;
 281   3                     case GD_CONFIGURATION:         // Configuration
 282   3                        SUDPTRH = MSB(pConfigDscr);
 283   3                        SUDPTRL = LSB(pConfigDscr);
 284   3                        break;
 285   3                     case GD_OTHER_SPEED_CONFIGURATION:  // Other Speed Configuration
 286   3                        SUDPTRH = MSB(pOtherConfigDscr);
 287   3                        SUDPTRL = LSB(pOtherConfigDscr);
 288   3                        break;
 289   3                     case GD_STRING:            // String
 290   3                        if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
 291   3                        {
 292   4                           SUDPTRH = MSB(dscr_ptr);
 293   4                           SUDPTRL = LSB(dscr_ptr);
 294   4                        }
 295   3                        else 
 296   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 297   3                        break;
 298   3                     default:            // Invalid request
 299   3                        EZUSB_STALL_EP0();      // Stall End Point 0
 300   3                  }
 301   2               break;
 302   2            case SC_GET_INTERFACE:                  // *** Get Interface
C51 COMPILER V7.02b   FW                                                                   07/11/2004 12:05:27 PAGE 6   

 303   2               DR_GetInterface();
 304   2               break;
 305   2            case SC_SET_INTERFACE:                  // *** Set Interface
 306   2               DR_SetInterface();
 307   2               break;
 308   2            case SC_SET_CONFIGURATION:               // *** Set Configuration
 309   2               DR_SetConfiguration();
 310   2               break;
 311   2            case SC_GET_CONFIGURATION:               // *** Get Configuration
 312   2               DR_GetConfiguration();
 313   2               break;
 314   2            case SC_GET_STATUS:                  // *** Get Status
 315   2               if(DR_GetStatus())
 316   2                  switch(SETUPDAT[0])
 317   2                  {
 318   3                     case GS_DEVICE:            // Device
 319   3                        EP0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
 320   3                        EP0BUF[1] = 0;
 321   3                        EP0BCH = 0;
 322   3                        EP0BCL = 2;
 323   3                        break;
 324   3                     case GS_INTERFACE:         // Interface
 325   3                        EP0BUF[0] = 0;
 326   3                        EP0BUF[1] = 0;
 327   3                        EP0BCH = 0;
 328   3                        EP0BCL = 2;
 329   3                        break;
 330   3                     case GS_ENDPOINT:         // End Point
 331   3                        EP0BUF[0] = *(BYTE xdata *) epcs(SETUPDAT[4]) & bmEPSTALL;
 332   3                        EP0BUF[1] = 0;
 333   3                        EP0BCH = 0;
 334   3                        EP0BCL = 2;
 335   3                        break;
 336   3                     default:            // Invalid Command
 337   3                        EZUSB_STALL_EP0();      // Stall End Point 0
 338   3                  }
 339   2               break;
 340   2            case SC_CLEAR_FEATURE:                  // *** Clear Feature
 341   2               if(DR_ClearFeature())
 342   2                  switch(SETUPDAT[0])
 343   2                  {
 344   3                     case FT_DEVICE:            // Device
 345   3                        if(SETUPDAT[2] == 1)
 346   3                           Rwuen = FALSE;       // Disable Remote Wakeup
 347   3                        else
 348   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 349   3                        break;
 350   3                     case FT_ENDPOINT:         // End Point
 351   3                        if(SETUPDAT[2] == 0)
 352   3                        {
 353   4                           *(BYTE xdata *) epcs(SETUPDAT[4]) &= ~bmEPSTALL;
 354   4                           EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
 355   4                        }
 356   3                        else
 357   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 358   3                        break;
 359   3                  }
 360   2               break;
 361   2            case SC_SET_FEATURE:                  // *** Set Feature
 362   2               if(DR_SetFeature())
 363   2                  switch(SETUPDAT[0])
 364   2                  {
C51 COMPILER V7.02b   FW                                                                   07/11/2004 12:05:27 PAGE 7   

 365   3                     case FT_DEVICE:            // Device
 366   3                        if(SETUPDAT[2] == 1)
 367   3                           Rwuen = TRUE;      // Enable Remote Wakeup
 368   3                        else if(SETUPDAT[2] == 2)
 369   3                           // Set Feature Test Mode.  The core handles this request.  However, it is
 370   3                           // necessary for the firmware to complete the handshake phase of the
 371   3                           // control transfer before the chip will enter test mode.  It is also
 372   3                           // necessary for FX2 to be physically disconnected (D+ and D-)
 373   3                           // from the host before it will enter test mode.
 374   3                           break;
 375   3                        else
 376   3                           EZUSB_STALL_EP0();   // Stall End Point 0
 377   3                        break;
 378   3                     case FT_ENDPOINT:         // End Point
 379   3                        *(BYTE xdata *) epcs(SETUPDAT[4]) |= bmEPSTALL;
 380   3                        break;
 381   3                  }
 382   2               break;
 383   2            default:                     // *** Invalid Command
 384   2               if(DR_VendorCmnd())
 385   2                  EZUSB_STALL_EP0();            // Stall End Point 0
 386   2         }
 387   1      
 388   1         // Acknowledge handshake phase of device request
 389   1         EP0CS |= bmHSNAK;
 390   1      }
 391          
 392          // Wake-up interrupt handler
 393          void resume_isr(void) interrupt WKUP_VECT
 394          {
 395   1         EZUSB_CLEAR_RSMIRQ();
 396   1      }
 397          
 398          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1119    ----
   CONSTANT SIZE    =     43    ----
   XDATA SIZE       =   ----       1
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     14      21
   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 + -