i wanna USB HID mikroC Open source code

Discussion in 'Embedded Systems and Microcontrollers' started by buffon2009, Feb 19, 2012.

  1. buffon2009

    Thread Starter New Member

    Dec 7, 2011
    28
    0
    hi guys

    hi everyone,


    i wanna a USB HID Open source library for mikroC for PIC in order to use it in my project as i use PIC18f4550 with built-in usb module

    i don't want to use the default library with mikroC because i wanna more customization one.

    Thanks in Advance,
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    You have our full permission to write your own custom USB library.
     
  3. buffon2009

    Thread Starter New Member

    Dec 7, 2011
    28
    0
    i use this code
    this is the main.c file

    Code ( (Unknown Language)):
    1.  
    2. #include "usb.h"
    3. #include "callbacks.h"
    4. #include "usb.c"
    5. // Lcd pinout settings
    6. sbit LCD_RS at RB4_bit;
    7. sbit LCD_EN at RB5_bit;
    8. sbit LCD_D7 at RB3_bit;
    9. sbit LCD_D6 at RB2_bit;
    10. sbit LCD_D5 at RB1_bit;
    11. sbit LCD_D4 at RB0_bit;
    12.  
    13. // Pin direction
    14. sbit LCD_RS_Direction at TRISB4_bit;
    15. sbit LCD_EN_Direction at TRISB5_bit;
    16. sbit LCD_D7_Direction at TRISB3_bit;
    17. sbit LCD_D6_Direction at TRISB2_bit;
    18. sbit LCD_D5_Direction at TRISB1_bit;
    19. sbit LCD_D4_Direction at TRISB0_bit;
    20.  
    21. // HID feature buffer
    22. volatile unsigned char HIDFeatureBuffer[HID_FEATURE_REPORT_BYTES];
    23.  
    24. void interrupt_low(void)
    25. {
    26. }
    27.  
    28. // Allocate buffers in RAM for storage of bytes that have either just
    29. // come in from the SIE or are waiting to go out to the SIE.
    30. char txBuffer[HID_INPUT_REPORT_BYTES];
    31. char rxBuffer[HID_OUTPUT_REPORT_BYTES];
    32. unsigned int timestamp=0;
    33. extern byte transferType;
    34.  
    35. // Entry point for user initialization
    36. void UserInit(void)
    37. {
    38.         TRISA=0b11111001;
    39.         PORTA=0;
    40.         TRISB=0;
    41.         PORTB=0;
    42.         T0CON=0x80;                        // Timer0 period = T*2^16:2 = 5.46ms:2 = 10.93ms (PS=2)
    43.         //display("USER INIT");
    44. }
    45.  
    46. #define LOBYTE(x) (*((char *)&x))
    47. #define HIBYTE(x) (*(((char *)&x)+1))
    48.  
    49. // If we got some bytes from the host, then echo them back.
    50. byte rxCnt;
    51. static void USBEcho(void)
    52. {
    53.     byte i;
    54.  
    55.     // Find out if an Output report has been received from the host.
    56.     rxCnt = HIDRxReport(rxBuffer, HID_OUTPUT_REPORT_BYTES);
    57.  
    58.         // If no bytes in, then nothing to do
    59.         if (rxCnt == 0)
    60.                 return;
    61.  
    62.         // put first byte in PORTB
    63.         LATB=rxBuffer[0];
    64.         // x01 to signal interrupt transfer
    65.         LATB.LATB1=0;
    66.         LATB.LATB0=1;
    67.  
    68.         //read PORTA levels and store in first byte of report
    69.         txBuffer[0]=PORTA;
    70.         txBuffer[1]=0xF0;        //this is to differentiate between different transfer types
    71.         txBuffer[2]=HIBYTE(timestamp);
    72.         txBuffer[3]=LOBYTE(timestamp);
    73.     // Copy input bytes to the output buffer
    74.         for (i=4;i<HID_OUTPUT_REPORT_BYTES;i++)
    75.         txBuffer[i] = rxBuffer[i];
    76.  
    77.     // As long as the SIE is owned by the processor, we let USB tasks continue.
    78.         while (ep1Bi.Stat & UOWN)
    79.         ProcessUSBTransactions();
    80.  
    81.     // The report will be sent in the next interrupt IN transfer.
    82.     HIDTxReport(txBuffer, HID_INPUT_REPORT_BYTES);
    83. }
    84.  
    85. // Central processing loop.  Whenever the firmware isn't busy servicing
    86. // the USB, we will get control here to do other processing.
    87. void ProcessIO(void)
    88. {
    89.     // User Application USB tasks
    90.      if ((deviceState < CONFIGURED) || (UCON.SUSPND==1))
    91.                 return;
    92.  
    93.         // Process USB: Echo back any bytes that have come in.
    94.     USBEcho();
    95. }
    96.  
    97. // Initialization for a SET_FEATURE request.  This routine will be
    98. // invoked during the setup stage and is used to set up the buffer
    99. // for receiving data from the host
    100. void SetupFeatureReport(byte reportID)
    101. {
    102.     if (reportID == 0)
    103.     {
    104.         // When the report arrives in the data stage, the data will be
    105.         // stored in HIDFeatureBuffer.
    106.         inPtr = (byte*)&HIDFeatureBuffer;
    107.     }
    108. }
    109.  
    110. // Post processing for a SET_FEATURE request.  After all the data has
    111. // been delivered from host to device, this will be invoked to perform
    112. // application specific processing.
    113. void SetFeatureReport(byte reportID)
    114. {
    115.     // Currently only handling report 0, ignore any others.
    116.     if (reportID == 0)
    117.     {
    118.         // Set the state of PORTB based on the first byte
    119.         // of the feature report.
    120.         LATB = HIDFeatureBuffer[0];
    121.                 // x10 to signal feature transfer
    122.                 LATB.LATB1=1;
    123.                 LATB.LATB0=0;
    124.     }
    125. }
    126.  
    127. // Handle a feature report request on the control pipe
    128. void GetFeatureReport(byte reportID)
    129. {
    130.         if (reportID == 0)
    131.         {
    132.                 // Handle report #0
    133.                 outPtr = (byte *)&HIDFeatureBuffer;
    134.                 HIDFeatureBuffer[0]=PORTA;
    135.                 HIDFeatureBuffer[1]=0xF1;        //this is to differentiate between different transfer types
    136.                 HIDFeatureBuffer[2]=HIBYTE(timestamp);
    137.                 HIDFeatureBuffer[3]=LOBYTE(timestamp);
    138.                 wCount = HID_FEATURE_REPORT_BYTES;
    139.                 transferType=0;
    140.         }
    141.  
    142. }
    143.  
    144. // Handle control out.  This might be an alternate way of processing
    145. // an output report, so all that's needed is to point the output
    146. // pointer to the output buffer
    147. // Initialization for a SET_REPORT request.  This routine will be
    148. // invoked during the setup stage and is used to set up the buffer
    149. // for receiving data from the host
    150. void SetupOutputReport(byte reportID)
    151. {
    152.         if (reportID == 0)
    153.         {
    154.                 // When the report arrives in the data stage, the data will be
    155.                 // stored in HIDFeatureBuffer
    156.                 inPtr = (byte*)&HIDRxBuffer;
    157.         }
    158. }
    159.  
    160.  
    161. // Post processing for a SET_REPORT request.  After all the data has
    162. // been delivered from host to device, this will be invoked to perform
    163. // application specific processing.
    164. void SetOutputReport(byte reportID)
    165. {
    166.  
    167.         // Currently only handling report 0, ignore any others.
    168.         if (reportID != 0)
    169.                 return;
    170.  
    171.         LATB=HIDRxBuffer[0];
    172.         // x11 to signal SET_REPORT transfer
    173.         LATB.LATB1=1;
    174.         LATB.LATB0=1;
    175. }
    176.  
    177. // Handle a control input report
    178. void GetInputReport(byte reportID)
    179. {
    180.         if (reportID == 0)
    181.         {
    182.                 byte i;
    183.                 // Send back the contents of the HID report
    184.                 // TBD: provide useful information...
    185.                 outPtr = (byte *)&HIDTxBuffer;
    186.                 HIDTxBuffer[0]=PORTA;
    187.                 HIDTxBuffer[1]=0xF2;        //this is to differentiate between different transfer types
    188.                 HIDTxBuffer[2]=HIBYTE(timestamp);
    189.                 HIDTxBuffer[3]=LOBYTE(timestamp);
    190.                 for(i=4;i<HID_INPUT_REPORT_BYTES;i++) HIDTxBuffer[i]=HIDRxBuffer[i];
    191.                 // The number of bytes in the report (from usb.h).
    192.                 wCount = HID_INPUT_REPORT_BYTES;
    193.                 transferType=0;
    194.         }
    195. }
    196. void display(unsigned int txt){
    197.      unsigned char ttxt[7];
    198.      Lcd_Cmd(_LCD_CLEAR);
    199.      delay_ms(200);
    200.      intToStr(txt,ttxt);
    201.      lcd_out(1,1,ttxt);
    202.      delay_ms(200);
    203. }
    204. // Entry point of the firmware
    205. void main(void) {
    206.     //byte led_cnt=0;
    207.  
    208.     ADCON1 |= 0x0F;                             // Set all I/O pins to digital
    209.      // Initialize USB
    210.     lcd_init();
    211.     UCFG = 0x14; // Enable pullup resistors; full speed mode
    212.  
    213.    
    214.    
    215.     //default configuration of the device..
    216.     deviceState = DETACHED;
    217.     remoteWakeup = 0x00;
    218.     currentConfiguration = 0x00;
    219.     //display("DETACHED");
    220.  
    221.    
    222.     // Call user initialization function
    223.         UserInit();
    224.        
    225.  
    226. while(1)
    227.     {
    228.         // Ensure USB module is available
    229.                 EnableUSBModule();
    230.                 // As long as we aren't in test mode (UTEYE), process
    231.                 // USB transactions.
    232.                 if(UCFG.UTEYE != 1)
    233.                        ProcessUSBTransactions();
    234.  
    235.         // Application specific tasks
    236.         ProcessIO();
    237.                  //  display(UIR.UERRIF);
    238.         /*//Blink LED2 @ 1Hz when configured
    239.                  if(INTCON.TMR0IF){
    240.                         INTCON.TMR0IF=0;
    241.                         timestamp++;
    242.                         led_cnt++;
    243.                         if (deviceState<CONFIGURED&&led_cnt>=10){
    244.                                 LED2 = !LED2;
    245.                                 led_cnt=0;
    246.                         }
    247.                         else if (deviceState == CONFIGURED&&led_cnt>=46){
    248.                                 LED2 = !LED2;
    249.                                 led_cnt=0;
    250.                         }
    251.                 }*/
    252.     }
    253.  
    254. }
    255. [/i][/i][/i][/i]
     
  4. buffon2009

    Thread Starter New Member

    Dec 7, 2011
    28
    0
    this is the includes file
    this is usb.h
    Code ( (Unknown Language)):
    1.  
    2. #ifndef USB_H
    3. #define USB_H
    4.  
    5. #define DEBUG_PRINT 0
    6.  
    7.  
    8. #define LSB(x) (x & 0xFF)
    9. #define MSB(x) ((x & 0xFF00) >> 8)
    10.  
    11. #define PTR16(x) ((unsigned int)(((unsigned long)x) & 0xFFFF))
    12. //
    13. // Standard Request Codes USB 2.0 Spec Ref Table 9-4
    14. //
    15. #define GET_STATUS         0
    16. #define CLEAR_FEATURE      1
    17. #define SET_FEATURE        3
    18. #define SET_ADDRESS        5
    19. #define GET_DESCRIPTOR     6
    20. #define SET_DESCRIPTOR     7
    21. #define GET_CONFIGURATION  8
    22. #define SET_CONFIGURATION  9
    23. #define GET_INTERFACE     10
    24. #define SET_INTERFACE     11
    25. #define SYNCH_FRAME       12
    26.  
    27. // Descriptor Types
    28. #define DEVICE_DESCRIPTOR        0x01
    29. #define CONFIGURATION_DESCRIPTOR 0x02
    30. #define STRING_DESCRIPTOR        0x03
    31. #define INTERFACE_DESCRIPTOR     0x04
    32. #define ENDPOINT_DESCRIPTOR      0x05
    33.  
    34. // Buffer Descriptor bit masks (from PIC datasheet)
    35. #define UOWN   0x80 // USB Own Bit
    36. #define DTS    0x40 // Data Toggle Synchronization Bit
    37. #define KEN    0x20 // BD Keep Enable Bit
    38. #define INCDIS 0x10 // Address Increment Disable Bit
    39. #define DTSEN  0x08 // Data Toggle Synchronization Enable Bit
    40. #define BSTALL 0x04 // Buffer Stall Enable Bit
    41. #define BC9    0x02 // Byte count bit 9
    42. #define BC8    0x01 // Byte count bit 8
    43.  
    44. // visible Device states (Chap 9.1.1)
    45. #define DETACHED     0
    46. #define ATTACHED     1
    47. #define POWERED      2
    48. #define DEFAULT      3
    49. #define ADDRESS      4
    50. #define CONFIGURED   5
    51.  
    52. // Definitions from "Device Class Definition for Human Interface Devices (HID)",
    53. // version 1.11
    54. //
    55.  
    56. // Class Descriptor Types
    57. #define HID_DESCRIPTOR      0x21
    58. #define REPORT_DESCRIPTOR   0x22
    59. #define PHYSICAL_DESCRIPTOR 0x23
    60.  
    61. // HID Class specific requests
    62. #define GET_REPORT      0x01
    63. #define GET_IDLE        0x02
    64. #define GET_PROTOCOL    0x03
    65. #define SET_REPORT      0x09
    66. #define SET_IDLE        0x0A
    67. #define SET_PROTOCOL    0x0B
    68.  
    69. // Size of the feature, input, and output reports
    70. #define HID_INPUT_REPORT_BYTES   64
    71. #define HID_OUTPUT_REPORT_BYTES  64
    72. #define HID_FEATURE_REPORT_BYTES 64
    73.  
    74. // Standard Feature Selectors
    75. #define DEVICE_REMOTE_WAKEUP    0x01
    76. #define ENDPOINT_HALT           0x00
    77.  
    78. typedef unsigned char byte;
    79. typedef unsigned int  word;
    80.  
    81. // Global variables
    82. extern byte deviceState;    // Visible device states (from USB 2.0, chap 9.1.1)
    83. extern byte selfPowered;
    84. extern byte remoteWakeup;
    85. extern byte currentConfiguration;
    86.  
    87. typedef struct _BDT
    88. {
    89.     byte Stat;
    90.     byte Cnt;
    91.     unsigned int ADDR;
    92. } BDT; //Buffer Descriptor Table
    93.  
    94. extern volatile BDT  ep0Bo; //Endpoint #0 BD Out
    95. extern volatile BDT  ep0Bi; //Endpoint #0 BD In
    96. extern volatile BDT  ep1Bo; //Endpoint #1 BD Out
    97. extern volatile BDT  ep1Bi; //Endpoint #1 BD In
    98.  
    99. // Every device request starts with an 8 byte setup packet (USB 2.0, chap 9.3)
    100. // with a standard layout.  The meaning of wValue and wIndex will
    101. // vary depending on the request type and specific request.
    102. typedef struct _setupPacketStruct
    103. {
    104.     byte bmRequestType; // D7: Direction, D6..5: Type, D4..0: Recipient
    105.     byte bRequest;      // Specific request
    106.     byte wValue0;       // LSB of wValue
    107.     byte wValue1;       // MSB of wValue
    108.     byte wIndex0;       // LSB of wIndex
    109.     byte wIndex1;       // MSB of wIndex
    110.     word wLength;       // Number of bytes to transfer if there's a data stage
    111.     byte extra[1];      // Fill out to same size as Endpoint 0 max buffer (E0SZ-7)
    112. } setupPacketStruct;
    113.  
    114. extern volatile setupPacketStruct SetupPacket;
    115.  
    116. // Size of the buffer for endpoint 0
    117. #define E0SZ 8
    118.  
    119. extern volatile byte HIDRxBuffer[HID_OUTPUT_REPORT_BYTES]; // Data received OUT from the host
    120. extern volatile byte HIDTxBuffer[HID_INPUT_REPORT_BYTES]; // Data sent IN to host
    121.  
    122. // inPtr/OutPtr are used to move data from user memory (RAM/ROM/EEPROM) buffers
    123. // from/to USB dual port buffers.
    124. extern byte *outPtr;        // Address of buffer to send to host
    125. extern byte *inPtr;         // Address of buffer to receive data from host
    126. extern unsigned int wCount; // Total # of bytes to move
    127.  
    128. // USB Functions
    129. void EnableUSBModule(void);
    130. void ProcessUSBTransactions(void);
    131.  
    132. // # of bytes from last HID transaction
    133. extern byte hidRxLen;
    134.  
    135. // Functions for reading/writing the HID interrupt endpoint
    136. byte HIDTxReport(byte *buffer, byte len);
    137. byte HIDRxReport(byte *buffer, byte len);
    138.  
    139. #endif //USB_H
    140.  
     
  5. buffon2009

    Thread Starter New Member

    Dec 7, 2011
    28
    0
    this is usb.c
    Code ( (Unknown Language)):
    1.  
    2. #include "usb.h"
    3. #include "callbacks.h"
    4.  
    5. #define ALLOW_SUSPEND 0
    6. // It appears that you need at least 6 loops that are replaced by memcpy()
    7. // before it is an advantage.
    8. #define USE_MEMCPY 0
    9.  
    10. // Device and configuration descriptors.  These are used as the
    11. // host enumerates the device and discovers what class of device
    12. // it is and what interfaces it supports.
    13. #define DEVICE_DESCRIPTOR_SIZE 0x12
    14. #define CONFIG_HEADER_SIZE  0x09
    15. #define HID_DESCRIPTOR_SIZE 0x20
    16. #define HID_HEADER_SIZE 0x09
    17.  
    18. typedef struct _configStruct
    19. {
    20.     byte configHeader[CONFIG_HEADER_SIZE];
    21.     byte HIDDescriptor[HID_DESCRIPTOR_SIZE];
    22. } ConfigStruct;
    23.  
    24. // Global variables
    25. byte deviceState;
    26. byte remoteWakeup;
    27. byte deviceAddress;
    28. byte selfPowered;
    29. byte currentConfiguration;
    30.  
    31. // Control Transfer Stages - see USB spec chapter 5
    32. #define SETUP_STAGE    0 // Start of a control transfer (followed by 0 or more data stages)
    33. #define DATA_OUT_STAGE 1 // Data from host to device
    34. #define DATA_IN_STAGE  2 // Data from device to host
    35. #define STATUS_STAGE   3 // Unused - if data I/O went ok, then back to Setup
    36.  
    37. byte ctrlTransferStage; // Holds the current stage in a control transfer
    38.  
    39. byte HIDPostProcess;    // Set to 1 if HID needs to process after the data stage
    40. byte requestHandled;    // Set to 1 if request was understood and processed.
    41.  
    42. byte *outPtr;           // Data to send to the host
    43. const byte *ROMoutPtr;    // Data to send to the host   //rom
    44. byte *inPtr;            // Data from the host
    45. word wCount;            // Number of bytes of data
    46. byte transferType;                // 0=ram 1=rom
    47.  
    48. // HID Class variables
    49. byte hidIdleRate;
    50. byte hidProtocol; // [0] Boot Protocol [1] Report Protocol
    51. byte hidRxLen;    // # of bytes put into buffer
    52.  
    53. volatile BDT  ep0Bo; //Endpoint #0 BD Out
    54. volatile BDT  ep0Bi; //Endpoint #0 BD In
    55. volatile BDT  ep1Bo; //Endpoint #1 BD Out
    56. volatile BDT  ep1Bi; //Endpoint #1 BD In
    57.  
    58. // TBD: add definitions for additional endpoints (2-16).
    59.  
    60. // Put endpoint 0 buffers into dual port RAM
    61. volatile setupPacketStruct SetupPacket;
    62. volatile byte controlTransferBuffer[E0SZ];
    63.  
    64. // HID specific buffers
    65. volatile byte HIDRxBuffer[HID_OUTPUT_REPORT_BYTES];
    66. volatile byte HIDTxBuffer[HID_INPUT_REPORT_BYTES];
    67.  
    68. const byte deviceDescriptor[] =
    69. {
    70.     0x12, 0x01, // bLength, bDescriptorType
    71.     0x00, 0x02, // bcdUSB (low byte), bcdUSB (high byte)
    72.     0x00, 0x00, // bDeviceClass, bDeviceSubClass
    73.     0x00, E0SZ, // bDeviceProtocl, bMaxPacketSize
    74.     0xD8, 0x04, // idVendor (low byte), idVendor (high byte)
    75.     0xFF, 0x01, // idProduct (low byte), idProduct (high byte)
    76.     0x01, 0x00, // bcdDevice (low byte), bcdDevice (high byte)
    77.     0x01, 0x02, // iManufacturer, iProduct
    78.     0x00, 0x01  // iSerialNumber (none), bNumConfigurations
    79. };
    80.  
    81. // Total config size is 0x09 + 0x09 + 0x09 + 0x07 + 0x07 = 0x29
    82. #define CFSZ 0x29
    83. #define HISZ HID_INPUT_REPORT_BYTES
    84. #define HOSZ HID_OUTPUT_REPORT_BYTES
    85.  
    86. const ConfigStruct configDescriptor =
    87. {
    88.     {
    89.     // Configuration descriptor
    90.     0x09, 0x02, // bLength, bDescriptorType (Configuration)
    91.     CFSZ, 0x00, // wTotalLength (low), wTotalLength (high)
    92.     0x01, 0x01, // bNumInterfaces, bConfigurationValue
    93.     0x00, 0xA0, // iConfiguration, bmAttributes ()
    94.     0x32,       // bMaxPower
    95.     },
    96.     {
    97.     // HID Interface descriptor
    98.     0x09, 0x04, // bLength, bDescriptorType (Interface)
    99.     0x00, 0x00, // bInterfaceNumber, bAlternateSetting
    100.     0x02, 0x03, // bNumEndpoints, bInterfaceClass (HID)
    101.     0x00, 0x00, // bInterfaceSubclass, bInterfaceProtocol,
    102.     0x00,       // iInterface
    103.     // Hid descriptor
    104.     0x09, 0x21, // bLength, bDescriptorType (HID)
    105.     0x01, 0x01, // bcdHID (low), bcdHID (high)
    106.     0x00, 0x01, // bCountryCode, bNumDescriptors
    107.     0x22, 47  , // bDescriptorType, wDescriptorLength (low)
    108.     0x00,       // wDescriptorLength (high)
    109.     // HID Endpoint 1 In
    110.     0x07, 0x05, // bLength, bDescriptorType (Endpoint)
    111.     0x81, 0x03, // bEndpointAddress, bmAttributes (Interrupt)
    112.     HISZ, 0x00, // wMaxPacketSize (low), wMaxPacketSize (high)
    113.     0x01,       // bInterval (1 millisecond)
    114.     // HID Endpoint 1 Out
    115.     0x07, 0x05, // bLength, bDescriptorType (Endpoint)
    116.     0x01, 0x03, // bEndpointAddress, bmAttributes (Interrupt)
    117.     HOSZ, 0x00, // wMaxPacketSize (low), wMaxPacketSize (high)
    118.     0x01,       // bInterval (1 millisecond)
    119.     }
    120. };
    121.  
    122. #define HIRB HID_INPUT_REPORT_BYTES
    123. #define HORB HID_OUTPUT_REPORT_BYTES
    124. #define HFRB HID_FEATURE_REPORT_BYTES
    125.  
    126. #define HID_REPORT_SIZE 47 // Size is from HID Descriptor tool
    127. const byte HIDReport[HID_REPORT_SIZE] = {
    128.     0x06, 0xa0, 0xff,  // USAGE_PAGE (Vendor Defined Page 1)
    129.     0x09, 0x01,        // USAGE (Vendor Usage 1)
    130.     0xa1, 0x01,        // COLLECTION (Application)
    131.  
    132.         // The Input report
    133.         0x09, 0x01,             // Usage ID - vendor defined
    134.         0x15, 0x00,             // Logical Minimum (0)
    135.         0x26, 0xFF, 0x00,   // Logical Maximum (255)
    136.         0x75, 0x08,             // Report Size (8 bits)
    137.         0x95, 0x40,             // Report Count (64 fields)
    138.         0x81, 0x02,             // Input (Data, Variable, Absolute)
    139.  
    140.         // The Output report
    141.         0x09, 0x01,             // Usage ID - vendor defined
    142.         0x15, 0x00,             // Logical Minimum (0)
    143.         0x26, 0xFF, 0x00,   // Logical Maximum (255)
    144.         0x75, 0x08,             // Report Size (8 bits)
    145.         0x95, 0x40,             // Report Count (64 fields)
    146.         0x91, 0x02,              // Output (Data, Variable, Absolute)
    147.  
    148.         // The Feature report
    149.         0x09, 0x02,             // Usage ID - vendor defined
    150.         0x15, 0x00,             // Logical Minimum (0)
    151.         0x26, 0xFF, 0x00,   // Logical Maximum (255)
    152.         0x75, 0x08,             // Report Size (8 bits)
    153.         0x95, 0x40,             // Report Count (64 fields)
    154.         0xB1, 0x02,              // Feature (Data, Variable, Absolute)
    155.  
    156.     0xc0               // END_COLLECTION
    157. };
    158.  
    159. const byte stringDescriptor0[] =
    160. {
    161.     0x04, STRING_DESCRIPTOR,
    162.     0x09, 0x04,
    163. };
    164. const byte stringDescriptor1[] =
    165. {
    166.     32, STRING_DESCRIPTOR, // bLength, bDscType
    167.     'G',0,'e',0,'n',0,'e',0,'r',0,'i',0,'c',0,' ',0,'H',0,'I',0,'D',0,' ',0,'I',0,'/',0,'O',0,
    168. };
    169. const byte stringDescriptor2[] =
    170. {
    171.     48, STRING_DESCRIPTOR,
    172.     'E',0,'x',0,'a',0,'m',0,'p',0,'l',0,'e',0,' ',0,'o',0,'f',0,' ',0,'H',0,'I',0,'D',0,' ',0,
    173.     'f',0,'i',0,'r',0,'m',0,'w',0,'a',0,'r',0,'e',0,
    174. };
    175.  
     
Loading...