usb: hid: allow boot interface Protocol Code to be set per device

Kconfig option USB_HID_PROTOCOL_CODE does not allow to set
boot interface protocol code for specific HID device but
only to set the same value for all device.
Add new API function to allow the application to set
Protocol Code per device. Deprecate USB_HID_PROTOCOL_CODE option.

Fixes: #32778

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
Johann Fischer 2021-03-15 13:28:57 +01:00 committed by Anas Nashif
commit 91ddb8c9fe
5 changed files with 39 additions and 7 deletions

View file

@ -53,6 +53,13 @@ extern "C" {
/** USB HID Class SetProtocol bRequest value */
#define USB_HID_SET_PROTOCOL 0x0B
/** USB HID Boot Interface Protocol (bInterfaceProtocol) Code None */
#define HID_BOOT_IFACE_CODE_NONE 0
/** USB HID Boot Interface Protocol (bInterfaceProtocol) Code Keyboard */
#define HID_BOOT_IFACE_CODE_KEYBOARD 1
/** USB HID Boot Interface Protocol (bInterfaceProtocol) Code Mouse */
#define HID_BOOT_IFACE_CODE_MOUSE 2
/** USB HID Class Boot protocol code */
#define HID_PROTOCOL_BOOT 0
/** USB HID Class Report protocol code */

View file

@ -108,6 +108,18 @@ int hid_int_ep_read(const struct device *dev,
uint32_t max_data_len,
uint32_t *ret_bytes);
/**
* @brief Set USB HID class Protocol Code
*
* @details Should be called before usb_hid_init().
*
* @param[in] dev Pointer to USB HID device
* @param[in] proto_code Protocol Code to be used for bInterfaceProtocol
*
* @return 0 on success, negative errno code on fail.
*/
int usb_hid_set_proto_code(const struct device *dev, uint8_t proto_code);
/**
* @brief Initialize USB HID class support
*