usb: hid: Add Human Interface Device (HID) class
Add support for Human Interface Device USB class. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
8f21a37861
commit
e8ccb16986
8 changed files with 401 additions and 3 deletions
71
include/usb/class/usb_hid.h
Normal file
71
include/usb/class/usb_hid.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Human Interface Device (HID) USB class core header
|
||||
*
|
||||
* Copyright (c) 2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief USB Human Interface Device (HID) Class public header
|
||||
*
|
||||
* Header follows Device Class Definition for Human Interface Devices (HID)
|
||||
* Version 1.11 document (HID1_11-1.pdf).
|
||||
*/
|
||||
|
||||
#ifndef __USB_HID_H__
|
||||
#define __USB_HID_H__
|
||||
|
||||
struct usb_hid_class_subdescriptor {
|
||||
u8_t bDescriptorType;
|
||||
u16_t wDescriptorLength;
|
||||
} __packed;
|
||||
|
||||
struct usb_hid_descriptor {
|
||||
u8_t bLength;
|
||||
u8_t bDescriptorType;
|
||||
u16_t bcdHID;
|
||||
u8_t bCountryCode;
|
||||
u8_t bNumDescriptors;
|
||||
|
||||
/*
|
||||
* Specification says at least one Class Descriptor needs to
|
||||
* be present (Report Descriptor).
|
||||
*/
|
||||
struct usb_hid_class_subdescriptor subdesc[1];
|
||||
} __packed;
|
||||
|
||||
/* HID Class Specific Requests */
|
||||
|
||||
#define HID_GET_REPORT 0x01
|
||||
#define HID_GET_IDLE 0x02
|
||||
#define HID_GET_PROTOCOL 0x03
|
||||
#define HID_SET_REPORT 0x09
|
||||
#define HID_SET_IDLE 0x0A
|
||||
#define HID_SET_PROTOCOL 0x0B
|
||||
|
||||
/* Public headers */
|
||||
|
||||
struct hid_ops {
|
||||
int (*get_report)(struct usb_setup_packet *setup, s32_t *len,
|
||||
u8_t **data);
|
||||
int (*get_idle)(struct usb_setup_packet *setup, s32_t *len,
|
||||
u8_t **data);
|
||||
int (*get_protocol)(struct usb_setup_packet *setup, s32_t *len,
|
||||
u8_t **data);
|
||||
int (*set_report)(struct usb_setup_packet *setup, s32_t *len,
|
||||
u8_t **data);
|
||||
int (*set_idle)(struct usb_setup_packet *setup, s32_t *len,
|
||||
u8_t **data);
|
||||
int (*set_protocol)(struct usb_setup_packet *setup, s32_t *len,
|
||||
u8_t **data);
|
||||
};
|
||||
|
||||
/* Register HID device */
|
||||
void usb_hid_register_device(const u8_t *desc, size_t size, struct hid_ops *op);
|
||||
|
||||
/* Initialize USB HID */
|
||||
int usb_hid_init(void);
|
||||
|
||||
#endif /* __USB_HID_H__ */
|
Loading…
Add table
Add a link
Reference in a new issue