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

📄 fw.lst

📁 linux下数据下载器的设计与实现
💻 LST
📖 第 1 页 / 共 2 页
字号:
 229   4                        default:                   // Invalid request
 230   4                           EZUSB_STALL_EP0();      // Stall End Point 0
 231   4                     }  // switch
 232   3                  break;
 233   3               case SC_GET_INTERFACE:              // *** Get Interface
 234   3                  EP0BUF[0] = AlternateSetting;
 235   3                  EP0BCL = 1;
 236   3                  break;
 237   3               case SC_SET_INTERFACE:                  // *** Set Interface
 238   3                  TOGCTL = 0x2;     // Reset data toggle for EP2
 239   3                  TOGCTL = 0x22;
 240   3                  TOGCTL = 0x14;    // Reset data toggle for EP4
C51 COMPILER V7.50   FW                                                                    10/12/2007 17:05:42 PAGE 5   

 241   3                  TOGCTL = 0x34;
 242   3                  AlternateSetting = setupdat2;
 243   3                  break;
 244   3               case SC_SET_CONFIGURATION:               // *** Set Configuration
 245   3                  Configuration = setupdat2;
 246   3                  break;
 247   3               case SC_GET_CONFIGURATION:               // *** Get Configuration
 248   3                  EP0BUF[0] = Configuration;
 249   3                  EP0BCL = 1;
 250   3                  break;
 251   3               case SC_GET_STATUS:                 // *** Get Status
 252   3                     switch(setupdat0)
 253   3                     {
 254   4                        case GS_DEVICE:            // Device
 255   4                           EP0BUF[0] = 0x01;       // Bit 0 -- 1 = self-power, 0 = bus power
 256   4                           EP0BUF[1] = 0;          // Bit 1 -- remote wakeup enabled (0 for us)
 257   4                           EP0BCL = 2;
 258   4                           break;
 259   4                        case GS_INTERFACE:         // Interface
 260   4                           EP0BUF[0] = 0;
 261   4                           EP0BUF[1] = 0;
 262   4                           EP0BCL = 2;
 263   4                           break;
 264   4                        case GS_ENDPOINT:         // End Point
 265   4                           if (setupdat4 == 0x2)
 266   4                           {
 267   5                              EP0BUF[0] = (P_EP2CS & bmEPSTALL);
 268   5                           }
 269   4                           else if (setupdat4 == 0x84)
 270   4                           {
 271   5                              EP0BUF[0] = (P_EP4CS & bmEPSTALL);
 272   5                           }
 273   4                           else if (setupdat4 == 0x00)
 274   4                           {
 275   5                              EP0BUF[0] = 0x00;
 276   5                           }
 277   4                           else
 278   4                           {
 279   5                              EZUSB_STALL_EP0();   // Stall End Point 0
 280   5                              break;
 281   5                           }
 282   4         
 283   4                           EP0BUF[1] = 0;
 284   4                           EP0BCL = 2;
 285   4                           break;
 286   4                        default:                   // Invalid Command
 287   4                           EZUSB_STALL_EP0();      // Stall End Point 0
 288   4                     }
 289   3                  break;
 290   3               case SC_CLEAR_FEATURE:                  // *** Clear Feature
 291   3                     switch(setupdat0)
 292   3                     {
 293   4                        case FT_DEVICE:            // Device
 294   4                              EZUSB_STALL_EP0();   // Stall End Point 0
 295   4                           break;
 296   4                        case FT_ENDPOINT:          // End Point
 297   4                           if(setupdat2 == 0)
 298   4                           {
 299   5                              // do not clear endpoint STALLs if we received an invalid CBW.
 300   5                              // The BOT MSC Spec says we must stay STALL'd until we get reset
 301   5                              if (!phaseErrorState)
 302   5                              {
C51 COMPILER V7.50   FW                                                                    10/12/2007 17:05:42 PAGE 6   

 303   6                                 if (setupdat4 == 0x2)
 304   6                                 {
 305   7                                    ResetAndArmEp2();
 306   7                                    TOGCTL = 0x2;
 307   7                                    TOGCTL = 0x22;       // reset data toggle
 308   7                                    P_EP2CS = 0;         // Clear stall bit
 309   7                                 }
 310   6                                 else if (setupdat4 == 0x84)
 311   6                                 {
 312   7                                    TOGCTL = 0x14;
 313   7                                    TOGCTL = 0x34;       // reset data toggle
 314   7                                    P_EP4CS = 0;         // Clear stall bit
 315   7                                 }
 316   6                                 else if (setupdat4 == 0x0)
 317   6                                 {
 318   7                                       // EP0 STALLs are auto-clear
 319   7                                 }
 320   6                                 else
 321   6                                    EZUSB_STALL_EP0();   // Stall End Point 0
 322   6                              }
 323   5                           }
 324   4                           else
 325   4                              EZUSB_STALL_EP0();      // Stall End Point 0
 326   4                           break;
 327   4                        default:
 328   4                           EZUSB_STALL_EP0();      // Stall End Point 0
 329   4                     }  
 330   3                  break;
 331   3               case SC_SET_FEATURE:                  // *** Set Feature
 332   3                     switch(setupdat0)
 333   3                     {
 334   4                        case FT_DEVICE:            // Device
 335   4                           if(setupdat2 == 2)
 336   4                              // Set Feature Test Mode.  The core handles this request.  However, it is
 337   4                              // necessary for the firmware to complete the handshake phase of the
 338   4                              // control transfer before the chip will enter test mode.  It is also
 339   4                              // necessary for FX2 to be physically disconnected (D+ and D-)
 340   4                              // from the host before it will enter test mode.
 341   4                              break;
 342   4                           else
 343   4                              EZUSB_STALL_EP0();   // Stall End Point 0
 344   4                           break;
 345   4                        case FT_ENDPOINT:          // End Point
 346   4                           if(setupdat2 == 0)
 347   4                              {
 348   5                              if (setupdat4 == 0x2)
 349   5                                 P_EP2CS = bmEPSTALL;       // Set stall bit
 350   5                              else if (setupdat4 == 0x84)
 351   5                                 P_EP4CS = bmEPSTALL;       // Set stall bit
 352   5                              else
 353   5                                 EZUSB_STALL_EP0();   // Stall End Point 0
 354   5                              }
 355   4                           else
 356   4                              EZUSB_STALL_EP0();   // Stall End Point 0
 357   4                           break;
 358   4                        default:
 359   4                           EZUSB_STALL_EP0();      // Stall End Point 0
 360   4                     }  
 361   3                  break;
 362   3         
 363   3               default:                            // *** Invalid Command
 364   3                     EZUSB_STALL_EP0();            // Stall End Point 0
