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

📄 f34x_usb_standard_requests.lst

📁 This file for experiment of C8051 Microcontroller(SILABS company) with USB interface that use keil p
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V8.08   F34X_USB_STANDARD_REQUESTS                                            05/11/2009 10:06:15 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE F34X_USB_STANDARD_REQUESTS
OBJECT MODULE PLACED IN F34x_USB_Standard_Requests.OBJ
COMPILER INVOKED BY: C:\SiLabs\MCU\IDEfiles\C51\BIN\C51.exe F34x_USB_Standard_Requests.c DB OE

line level    source

   1          //-----------------------------------------------------------------------------
   2          // F34x_USB_Standard_Requests.c
   3          //-----------------------------------------------------------------------------
   4          // Copyright 2005 Silicon Laboratories, Inc.
   5          // http://www.silabs.com
   6          //
   7          // Program Description:
   8          //
   9          // This source file contains the subroutines used to handle incoming 
  10          // setup packets. These are called by Handle_Setup in USB_ISR.c and used for 
  11          // USB chapter 9 compliance.
  12          //
  13          
  14          // How To Test:    See Readme.txt
  15          //
  16          //
  17          // FID:            34X000022
  18          // Target:         C8051F34x
  19          // Tool chain:     Keil C51 7.50 / Keil EVAL C51
  20          //                 Silicon Laboratories IDE version 2.6
  21          // Command Line:   See Readme.txt
  22          // Project Name:   F34x_USB_Interrupt
  23          //
  24          //
  25          // Release 1.1
  26          //    -08 JAN 2008 (GP)
  27          //    -Set rbDATAEND for various requests
  28          //
  29          // Release 1.0
  30          //    -Initial Revision (GP)
  31          //    -22 NOV 2005
  32          //    -Ported from 'F320_USB_Bulk
  33          //
  34          
  35          //-----------------------------------------------------------------------------
  36          // Includes
  37          //-----------------------------------------------------------------------------
  38          
  39          #include "c8051F340.h"
  40          #include "F34x_USB_Register.h"
  41          #include "F34x_USB_Main.h"
  42          #include "F34x_USB_Descriptor.h"
  43          
  44          //-----------------------------------------------------------------------------
  45          // Externs
  46          //-----------------------------------------------------------------------------
  47          
  48          // These are created in USB_DESCRIPTOR.h
  49          
  50          extern device_descriptor DeviceDesc;            
  51          extern configuration_descriptor ConfigDesc;
  52          extern interface_descriptor InterfaceDesc;
  53          extern endpoint_descriptor Endpoint1Desc;
  54          extern endpoint_descriptor Endpoint2Desc;
  55          extern BYTE* StringDescTable[];
