USB HID Class API
USB device specific part for HID support defined in include/zephyr/usb/class/usb_hid.h.
API Reference
- group usb_hid_device_api
- Typedefs - Functions - 
void usb_hid_register_device(const struct device *dev, const uint8_t *desc, size_t size, const struct hid_ops *op)
- Register HID device. - Parameters:
- dev – [in] Pointer to USB HID device 
- desc – [in] Pointer to HID report descriptor 
- size – [in] Size of HID report descriptor 
- op – [in] Pointer to USB HID device interrupt struct 
 
 
 - 
int hid_int_ep_write(const struct device *dev, const uint8_t *data, uint32_t data_len, uint32_t *bytes_ret)
- Write to USB HID interrupt endpoint buffer. - Parameters:
- dev – [in] Pointer to USB HID device 
- data – [in] Pointer to data buffer 
- data_len – [in] Length of data to copy 
- bytes_ret – [out] Bytes written to the EP buffer. 
 
- Returns:
- 0 on success, negative errno code on fail. 
 
 - 
int hid_int_ep_read(const struct device *dev, uint8_t *data, uint32_t max_data_len, uint32_t *ret_bytes)
- Read from USB HID interrupt endpoint buffer. - Parameters:
- dev – [in] Pointer to USB HID device 
- data – [in] Pointer to data buffer 
- max_data_len – [in] Max length of data to copy 
- ret_bytes – [out] Number of bytes to copy. If data is NULL and max_data_len is 0 the number of bytes available in the buffer will be returned. 
 
- Returns:
- 0 on success, negative errno code on fail. 
 
 - 
int usb_hid_set_proto_code(const struct device *dev, uint8_t proto_code)
- Set USB HID class Protocol Code. - Should be called before usb_hid_init(). - Parameters:
- dev – [in] Pointer to USB HID device 
- proto_code – [in] Protocol Code to be used for bInterfaceProtocol 
 
- Returns:
- 0 on success, negative errno code on fail. 
 
 - 
struct hid_ops
- #include <usb_hid.h>USB HID device interface. 
 
- 
void usb_hid_register_device(const struct device *dev, const uint8_t *desc, size_t size, const struct hid_ops *op)