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

📄 f3xx_usb0_reporthandler.lst

📁 基于344单片机的HID设备的USB鼠标代码
💻 LST
字号:
C51 COMPILER V8.05a   F3XX_USB0_REPORTHANDLER                                              10/16/2008 16:50:25 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE F3XX_USB0_REPORTHANDLER
OBJECT MODULE PLACED IN F3xx_USB0_ReportHandler.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\c51.exe F3xx_USB0_ReportHandler.c DB OE

line level    source

   1          //-----------------------------------------------------------------------------
   2          // USB0_ReportHandler.c
   3          //-----------------------------------------------------------------------------
   4          // Copyright 2005 Silicon Laboratories, Inc.
   5          // http://www.silabs.com
   6          //
   7          // Program Description:
   8          //
   9          // Contains functions and variables dealing with Input and Output
  10          // HID reports.
  11          //
  12          // How To Test:    See Readme.txt
  13          //
  14          //
  15          // FID:
  16          // Target:         C8051F340
  17          // Tool chain:     Keil C51 7.50 / Keil EVAL C51
  18          //                 Silicon Laboratories IDE version 2.6
  19          // Command Line:   See Readme.txt
  20          // Project Name:   F3xx_MouseExample
  21          //
  22          // Release 1.1
  23          //    -Minor code comment changes
  24          //    -16 NOV 2006
  25          // Release 1.0
  26          //    -Initial Revision (PD)
  27          //    -07 DEC 2005
  28          //
  29          
  30          
  31          // ----------------------------------------------------------------------------
  32          // Header files
  33          // ----------------------------------------------------------------------------
  34          
  35          #include "F3xx_USB0_ReportHandler.h"
  36          #include "F3xx_USB0_InterruptServiceRoutine.h"
  37          #include "F3xx_USB0_Mouse.h"
  38          
  39          
  40          // ----------------------------------------------------------------------------
  41          // Local Function Prototypes
  42          // ----------------------------------------------------------------------------
  43          
  44          // ****************************************************************************
  45          // Add custom Report Handler Prototypes Here
  46          // ****************************************************************************
  47          
  48          void IN_Report(void);
  49          void OUT_Report(void);
  50          
  51          // ----------------------------------------------------------------------------
  52          // Local Definitions
  53          // ----------------------------------------------------------------------------
  54          
  55          // ****************************************************************************
C51 COMPILER V8.05a   F3XX_USB0_REPORTHANDLER                                              10/16/2008 16:50:25 PAGE 2   

  56          // Set Definitions to sizes corresponding to the number of reports
  57          // ****************************************************************************
  58          
  59          #define IN_VECTORTABLESize 1
  60          #define OUT_VECTORTABLESize 1
  61          
  62          // ----------------------------------------------------------------------------
  63          // Global Constant Declaration
  64          // ----------------------------------------------------------------------------
  65          
  66          
  67          // ****************************************************************************
  68          // Link all Report Handler functions to corresponding Report IDs
  69          // ****************************************************************************
  70          
  71          const VectorTableEntry code IN_VECTORTABLE[IN_VECTORTABLESize] =
  72          {
  73             // FORMAT: Report ID, Report Handler
  74             0, IN_Report
  75          };
  76          
  77          // ****************************************************************************
  78          // Link all Report Handler functions to corresponding Report IDs
  79          // ****************************************************************************
  80          const VectorTableEntry code OUT_VECTORTABLE[OUT_VECTORTABLESize] =
  81          {
  82             // FORMAT: Report ID, Report Handler
  83             0, OUT_Report
  84          };
  85          
  86          
  87          // ----------------------------------------------------------------------------
  88          // Global Variable Declaration
  89          // ----------------------------------------------------------------------------
  90          
  91          BufferStructure IN_BUFFER, OUT_BUFFER;
  92          
  93          // ----------------------------------------------------------------------------
  94          // Local Functions
  95          // ----------------------------------------------------------------------------
  96          
  97          // ****************************************************************************
  98          // Add all Report Handler routines here
  99          // ****************************************************************************
 100          
 101          
 102          // ****************************************************************************
 103          // For Input Reports:
 104          // Point IN_BUFFER.Ptr to the buffer containing the report
 105          // Set IN_BUFFER.Length to the number of bytes that will be
 106          // transmitted.
 107          //
 108          // REMINDER:
 109          // Systems using more than one report must define Report IDs
 110          // for each report.  These Report IDs must be included as the first
 111          // byte of an IN report.
 112          // Systems with Report IDs should set the FIRST byte of their buffer
 113          // to the value for the Report ID
 114          // AND
 115          // must transmit Report Size + 1 to include the full report PLUS
 116          // the Report ID.
 117          //