C51 COMPILER V7.50   FW                                                                    10/12/2007 17:05:42 PAGE 7   

 365   3               }
 366   2            }
 367   1         else if ((setupdat0 & SETUP_MASK) == SETUP_CLASS_REQUEST)
 368   1         {
 369   2            switch(SETUPDAT[1])
 370   2               {
 371   3               case SC_MASS_STORAGE_RESET:
 372   3                     // Verify that the command is actually a MS reset command sent to the proper interface
 373   3                     if (setupdat0 == 0x21 && setupdat4 == 0)  // Our interface number is hard coded (0) in DSCR
             -.A51
 374   3                     {
 375   4                        // All we really need to do in response to a MSC Reset is restart using
 376   4                        // a soft reset (jump to 0x00).  This will re-initialize the drive and
 377   4                        // endpoints.
 378   4                        EZUSB_IRQ_CLEAR();
 379   4                        INT2CLR = bmSUDAV;         // Clear SUDAV IRQ
 380   4            
 381   4                        // force a soft reset after the iret.
 382   4                        EA = 0;
 383   4                        softReset();
 384   4                     }
 385   3                     else
 386   3                        EZUSB_STALL_EP0();   // Stall End Point 0
 387   3                     break;
 388   3            
 389   3               case SC_GET_MAX_LUN:
 390   3                  if (setupdat0 == 0xa1 && setupdat4 == 0)  // Our interface number is hard coded (0) in DSCR.A5
             -1
 391   3                  {
 392   4      #ifdef USE_2LUN
                             EP0BUF[0] = 1;          // 2 LUNs
              #else
 395   4                     EP0BUF[0] = 0;
 396   4      #endif
 397   4                     EP0BCL = 1;
 398   4                  }
 399   3                  else
 400   3                     EZUSB_STALL_EP0();      // Stall End Point 0
 401   3                  break;
 402   3      
 403   3      #ifdef HID
                       case SC_HID_SET_IDLE: break;
              #endif
 406   3      
 407   3               default:                      // *** Invalid Command
 408   3                     EZUSB_STALL_EP0();      // Stall End Point 0
 409   3      
 410   3               } // End Switch
 411   2         } // end elseif
 412   1         else
 413   1             EZUSB_STALL_EP0();              // Stall End Point 0
 414   1      
 415   1         // Acknowledge handshake phase of device request
 416   1         EP0CS |= bmHSNAK;
 417   1      }
 418          
 419          //-----------------------------------------------------------------------------
 420          // Wake-up interrupt handler
 421          //-----------------------------------------------------------------------------
 422          void resume_isr(void) interrupt     WKUP_VECT
 423          {
 424   1         EZUSB_CLEAR_RSMIRQ();
C51 COMPILER V7.50   FW                                                                    10/12/2007 17:05:42 PAGE 8   

 425   1      }
 426          
 427          //-----------------------------------------------------------------------------
 428          // General Send Descriptor subroutine
 429          // Note: Transfer length is 64 max
 430          //-----------------------------------------------------------------------------
 431          void sendDescriptor(BYTE offset, BYTE len)
 432          {
 433   1         BYTE xdata j;
 434   1      
 435   1         AUTOPTR1H = MSB(halfKBuffer);
 436   1         AUTOPTR1L = offset;
 437   1         for(j=0;j<64;j++) EP0BUF[j]=P_XAUTODAT1;
 438   1         if (len==0) len = EP0BUF[0];
 439   1         if (!SETUPDAT[7])
 440   1            len = min(len, SETUPDAT[6]);
 441   1         EP0BCL = len;
 442   1      }
 443          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1279    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----       6
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -