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

📄 f34x_usb_standard_requests.lst

📁 This file for experiment of C8051 Microcontroller(SILABS company) with USB interface that use keil p
💻 LST
📖 第 1 页 / 共 3 页
字号:
 408   3                  Force_Stall();
 409   3               }
 410   2               break;
 411   2      
 412   2            default:
 413   2               Force_Stall();                         // Send Stall if unsupported request
 414   2               break;
 415   2         }
 416   1      
 417   1         if (Setup.wValue.c[MSB] == DSC_DEVICE ||     // Verify that the requested descriptor is
 418   1         Setup.wValue.c[MSB] == DSC_CONFIG     ||     // valid
 419   1         Setup.wValue.c[MSB] == DSC_STRING     ||
 420   1         Setup.wValue.c[MSB] == DSC_INTERFACE  ||
 421   1         Setup.wValue.c[MSB] == DSC_ENDPOINT)
 422   1         {
 423   2            if ((Setup.wLength.c[LSB] < DataSize) &&
 424   2            (Setup.wLength.c[MSB] == 0))
 425   2            {
 426   3               DataSize = Setup.wLength.i;       // Send only requested amount of data
 427   3            }
C51 COMPILER V8.08   F34X_USB_STANDARD_REQUESTS                                            05/11/2009 10:06:15 PAGE 8   

 428   2         }
 429   1         if (Ep_Status[0] != EP_STALL)                // Make sure endpoint not in stall mode
 430   1         {
 431   2           POLL_WRITE_BYTE(E0CSR, rbSOPRDY);          // Service Setup Packet
 432   2           Ep_Status[0] = EP_TX;                      // Put endpoint in transmit mode
 433   2           DataSent = 0;                              // Reset Data Sent counter
 434   2         }
 435   1      }
 436          
 437          //-----------------------------------------------------------------------------
 438          // Get_Configuration
 439          //-----------------------------------------------------------------------------
 440          //
 441          // Return Value : None
 442          // Parameters   : None
 443          //
 444          // This routine returns current configuration value
 445          //
 446          //-----------------------------------------------------------------------------
 447          
 448          void Get_Configuration(void)                   
 449          {
 450   1         if ((Setup.bmRequestType != OUT_DEVICE)    ||// This request must be directed to the device
 451   1         Setup.wValue.c[MSB]  || Setup.wValue.c[LSB]||// with value word set to zero
 452   1         Setup.wIndex.c[MSB]  || Setup.wIndex.c[LSB]||// and index set to zero
 453   1         Setup.wLength.c[MSB] || (Setup.wLength.c[LSB] != 1))// and setup length set to one
 454   1         {
 455   2            Force_Stall();                            // Otherwise send a stall to host
 456   2         }
 457   1      
 458   1         else
 459   1         {
 460   2            if (USB_State == DEV_CONFIGURED)          // If the device is configured, then return value 0x01
 461   2            {                                         // since this software only supports one configuration
 462   3               DataPtr = (BYTE*)&ONES_PACKET;
 463   3               DataSize = 1;
 464   3            }
 465   2            if (USB_State == DEV_ADDRESS)             // If the device is in address state, it is not
 466   2            {                                         // configured, so return 0x00
 467   3               DataPtr = (BYTE*)&ZERO_PACKET;
 468   3               DataSize = 1;
 469   3            }
 470   2         }
 471   1         if (Ep_Status[0] != EP_STALL)
 472   1         {
 473   2            POLL_WRITE_BYTE(E0CSR, rbSOPRDY);         // Set Serviced Out Packet bit
 474   2            Ep_Status[0] = EP_TX;                     // Put endpoint into transmit mode
 475   2            DataSent = 0;                             // Reset Data Sent counter to zero
 476   2         }
 477   1      }
 478          
 479          //-----------------------------------------------------------------------------
 480          // Set_Configuration
 481          //-----------------------------------------------------------------------------
 482          //
 483          // Return Value : None
 484          // Parameters   : None
 485          //
 486          // This routine allows host to change current device configuration value
 487          //
 488          //-----------------------------------------------------------------------------
 489          