C51 COMPILER V8.05a   F3XX_USB0_REPORTHANDLER                                              10/16/2008 16:50:25 PAGE 3   

 118          // ****************************************************************************
 119          
 120          
 121          void IN_Report(void){
 122   1      
 123   1         // save left mouse button stat to bit 0 of first data byte
 124   1         IN_PACKET[0] = MOUSE_BUTTON;
 125   1      
 126   1         // determine whether X-Axis or Y-Axis is active, then
 127   1         // set MOUSE_VECTOR to active axis
 128   1         if(MOUSE_AXIS == X_Axis) IN_PACKET[1] = MOUSE_VECTOR;
 129   1         else IN_PACKET[1] = 0;
 130   1      
 131   1         if(MOUSE_AXIS == Y_Axis) IN_PACKET[2] = MOUSE_VECTOR;
 132   1         else IN_PACKET[2] = 0;
 133   1      
 134   1         // point IN_BUFFER pointer to data packet and set
 135   1         // IN_BUFFER length to transmit correct report size
 136   1         IN_BUFFER.Ptr = IN_PACKET;
 137   1         IN_BUFFER.Length = 3;
 138   1      
 139   1      }
 140          
 141          
 142          // ****************************************************************************
 143          // For Output Reports:
 144          // Data contained in the buffer OUT_BUFFER.Ptr will not be
 145          // preserved after the Report Handler exits.
 146          // Any data that needs to be preserved should be copyed from
 147          // the OUT_BUFFER.Ptr and into other user-defined memory.
 148          //
 149          // ****************************************************************************
 150          
 151          void OUT_Report(void)
 152          {
 153   1      }
 154          
 155          // ----------------------------------------------------------------------------
 156          // Global Functions
 157          // ----------------------------------------------------------------------------
 158          
 159          // ****************************************************************************
 160          // Configure Setup_OUT_BUFFER
 161          //
 162          // Reminder:
 163          // This function should set OUT_BUFFER.Ptr so that it
 164          // points to an array in data space big enough to store
 165          // any output report.
 166          // It should also set OUT_BUFFER.Length to the size of
 167          // this buffer.
 168          //
 169          // ****************************************************************************
 170          
 171          void Setup_OUT_BUFFER(void)
 172          {
 173   1      }
 174          
 175          // ----------------------------------------------------------------------------
 176          // Vector Routines
 177          // ----------------------------------------------------------------------------
 178          
 179          // ----------------------------------------------------------------------------
C51 COMPILER V8.05a   F3XX_USB0_REPORTHANDLER                                              10/16/2008 16:50:25 PAGE 4   

 180          // ReportHandler_IN...
 181          // ----------------------------------------------------------------------------
 182          //
 183          // Return Value - None
 184          // Parameters - Report ID
 185          //
 186          // These functions match the Report ID passed as a parameter
 187          // to an Input Report Handler.
 188          // the ...FG function is called in the SendPacket foreground routine,
 189          // while the ...ISR function is called inside the USB ISR.  A lock
 190          // is set whenever one function is called to prevent a call from the
 191          // other from disrupting the routine.
 192          // However, this should never occur, as interrupts are disabled by SendPacket
 193          // before USB operation begins.
 194          // ----------------------------------------------------------------------------
 195          void ReportHandler_IN_ISR(unsigned char R_ID)
 196          {
 197   1         unsigned char index;
 198   1      
 199   1         index = 0;
 200   1      
 201   1         while(index <= IN_VECTORTABLESize)
 202   1         {
 203   2            // check to see if Report ID passed into function
 204   2                // matches the Report ID for this entry in the Vector Table
 205   2            if(IN_VECTORTABLE[index].ReportID == R_ID)
 206   2            {
 207   3               IN_VECTORTABLE[index].hdlr();
 208   3               break;
 209   3            }
 210   2      
 211   2            // if Report IDs didn't match, increment the index pointer
 212   2            index++;
 213   2         }
 214   1      
 215   1      }
 216          void ReportHandler_IN_Foreground(unsigned char R_ID)
 217          {
 218   1         unsigned char index;
 219   1      
 220   1         index = 0;
 221   1      
 222   1         while(index <= IN_VECTORTABLESize)
 223   1         {
 224   2            // check to see if Report ID passed into function
 225   2            // matches the Report ID for this entry in the Vector Table
 226   2            if(IN_VECTORTABLE[index].ReportID == R_ID)
 227   2            {
 228   3               IN_VECTORTABLE[index].hdlr();
 229   3               break;
 230   3            }
 231   2      
 232   2            // if Report IDs didn't match, increment the index pointer
 233   2            index++;
 234   2         }
 235   1      
 236   1      }
 237          
 238          // ----------------------------------------------------------------------------
 239          // ReportHandler_OUT
 240          // ----------------------------------------------------------------------------
 241          //
C51 COMPILER V8.05a   F3XX_USB0_REPORTHANDLER                                              10/16/2008 16:50:25 PAGE 5   

 242          // Return Value - None
 243          // Parameters - None
 244          //
 245          // This function matches the Report ID passed as a parameter
 246          // to an Output Report Handler.
 247          //
 248          // ----------------------------------------------------------------------------
 249          void ReportHandler_OUT(unsigned char R_ID){
 250   1      
 251   1         unsigned char index;
 252   1      
 253   1         index = 0;
 254   1      
 255   1         while(index <= OUT_VECTORTABLESize)
 256   1         {
 257   2            // check to see if Report ID passed into function
 258   2            // matches the Report ID for this entry in the Vector Table
 259   2            if(OUT_VECTORTABLE[index].ReportID == R_ID)
 260   2            {
 261   3               OUT_VECTORTABLE[index].hdlr();
 262   3               break;
 263   3            }
 264   2      
 265   2            // if Report IDs didn't match, increment the index pointer
 266   2            index++;
 267   2         }
 268   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    226    ----
   CONSTANT SIZE    =      8    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      8       6
   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 + -