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

📄 usb_std_req.lst

📁 针对TMS320C6000系列的DSP芯片的在线升级的源码
💻 LST
📖 第 1 页 / 共 2 页
字号:
 224   2            POLL_WRITE_BYTE(E0CSR, (rbSOPRDY | rbDATAEND)); 
 225   2                                                      // Indicate setup packet has been serviced
 226   2         }
 227   1      }
 228          
 229          void Set_Address(void)                          // Set new function address
 230          {  
 231   1         if ((Setup.bmRequestType != IN_DEVICE)     ||// Request must be directed to device
 232   1         Setup.wIndex.c[MSB]  || Setup.wIndex.c[LSB]||// with index and length set to zero.
 233   1         Setup.wLength.c[MSB] || Setup.wLength.c[LSB]|| 
 234   1         Setup.wValue.c[MSB]  || (Setup.wValue.c[LSB] & 0x80))
 235   1         {
 236   2           Force_Stall();                             // Send stall if setup data invalid
 237   2         }
 238   1      
 239   1         Ep_Status[0] = EP_ADDRESS;                   // Set endpoint zero to update address next status phase
 240   1         if (Setup.wValue.c[LSB] != 0) 
C51 COMPILER V6.12  USB_STD_REQ                                                            06/09/2004 15:44:26 PAGE 5   

 241   1         {
 242   2            USB_State = DEV_ADDRESS;                  // Indicate that device state is now address
 243   2         }
 244   1         else 
 245   1         {
 246   2            USB_State = DEV_DEFAULT;                  // If new address was 0x00, return device to default
 247   2         }                                            // state
 248   1         if (Ep_Status[0] != EP_STALL)
 249   1         {    
 250   2            POLL_WRITE_BYTE(E0CSR, (rbSOPRDY | rbDATAEND)); 
 251   2                                                      // Indicate setup packet has been serviced
 252   2         }
 253   1      }
 254          
 255          void Get_Descriptor(void)                       // This routine sets the data pointer and size to correct
 256          {                                               // descriptor and sets the endpoint status to transmit
 257   1      
 258   1         switch(Setup.wValue.c[MSB])                  // Determine which type of descriptor
 259   1         {                                            // was requested, and set data ptr and 
 260   2            case DSC_DEVICE:                          // size accordingly
 261   2               DataPtr = (BYTE*) &DeviceDesc;
 262   2               DataSize = DeviceDesc.bLength;
 263   2               break;
 264   2            
 265   2            case DSC_CONFIG:
 266   2               DataPtr = (BYTE*) &ConfigDesc;
 267   2                                                      // Compiler Specific - The next statement reverses the
 268   2                                                      // bytes in the configuration descriptor for the compiler
 269   2               DataSize = ConfigDesc.wTotalLength.c[MSB] + 256*ConfigDesc.wTotalLength.c[LSB];
 270   2               break;
 271   2            
 272   2      	  case DSC_STRING:
 273   2               DataPtr = StringDescTable[Setup.wValue.c[LSB]];
 274   2      		                                        // Can have a maximum of 255 strings
 275   2               DataSize = *DataPtr;
 276   2               break;
 277   2            
 278   2            case DSC_INTERFACE:
 279   2               DataPtr = (BYTE*) &InterfaceDesc;
 280   2               DataSize = InterfaceDesc.bLength;
 281   2               break;
 282   2            
 283   2            case DSC_ENDPOINT:
 284   2               if ((Setup.wValue.c[LSB] == IN_EP1) || 
 285   2               (Setup.wValue.c[LSB] == OUT_EP2))
 286   2               {
 287   3                  if (Setup.wValue.c[LSB] == IN_EP1)
 288   3                  {
 289   4                     DataPtr = (BYTE*) &Endpoint1Desc;
 290   4                     DataSize = Endpoint1Desc.bLength;
 291   4                  }
 292   3                  else
 293   3                  {
 294   4                     DataPtr = (BYTE*) &Endpoint2Desc;
 295   4                     DataSize = Endpoint2Desc.bLength;
 296   4                  }
 297   3               }
 298   2               else
 299   2               {
 300   3                  Force_Stall();
 301   3               }
 302   2               break;
C51 COMPILER V6.12  USB_STD_REQ                                                            06/09/2004 15:44:26 PAGE 6   

 303   2            
 304   2            default:
 305   2               Force_Stall();                         // Send Stall if unsupported request
 306   2               break;
 307   2         }
 308   1         
 309   1         if (Setup.wValue.c[MSB] == DSC_DEVICE ||     // Verify that the requested descriptor is 
 310   1         Setup.wValue.c[MSB] == DSC_CONFIG     ||     // valid
 311   1         Setup.wValue.c[MSB] == DSC_STRING     ||
 312   1         Setup.wValue.c[MSB] == DSC_INTERFACE  ||
 313   1         Setup.wValue.c[MSB] == DSC_ENDPOINT)
 314   1         {
 315   2            if ((Setup.wLength.c[LSB] < DataSize) && 
 316   2            (Setup.wLength.c[MSB] == 0))
 317   2            {
 318   3               DataSize = Setup.wLength.i;       // Send only requested amount of data
 319   3            }
 320   2         }
 321   1         if (Ep_Status[0] != EP_STALL)                // Make sure endpoint not in stall mode
 322   1         {
 323   2           POLL_WRITE_BYTE(E0CSR, rbSOPRDY);          // Service Setup Packet
 324   2           Ep_Status[0] = EP_TX;                      // Put endpoint in transmit mode
 325   2           DataSent = 0;                              // Reset Data Sent counter
 326   2         }
 327   1      }
 328          
 329          
 330          void Get_Configuration(void)                    // This routine returns current configuration value
 331          {
 332   1         if ((Setup.bmRequestType != OUT_DEVICE)    ||// This request must be directed to the device
 333   1         Setup.wValue.c[MSB]  || Setup.wValue.c[LSB]||// with value word set to zero
 334   1         Setup.wIndex.c[MSB]  || Setup.wIndex.c[LSB]||// and index set to zero
 335   1         Setup.wLength.c[MSB] || (Setup.wLength.c[LSB] != 1))// and setup length set to one
 336   1         {
 337   2            Force_Stall();                            // Otherwise send a stall to host
 338   2         }
 339   1      
 340   1         else 
 341   1         {
 342   2            if (USB_State == DEV_CONFIGURED)          // If the device is configured, then return value 0x01
 343   2            {                                         // since this software only supports one configuration
 344   3               DataPtr = (BYTE*)&ONES_PACKET;
 345   3               DataSize = 1;
 346   3            }
 347   2            if (USB_State == DEV_ADDRESS)             // If the device is in address state, it is not
 348   2            {                                         // configured, so return 0x00
 349   3               DataPtr = (BYTE*)&ZERO_PACKET;
 350   3               DataSize = 1;
 351   3            }
 352   2         }
 353   1         if (Ep_Status[0] != EP_STALL)
 354   1         {
 355   2            POLL_WRITE_BYTE(E0CSR, rbSOPRDY);         // Set Serviced Out Packet bit
 356   2            Ep_Status[0] = EP_TX;                     // Put endpoint into transmit mode
 357   2            DataSent = 0;                             // Reset Data Sent counter to zero
 358   2         }
 359   1      }
 360          
 361          void Set_Configuration(void)                    // This routine allows host to change current
 362          {                                               // device configuration value
 363   1      
 364   1         if ((USB_State == DEV_DEFAULT)             ||// Device must be addressed before configured
C51 COMPILER V6.12  USB_STD_REQ                                                            06/09/2004 15:44:26 PAGE 7   

 365   1         (Setup.bmRequestType != IN_DEVICE)         ||// and request recipient must be the device
 366   1         Setup.wIndex.c[MSB]  || Setup.wIndex.c[LSB]||// the index and length words must be zero
 367   1         Setup.wLength.c[MSB] || Setup.wLength.c[LSB] || 
 368   1         Setup.wValue.c[MSB]  || (Setup.wValue.c[LSB] > 1))// This software only supports config = 0,1
 369   1         {
 370   2            Force_Stall();                            // Send stall if setup data is invalid
 371   2         }
 372   1      
 373   1         else
 374   1         {
 375   2            if (Setup.wValue.c[LSB] > 0)              // Any positive configuration request
 376   2            {                                         // results in configuration being set to 1
 377   3               USB_State = DEV_CONFIGURED;
 378   3               Ep_Status[1] = EP_IDLE;                // Set endpoint status to idle (enabled)
 379   3               Ep_Status[2] = EP_IDLE;
 380   3               POLL_WRITE_BYTE(INDEX, 1);             // Change index to endpoint 1
 381   3               POLL_WRITE_BYTE(EINCSR2, rbInDIRSEL);  // Set DIRSEL to indicate endpoint 1 is IN
 382   3               Handle_In1();                          // Put first data packet on fifo
 383   3               POLL_WRITE_BYTE(INDEX, 0);             // Set index back to endpoint 0
 384   3            }
 385   2            else
 386   2            {
 387   3               USB_State = DEV_ADDRESS;               // Unconfigures device by setting state to 
 388   3               Ep_Status[1] = EP_HALT;                // address, and changing endpoint 1 and 2 
 389   3               Ep_Status[2] = EP_HALT;                // status to halt
 390   3            }
 391   2         }     
 392   1         if (Ep_Status[0] != EP_STALL)
 393   1         {
 394   2            POLL_WRITE_BYTE(E0CSR, (rbSOPRDY | rbDATAEND)); 
 395   2                                                      // Indicate setup packet has been serviced
 396   2         }
 397   1      }
 398          
 399          void Get_Interface(void)                        // This routine returns 0x00, since only one interface
 400          {                                               // is supported by this firmware
 401   1      
 402   1         if ((USB_State != DEV_CONFIGURED)      ||    // If device is not configured
 403   1         (Setup.bmRequestType != OUT_INTERFACE) ||    // or recipient is not an interface
 404   1         Setup.wValue.c[MSB]  ||Setup.wValue.c[LSB] ||// or non-zero value or index fields
 405   1         Setup.wIndex.c[MSB]  ||Setup.wIndex.c[LSB] ||// or data length not equal to one
 406   1         Setup.wLength.c[MSB] ||(Setup.wLength.c[LSB] != 1))    
 407   1         {
 408   2            Force_Stall();                            // Then return stall due to invalid request
 409   2         }
 410   1      
 411   1         else
 412   1         {
 413   2            DataPtr = (BYTE*)&ZERO_PACKET;            // Otherwise, return 0x00 to host
 414   2            DataSize = 1;
 415   2         }
 416   1         if (Ep_Status[0] != EP_STALL)
 417   1         {                       
 418   2            POLL_WRITE_BYTE(E0CSR, rbSOPRDY);         // Set Serviced Setup packet, put endpoint in transmit
 419   2            Ep_Status[0] = EP_TX;                     // mode and reset Data sent counter
 420   2            DataSent = 0;
 421   2         }
 422   1      }
 423          
 424          void Set_Interface(void)
 425          {
 426   1         if ((Setup.bmRequestType != IN_INTERFACE)  ||// Make sure request is directed at interface
C51 COMPILER V6.12  USB_STD_REQ                                                            06/09/2004 15:44:26 PAGE 8   

 427   1         Setup.wLength.c[MSB] ||Setup.wLength.c[LSB]||// and all other packet values are set to zero
 428   1         Setup.wValue.c[MSB]  ||Setup.wValue.c[LSB] || 
 429   1         Setup.wIndex.c[MSB]  ||Setup.wIndex.c[LSB])
 430   1         {
 431   2            Force_Stall();                            // Othewise send a stall to host
 432   2         }
 433   1         if (Ep_Status[0] != EP_STALL)
 434   1         {
 435   2            POLL_WRITE_BYTE(E0CSR, (rbSOPRDY | rbDATAEND)); 
 436   2                                                      // Indicate setup packet has been serviced
 437   2         }
 438   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   1229    ----
   CONSTANT SIZE    =      4    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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