C51 COMPILER V8.08   F34X_USB_STANDARD_REQUESTS                                            05/11/2009 10:06:15 PAGE 9   

 490          void Set_Configuration(void)                   
 491          {                                               
 492   1      
 493   1         if ((USB_State == DEV_DEFAULT)             ||// Device must be addressed before configured
 494   1         (Setup.bmRequestType != IN_DEVICE)         ||// and request recipient must be the device
 495   1         Setup.wIndex.c[MSB]  || Setup.wIndex.c[LSB]||// the index and length words must be zero
 496   1         Setup.wLength.c[MSB] || Setup.wLength.c[LSB] ||
 497   1         Setup.wValue.c[MSB]  || (Setup.wValue.c[LSB] > 1))// This software only supports config = 0,1
 498   1         {
 499   2            Force_Stall();                            // Send stall if setup data is invalid
 500   2         }
 501   1      
 502   1         else
 503   1         {
 504   2            if (Setup.wValue.c[LSB] > 0)              // Any positive configuration request
 505   2            {                                         // results in configuration being set to 1
 506   3               USB_State = DEV_CONFIGURED;
 507   3               Ep_Status[1] = EP_IDLE;                // Set endpoint status to idle (enabled)
 508   3               Ep_Status[2] = EP_IDLE;
 509   3               POLL_WRITE_BYTE(INDEX, 1);             // Change index to endpoint 1
 510   3               POLL_WRITE_BYTE(EINCSR2, rbInDIRSEL);  // Set DIRSEL to indicate endpoint 1 is IN
 511   3               Handle_In1();                          // Put first data packet on fifo
 512   3               POLL_WRITE_BYTE(INDEX, 0);             // Set index back to endpoint 0
 513   3            }
 514   2            else
 515   2            {
 516   3               USB_State = DEV_ADDRESS;               // Unconfigures device by setting state to
 517   3               Ep_Status[1] = EP_HALT;                // address, and changing endpoint 1 and 2
 518   3               Ep_Status[2] = EP_HALT;                // status to halt
 519   3            }
 520   2         }
 521   1         if (Ep_Status[0] != EP_STALL)
 522   1         {
 523   2            // Indicate setup packet has been serviced
 524   2            POLL_WRITE_BYTE(E0CSR, (rbSOPRDY | rbDATAEND));
 525   2         }
 526   1      }
 527          
 528          //-----------------------------------------------------------------------------
 529          // Get_Interface
 530          //-----------------------------------------------------------------------------
 531          //
 532          // Return Value : None
 533          // Parameters   : None
 534          //
 535          // This routine returns 0x00, since only one interface is supported by 
 536          // this firmware
 537          //
 538          //-----------------------------------------------------------------------------
 539          
 540          void Get_Interface(void)                        
 541          {                                              
 542   1      
 543   1         if ((USB_State != DEV_CONFIGURED)      ||    // If device is not configured
 544   1         (Setup.bmRequestType != OUT_INTERFACE) ||    // or recipient is not an interface
 545   1         Setup.wValue.c[MSB]  ||Setup.wValue.c[LSB] ||// or non-zero value or index fields
 546   1         Setup.wIndex.c[MSB]  ||Setup.wIndex.c[LSB] ||// or data length not equal to one
 547   1         Setup.wLength.c[MSB] ||(Setup.wLength.c[LSB] != 1))
 548   1         {
 549   2            Force_Stall();                            // Then return stall due to invalid request
 550   2         }
 551   1      
C51 COMPILER V8.08   F34X_USB_STANDARD_REQUESTS                                            05/11/2009 10:06:15 PAGE 10  

 552   1         else
 553   1         {
 554   2            DataPtr = (BYTE*)&ZERO_PACKET;            // Otherwise, return 0x00 to host
 555   2            DataSize = 1;
 556   2         }
 557   1         if (Ep_Status[0] != EP_STALL)
 558   1         {
 559   2            POLL_WRITE_BYTE(E0CSR, rbSOPRDY);         // Set Serviced Setup packet, put endpoint in transmit
 560   2            Ep_Status[0] = EP_TX;                     // mode and reset Data sent counter
 561   2            DataSent = 0;
 562   2         }
 563   1      }
 564          
 565          //-----------------------------------------------------------------------------
 566          // Set_Interface
 567          //-----------------------------------------------------------------------------
 568          //
 569          // Return Value : None
 570          // Parameters   : None
 571          //
 572          // This routine allows host to change current device configuration value
 573          //
 574          //-----------------------------------------------------------------------------
 575          
 576          void Set_Interface(void)
 577          {
 578   1         // Make sure request is directed at interface and all other packet values 
 579   1         // are set to zero
 580   1      
 581   1         if ((Setup.bmRequestType != IN_INTERFACE)  ||
 582   1         Setup.wLength.c[MSB] ||Setup.wLength.c[LSB]|| 
 583   1         Setup.wValue.c[MSB]  ||Setup.wValue.c[LSB] ||
 584   1         Setup.wIndex.c[MSB]  ||Setup.wIndex.c[LSB])
 585   1         {
 586   2            // Otherwise send a stall to host
 587   2            Force_Stall();                            
 588   2         }
 589   1         if (Ep_Status[0] != EP_STALL)
 590   1         {
 591   2            // Indicate setup packet has been serviced
 592   2            POLL_WRITE_BYTE(E0CSR, (rbSOPRDY | rbDATAEND));                                               
 593   2         }
 594   1      }
 595          
 596          //-----------------------------------------------------------------------------
 597          // End Of File
 598          //-----------------------------------------------------------------------------


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