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

📄 f3xx_usb0_reporthandler.lst

📁 hid to rs232 usb_hid 转 串口程序
💻 LST
📖 第 1 页 / 共 2 页
字号:
 179          //
C51 COMPILER V8.17   F3XX_USB0_REPORTHANDLER                                               03/18/2009 09:55:18 PAGE 4   

 180          // ****************************************************************************
 181          
 182          void OUT_Control (void)
 183          {
 184   1      #ifndef BAUDRATE_HARDCODED
 185   1         ULONG baudrate;
 186   1      
 187   1         baudrate.C[0] = OUT_PACKET[1];
 188   1         baudrate.C[1] = OUT_PACKET[2];
 189   1         baudrate.C[2] = OUT_PACKET[3];
 190   1         baudrate.C[3] = OUT_PACKET[4];
 191   1         BaudRate = baudrate.L;
 192   1         UART0_Init ();
 193   1      #endif
 194   1      }
 195          void OUT_Data (void)
 196          {
 197   1         unsigned char size,index;
 198   1         unsigned char xdata* ptr = OUT_PACKET;
 199   1      
 200   1         size = OUT_PACKET[1];               // First byte of report shows
 201   1                                             // number of valid bytes
 202   1                                             // contained in report
 203   1      
 204   1         // Use a local pointer to write to OUT_PACKET quickly
 205   1         ptr++;
 206   1         ptr++;
 207   1      
 208   1      
 209   1          //  EA = 0;
 210   1         for(index = 0; index < size; index++)
 211   1         {
 212   2            // Enter critical section
 213   2            EA = 0;
 214   2            // Move pointer and wrap if necessary
 215   2            UART_OUTPUT_FIRST++;
 216   2            UART_OUTPUT_FIRST &= ~0x80;
 217   2            // Save received byte onto UART buffer
 218   2            UART_OUTPUT[UART_OUTPUT_FIRST] = *ptr;
 219   2            ptr++;
 220   2      
 221   2            UART_OUTPUT_SIZE++;
 222   2            if (UART_OUTPUT_SIZE > 127)
 223   2            {
 224   3               while(1);
 225   3            }
 226   2            // Exit critical section
 227   2            EA = 1;
 228   2            
 229   2      
 230   2         }
 231   1      }
 232          
 233          // ----------------------------------------------------------------------------
 234          // Global Functions
 235          // ----------------------------------------------------------------------------
 236          
 237          // ****************************************************************************
 238          // Configure Setup_OUT_BUFFER
 239          //
 240          // Reminder:
 241          // This function should set OUT_BUFFER.Ptr so that it
C51 COMPILER V8.17   F3XX_USB0_REPORTHANDLER                                               03/18/2009 09:55:18 PAGE 5   

 242          // points to an array in data space big enough to store
 243          // any output report.
 244          // It should also set OUT_BUFFER.Length to the size of
 245          // this buffer.
 246          //
 247          // ****************************************************************************
 248          
 249          void Setup_OUT_BUFFER(void)
 250          {
 251   1         OUT_BUFFER.Ptr = OUT_PACKET;
 252   1         OUT_BUFFER.Length = 63;
 253   1      }
 254          
 255          // ----------------------------------------------------------------------------
 256          // Vector Routines
 257          // ----------------------------------------------------------------------------
 258          
 259          // ----------------------------------------------------------------------------
 260          // ReportHandler_IN...
 261          // ----------------------------------------------------------------------------
 262          //
 263          // Return Value - None
 264          // Parameters - Report ID
 265          //
 266          // These functions match the Report ID passed as a parameter
 267          // to an Input Report Handler.
 268          // the ...FG function is called in the SendPacket foreground routine,
 269          // while the ...ISR function is called inside the USB ISR.  A lock
 270          // is set whenever one function is called to prevent a call from the
 271          // other from disrupting the routine.
 272          // However, this should never occur, as interrupts are disabled by SendPacket
 273          // before USB operation begins.
 274          // ----------------------------------------------------------------------------
 275          void ReportHandler_IN_ISR(unsigned char R_ID)
 276          {
 277   1         unsigned char index;
 278   1      
 279   1         index = 0;
 280   1      
 281   1         while(index <= IN_VECTORTABLESize)
 282   1         {
 283   2            // Check to see if Report ID passed into function
 284   2                // matches the Report ID for this entry in the Vector Table
 285   2            if(IN_VECTORTABLE[index].ReportID == R_ID)
 286   2            {
 287   3               IN_VECTORTABLE[index].hdlr();
 288   3               break;
 289   3            }
 290   2      
 291   2            // If Report IDs didn't match, increment the index pointer
 292   2            index++;
 293   2         }
 294   1      
 295   1      }
 296          void ReportHandler_IN_Foreground(unsigned char R_ID)
 297          {
 298   1         unsigned char index;
 299   1      
 300   1         index = 0;
 301   1      
 302   1         while(index <= IN_VECTORTABLESize)
 303   1         {
C51 COMPILER V8.17   F3XX_USB0_REPORTHANDLER                                               03/18/2009 09:55:18 PAGE 6   

 304   2            // Check to see if Report ID passed into function
 305   2            // matches the Report ID for this entry in the Vector Table
 306   2            if(IN_VECTORTABLE[index].ReportID == R_ID)
 307   2            {
 308   3               IN_VECTORTABLE[index].hdlr();
 309   3               break;
 310   3            }
 311   2      
 312   2            // If Report IDs didn't match, increment the index pointer
 313   2            index++;
 314   2         }
 315   1      
 316   1      }
 317          
 318          // ----------------------------------------------------------------------------
 319          // ReportHandler_OUT
 320          // ----------------------------------------------------------------------------
 321          //
 322          // Return Value - None
 323          // Parameters - None
 324          //
 325          // This function matches the Report ID passed as a parameter
 326          // to an Output Report Handler.
 327          //
 328          // ----------------------------------------------------------------------------
 329          void ReportHandler_OUT(unsigned char R_ID){
 330   1      
 331   1         unsigned char index;
 332   1      
 333   1         index = 0;
 334   1      
 335   1         while(index <= OUT_VECTORTABLESize)
 336   1         {
 337   2            // Check to see if Report ID passed into function
 338   2            // matches the Report ID for this entry in the Vector Table
 339   2            if(OUT_VECTORTABLE[index].ReportID == R_ID)
 340   2            {
 341   3               OUT_VECTORTABLE[index].hdlr();
 342   3               break;
 343   3            }
 344   2      
 345   2            // If Report IDs didn't match, increment the index pointer
 346   2            index++;
 347   2         }
 348   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    379    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     24      14
   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 + -