Merge pull request #1604 from uestczyh222/master

[Components][USB][Device]Support customer HID class|支持自定义HID设备
This commit is contained in:
ZYH 2018-07-04 14:55:19 +08:00 committed by GitHub
commit e6a34ead5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 22 deletions

View File

@ -222,26 +222,13 @@ extern "C" {
#define USB_EP_DESC_NUM(addr) (addr & USB_EP_DESC_NUM_MASK) #define USB_EP_DESC_NUM(addr) (addr & USB_EP_DESC_NUM_MASK)
#define USB_EP_DIR(addr) ((addr & USB_DIR_MASK)>>7) #define USB_EP_DIR(addr) ((addr & USB_DIR_MASK)>>7)
#ifdef RT_USB_DEVICE_HID
#ifdef RT_USB_DEVICE_HID_KEYBOARD
#define HID_REPORT_ID_KEYBOARD1 1 #define HID_REPORT_ID_KEYBOARD1 1
#if RT_USB_DEVICE_HID_KEYBOARD_NUMBER>1
#define HID_REPORT_ID_KEYBOARD2 2 #define HID_REPORT_ID_KEYBOARD2 2
#if RT_USB_DEVICE_HID_KEYBOARD_NUMBER>2
#define HID_REPORT_ID_KEYBOARD3 3 #define HID_REPORT_ID_KEYBOARD3 3
#endif #define HID_REPORT_ID_KEYBOARD4 7
#endif
#endif
#ifdef RT_USB_DEVICE_HID_MEDIA
#define HID_REPORT_ID_MEDIA 4 #define HID_REPORT_ID_MEDIA 4
#endif
#ifdef RT_USB_DEVICE_HID_GENERAL
#define HID_REPORT_ID_GENERAL 5 #define HID_REPORT_ID_GENERAL 5
#endif
#ifdef RT_USB_DEVICE_HID_MOUSE
#define HID_REPORT_ID_MOUSE 6 #define HID_REPORT_ID_MOUSE 6
#endif
#endif
#define uswap_32(x) \ #define uswap_32(x) \
((((x) & 0xff000000) >> 24) | \ ((((x) & 0xff000000) >> 24) | \
@ -473,7 +460,6 @@ typedef struct usb_os_proerty * usb_os_proerty_t;
#define HID_SUB_DESCRIPTOR_MAX 1 #define HID_SUB_DESCRIPTOR_MAX 1
#endif #endif
#ifdef RT_USB_DEVICE_HID
struct uhid_descriptor struct uhid_descriptor
{ {
rt_uint8_t bLength; rt_uint8_t bLength;
@ -497,7 +483,7 @@ struct hid_report
}; };
typedef struct hid_report* hid_report_t; typedef struct hid_report* hid_report_t;
extern void HID_Report_Received(hid_report_t report); extern void HID_Report_Received(hid_report_t report);
#endif
struct urequest struct urequest
{ {
rt_uint8_t request_type; rt_uint8_t request_type;

View File

@ -129,6 +129,34 @@ const rt_uint8_t _report_desc[]=
USAGE_MAXIMUM(1), 0x65, USAGE_MAXIMUM(1), 0x65,
INPUT(1), 0x00, INPUT(1), 0x00,
END_COLLECTION(0), END_COLLECTION(0),
#if RT_USB_DEVICE_HID_KEYBOARD_NUMBER>3
USAGE_PAGE(1), 0x01,
USAGE(1), 0x06,
COLLECTION(1), 0x01,
REPORT_ID(1), HID_REPORT_ID_KEYBOARD4,
USAGE_PAGE(1), 0x07,
USAGE_MINIMUM(1), 0xE0,
USAGE_MAXIMUM(1), 0xE7,
LOGICAL_MINIMUM(1), 0x00,
LOGICAL_MAXIMUM(1), 0x01,
REPORT_SIZE(1), 0x01,
REPORT_COUNT(1), 0x08,
INPUT(1), 0x02,
REPORT_COUNT(1), 0x01,
REPORT_SIZE(1), 0x08,
INPUT(1), 0x01,
REPORT_COUNT(1), 0x06,
REPORT_SIZE(1), 0x08,
LOGICAL_MINIMUM(1), 0x00,
LOGICAL_MAXIMUM(1), 0x65,
USAGE_PAGE(1), 0x07,
USAGE_MINIMUM(1), 0x00,
USAGE_MAXIMUM(1), 0x65,
INPUT(1), 0x00,
END_COLLECTION(0),
#endif
#endif #endif
#endif #endif
#endif #endif