unsigned char code device_descriptor[] = {
0x12, /* bLength */
0x01, /* bDescriptor */
0x10, 0x01, /* bcdUSB */
0x00, /* bDeviceClass */
0x00, /* bDeviceSubClass */
0x00, /* bDevcieProtocol */
//0x40, /* bMaxPacketSize */
0x10, /* bMaxPacketSize */
0x00, 0x80, /* idVendor */
0x01, 0x00, /* idProduct */
0x00, 0x01, /* bcdDevice */
0x00,//0x01, /* iManufacturer */
0x00,//0x02, /* iProduct */
0x00, /* iSerialNumber */
0x01 /* bNumConfigurations */
};
unsigned char code config_descriptor[] = {
/* usb configuration descriptor */
0x09, /* bLength */
0x02, /* bDescriptorType */
0x22, 0x00, /* wTotalLength */
0x01, /* bNumInterfaces */
0x01, /* bConfigurationValue */
0x00, /* iConfiguration */
0x80, /* bmAttributes */
0x32, /* bMaxPower */
/* usb interface descriptor */
0x09, /* bLength */
0x04, /* bDescriptorType */
0x00, /* bInterfaceNumber */
0x00, /* bAlternateSetting */
0x01, /* bNumEndpoints */
0x03, /* bInterfaceClass */
0x01, /* bInterfaceSubClass */
0x01, /* bInterfaceProtocol */
0x00, /* iInterface */
/* usb hid descriptor */
0x09, /* bLength */
0x21, /* bDescriptorType */
0x01, 0x01, /* bcdHID */
0x00, /* bCountryCode */
0x01, /* bNumDescriptor */
0x22, /* wDescriptorType */
0x2d, 0x00, /* wDescriptorLength */
/* usb endpoint descriptor */
0x07, /* bLength */
0x05, /* bDescriptorType */
0x81, /* bEndpointAddress */
0x03, /* bmAttributes */
0x08, 0x00, /* wMaxPacketSize */
0x0a /* bInterval */
};
//#define USB_KEYBOARD_USE_LED 1
#define REPORT_DESCRIPTOR_SIZE 0x3f
#define REPORT_DESCRIPTOR_NOLED_SIZE 0x2d
/*
* 键盘有输入报告和输出报告,其中输入报告8个字节,输出报告1个字节
* 输入报告格式如下:
* [Key6][Key5][Key4][Key3][Key2][Key1][Reserved][Function Key]
* 输出报告格式如下:
* 7~5 4 3 2 1 0
* Reserved Kana Compose Scroll Lock Caps Lock Num Lock
*/
unsigned char code report_descriptor[] = {
0x05, 0x01, /* Usage Page(Generic Desktop) */
0x09, 0x06, /* Usage(Keyboard) */
0xa1, 0x01, /* Collection(Application) */
/* function key, such as Ctrl, Shift... */
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, Variable, Absolute) */
/* byte for reserved */
0x95, 0x01, /* Report Count(1) */
0x75, 0x08, /* Report Size(8) */
0x81, 0x01, /* Input(Constant) */
#ifdef USB_KEYBOARD_USE_LED
/* for LED */
0x95, 0x05, /* Report Count(5) */
0x75, 0x01, /* Report Size(1) */
0x05, 0x08, /* Usage Page(for LEDs) */
0x19, 0x01, /* Usage Minimum(Num Lock) */
0x29, 0x05, /* Usage Maximum(Kana) */
0x91, 0x02, /* Output(Data, Variable, Absolute) */
0x95, 0x01, /* Report Count(1) */
0x75, 0x03, /* Report Size(3) */
0x91, 0x01, /* Output(Constant) */
#endif
/* generic key */
0x95, 0x06, /* Report Count(6) */
0x75, 0x08, /* Report Size(8) */
0x15, 0x00, /* Logical Minimum(0) */
0x25, 0x65, /* Logical Maximum(101) */
0x05, 0x07, /* Usage Page(Key Codes) */
0x19, 0x00, /* Usage Minimum(0) */
0x29, 0x65, /* Usage Maximum(101) */
0x81, 0x00, /* Input(Data, Array) */
0xc0 /* End Collection */
};