C51 COMPILER V8.08   F34X_USB_STANDARD_REQUESTS                                            05/11/2009 10:06:15 PAGE 2   

  56          
  57          extern setup_buffer Setup;             // Buffer for current device request
  58          extern unsigned int DataSize;
  59          extern unsigned int DataSent;
  60          extern BYTE* DataPtr;
  61          
  62          extern BYTE Ep_Status[];               // Contains status bytes for EP 0-2
  63          
  64          extern BYTE USB_State;                 // Determines current usb device state
  65          
  66          //-----------------------------------------------------------------------------
  67          // Global Variables
  68          //-----------------------------------------------------------------------------
  69          
  70          // These are response packets used for communication with host
  71          code BYTE ONES_PACKET[2] = {0x01, 0x00};        
  72          code BYTE ZERO_PACKET[2] = {0x00, 0x00};        
  73          
  74          //-----------------------------------------------------------------------------
  75          // Support Subroutines
  76          //-----------------------------------------------------------------------------
  77          
  78          //-----------------------------------------------------------------------------
  79          // Get_Status
  80          //-----------------------------------------------------------------------------
  81          //
  82          // Return Value : None
  83          // Parameters   : None
  84          //
  85          // This routine returns a two byte status packet to the host
  86          //
  87          //-----------------------------------------------------------------------------
  88          
  89          void Get_Status(void)                  
  90          {                                      
  91   1      
  92   1         if (Setup.wValue.c[MSB] || Setup.wValue.c[LSB] ||
  93   1                                                      
  94   1         // If non-zero return length or data length not  equal to 2 then send a stall
  95   1         // indicating invalid request
  96   1         Setup.wLength.c[MSB]    || (Setup.wLength.c[LSB] != 2))                                               
  97   1         {                                            
  98   2            Force_Stall();
  99   2         }
 100   1      
 101   1         // Determine if recipient was device, interface, or EP
 102   1         switch(Setup.bmRequestType)                  
 103   1         {
 104   2            // If recipient was device
 105   2            case OUT_DEVICE:                          
 106   2               if (Setup.wIndex.c[MSB] || Setup.wIndex.c[LSB])
 107   2               {
 108   3                          // Send stall if request is invalid
 109   3                  Force_Stall();             
 110   3               }
 111   2               else
 112   2               {
 113   3                          // Otherwise send 0x00, indicating bus power and no
 114   3                              // remote wake-up supported
 115   3                  DataPtr = (BYTE*)&ZERO_PACKET;      
 116   3                  DataSize = 2;                       
 117   3               }
C51 COMPILER V8.08   F34X_USB_STANDARD_REQUESTS                                            05/11/2009 10:06:15 PAGE 3   

 118   2               break;
 119   2      
 120   2            // See if recipient was interface
 121   2            case OUT_INTERFACE:                       
 122   2                   // Only valid if device is configured and non-zero index
 123   2               if ((USB_State != DEV_CONFIGURED) ||
 124   2                    Setup.wIndex.c[MSB] || Setup.wIndex.c[LSB])                                                
 125   2               {
 126   3                          // Otherwise send stall to host
 127   3                  Force_Stall();                      
 128   3               }
 129   2               else
 130   2               {
 131   3                          // Status packet always returns 0x00
 132   3                  DataPtr = (BYTE*)&ZERO_PACKET;      
 133   3                  DataSize = 2;
 134   3               }
 135   2               break;
 136   2      
 137   2            // See if recipient was an endpoint
 138   2            case OUT_ENDPOINT:                        
 139   2                   // Make sure device is configured and index msb = 0x00
 140   2               if ((USB_State != DEV_CONFIGURED) || Setup.wIndex.c[MSB])                   
 141   2               {                                     
 142   3                  Force_Stall();              // otherwise return stall to host
 143   3               }
 144   2               else
 145   2               {
 146   3                  // Handle case if request is directed to EP 1
 147   3                  if (Setup.wIndex.c[LSB] == IN_EP1)  
 148   3                  {
 149   4                     if (Ep_Status[1] == EP_HALT)
 150   4                     {                                
 151   5                                    // If endpoint is halted, return 0x01,0x00
 152   5                        DataPtr = (BYTE*)&ONES_PACKET;
 153   5                        DataSize = 2;
 154   5                     }
 155   4                     else
 156   4                     {
 157   5                                    // Otherwise return 0x00,0x00 to indicate endpoint active
 158   5                        DataPtr = (BYTE*)&ZERO_PACKET;
 159   5                        DataSize = 2;
 160   5                     }
 161   4                  }
 162   3                  else
 163   3                  {
 164   4                                 // If request is directed to endpoint 2, send either
 165   4                                 // 0x01,0x00 if endpoint halted or 0x00,0x00 if endpoint is active
 166   4                     if (Setup.wIndex.c[LSB] == OUT_EP2)
 167   4                                                      
 168   4                     {                                
 169   5                        if (Ep_Status[2] == EP_HALT)
 170   5                        {
 171   6                           DataPtr = (BYTE*)&ONES_PACKET;
 172   6                           DataSize = 2;
 173   6                        }
 174   5                        else
 175   5                        {
 176   6                           DataPtr = (BYTE*)&ZERO_PACKET;
 177   6                           DataSize = 2;
 178   6                        }
 179   5                     }
C51 COMPILER V8.08   F34X_USB_STANDARD_REQUESTS                                            05/11/2009 10:06:15 PAGE 4   

 180   4                     else
 181   4                     {
 182   5                        Force_Stall();       // Send stall if unexpected data
 183   5                     }
 184   4                  }
 185   3               }
 186   2               break;
 187   2      
 188   2            default:
 189   2               Force_Stall();
 190   2               break;
 191   2         }
 192   1         if (Ep_Status[0] != EP_STALL)
 193   1         {
 194   2            // Set serviced Setup Packet, Endpoint 0 intransmit mode, 
 195   2                // and reset DataSent counter
 196   2            POLL_WRITE_BYTE(E0CSR, rbSOPRDY);        
 197   2            Ep_Status[0] = EP_TX;                     
 198   2            DataSent = 0;
 199   2         }

⌨️ 快捷键说明

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