Microchip Technology DM164127 Fiche De Données

Page de 54
© 2009 Microchip Technology Inc.
DS41356B-page 25
EXAMPLE 2-8: 
REPORT DESCRIPTOR FOR KEYBOARD()
Next, the keyboard.c source file will be configured.
6.
In the Project window, open the keyboard.c source file and scroll down to the 
UserInit(). 
Uncomment the port and ADC initialization code. The user is 
urged to review the PIC18F14K50 data sheet as to the significance of these 
initializations for the appropriate peripheral. 
// ADCON0=0x29;
// ADCON1 = 0X00;
// ADCON2=0x3F;  
Scroll down to the keyboard() and copy and paste the code in Example 2-9 
between the curly braces in the switch at:
//ADD STATE MACHINE CODE HERE
0x05, 0x01,   //   USAGE_PAGE (Generic Desktop)
0x09, 0x06,   //   USAGE (Keyboard)
0xa1, 0x01,   //   COLLECTION (Application)
0x05, 0x07,   //   USAGE_PAGE (Keyboard)
0x19, 0xe0,   //   USAGE_MINIMUM (Keyboard LeftControl)
0x29, 0xe7,   //   USAGE_MAXIMUM (Keyboard Right GUI)
0x15, 0x00,   //   LOGICAL_MINIMUM (0)
0x25, 0x01,   //   LOGICAL_MAXIMUM (1)
0x75, 0x01,   //   REPORT_SIZE (1)
0x95, 0x08,   //   REPORT_COUNT (8)
0x81, 0x02,   //   INPUT (Data,Var,Abs)
0x95, 0x01,   //   REPORT_COUNT (1)
0x75, 0x08,   //   REPORT_SIZE (8)
0x81, 0x03,   //   INPUT (Cnst,Var,Abs)
0x95, 0x05,   //   REPORT_COUNT (5)
0x75, 0x01,   //   REPORT_SIZE (1)
0x05, 0x08,   //   USAGE_PAGE (LEDs)
0x19, 0x01,   //   USAGE_MINIMUM (Num Lock)
0x29, 0x05,   //   USAGE_MAXIMUM (Kana)
0x91, 0x02,   //   OUTPUT (Data,Var,Abs)
0x95, 0x01,   //   REPORT_COUNT (1)
0x75, 0x03,   //   REPORT_SIZE (3)
0x91, 0x03,   //   OUTPUT (Cnst,Var,Abs)
0x95, 0x06,   //   REPORT_COUNT (6)
0x75, 0x08,   //   REPORT_SIZE (8)
0x15, 0x00,   //   LOGICAL_MINIMUM (0)
0x25, 0x65,   //   LOGICAL_MAXIMUM (101)
0x05, 0x07,   //   USAGE_PAGE (Keyboard)
0x19, 0x00,   //   USAGE_MINIMUM (Reserved (no event indicated))
0x29, 0x65,   //   USAGE_MAXIMUM (Keyboard Application)
0x81, 0x00,   //   INPUT (Data,Ary,Abs)
0xc0