📄 kbd_desc.c
字号:
#include <cpu.h>
#include <version.h>
#include "kbd_desc.h"
const BYTE KEYBOARD_DeviceDescriptor[ KEYBOARD_SIZ_DEVICE_DESC] = {
0x12, // bLength
0x01, // bDescriptorType
0x10, 0x01, // bcdUSB (spec release # 1.10)
0x00, // bDeviceClass
0x00, // bDeviceSubClass
0x00, // bDeviceProtocol
0x08, // bMaxPacketSize0
0xB7, 0x0E, // idVendor
0x16, 0x00, // idProduct
V_MINOR, V_MAJOR, // bcdDevice ex: 2.02
1, // Index of string Descriptor describing manufacturer
3, // Index of string Descriptor describing product
0, // Index of string Descriptor describing the device's serial number
0x01 // bNumConfigurations (Only one config)
} ;
const BYTE KEYBOARD_ConfigDescriptor[ KEYBOARD_SIZ_CONFIG_DESC] = {
// Configuration descriptor
0x09, // bLength: Configuration Descriptor size
0x02, // bDescriptorType: Configuration
KEYBOARD_SIZ_CONFIG_DESC, // Length of configuration descriptor.
0, // MSB Length of configuration descriptor.
0x01, // bNumInterfaces: 1 interfaces.
0x01, // bConfigurationValue: Configuration value = 1
0, // iConfiguration: Index of string descriptor describing the configuration (None)
0x80, // bmAttributes: Bus powered and NO Remote wakeup
// 0xA0, // bmAttributes: Bus powered and Remote wakeup
// 0xC0, // bmAttributes: Self powered and NO Remote wakeup
// 0xE0, // bmAttributes: Self powered and Remote wakeup
0x32, // MaxPower 100 mA
// Interface descriptor (Interface 0 = DemoKit)
0x09, // bLength: Interface Descriptor size
0x04, // bDescriptorType: Interface descriptor type
0x00, // bInterfaceNumber: Interface Number = 0
0x00, // bAlternateSetting: No Alternate setting
0x01, // bNumEndpoints: one endpoints used
0x03, // bInterfaceClass: HID
0x01, // bInterfaceSubClass: No subclass
0x01, // bInterfaceProtocol: none
0x00, // iInterface: Index of string descriptor (No string value)
// HID descriptor (Demokit)
0x09, // bLength: HID Descriptor size
0x21, // bDescriptorType: HID
0x10, // bcdHID(LSB): HID Class Spec release number (1.10)
0x01, // bcdHID(MSB)
0x00, // bCountryCode: None
0x01, // bNumDescriptors: Number of HID class descriptors to follow
0x22, // bDescriptorType: Report
KEYBOARD_SIZ_REPORT_DESC, // Length of report descriptor interface 0 (2 bytes)
0, // Length of report descriptor interface 0 (2 bytes)
// Endpoint 1 descriptor (Demokit)
0x07, // bLength: Endpoint Descriptor size
0x05, // bDescriptorType: Endpoint descriptor type
0x81, // bEndpointAddress: Endpoint 1 IN
0x03, // bmAttributes: Interrupt endpoint
0x08, // wMaxPacketSize(LSB): 8 Byte max (0x0008)
0x00, // wMaxPacketSize (MSB)
0x0A // bInterval: Polling Interval (10 ms = 0x0A)
} ;
const BYTE KEYBOARD_ReportDescriptor[ KEYBOARD_SIZ_REPORT_DESC] = {
0x05, 0x01, // USAGE_PAGE( Generic Desktop)
0x09, 0x06, // USAGE( Keyboard)
0xA1, 0x01, // COLLECTION( Application)
0x05, 0x07,
0x19, 0xE0,
0x29, 0xE7,
0x15, 0x00,
0x25, 0x01,
0x75, 0x01, /* REPORT_SIZE( 1) */
0x95, 0x08, /* REPORT_COUNT( 8) */
0x81, 0x02,
0x95, 0x01, /* REPORT_COUNT( 1) */
0x75, 0x08, /* REPORT_SIZE( 8) */
0x81, 0x01,
0x95, 0x05, /* REPORT_COUNT( 5) */
0x75, 0x01, /* REPORT_SIZE( 1) */
0x05, 0x08, 0x19, 0x01, 0x29, 0x05, 0x91, 0x02,
0x95, 0x01, /* REPORT_COUNT( 1) */
0x75, 0x03, /* REPORT_SIZE( 3) */
0x91, 0x01,
0x95, 0x06, /* REPORT_COUNT( 5) */
0x75, 0x08, /* REPORT_SIZE( 8) */
0x15, 0x00, 0x25, 0x65, 0x05, 0x07, 0x19, 0x00, 0x29, 0x65,
0x81, 0x00, 0xC0
} ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -