usb: Allow to register and handle vendor specific commands

At the moment we cannot handle vendor specific commands resulting in
error with following message:
...
[DBG] usb_handle_request: No handler for reqtype 2
[DBG] usb_handle_control_transfer: usb_handle_request failed
...

Change-Id: Ic899300e0c420c58ac3f86ecf5f5ec45955bd46f
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2016-08-25 16:13:10 +03:00 committed by Anas Nashif
commit 03b5412849
2 changed files with 13 additions and 0 deletions

View file

@ -101,6 +101,8 @@ struct usb_ep_cfg_data {
struct usb_interface_cfg_data {
/** Handler for USB Class specific Control (EP 0) communications */
usb_request_handler class_handler;
/** Handler for USB Vendor specific commands */
usb_request_handler vendor_handler;
/**
* The custom request handler gets a first chance at handling
* the request before it is handed over to the 'chapter 9' request
@ -115,6 +117,11 @@ struct usb_interface_cfg_data {
* communications
*/
uint8_t *payload_data;
/**
* This data area, allocated by the application, is used to store
* Vendor specific payload
*/
uint8_t *vendor_data;
};
/*

View file

@ -780,6 +780,12 @@ int usb_set_config(struct usb_cfg_data *config)
config->interface.class_handler,
config->interface.payload_data);
}
/* register vendor request handlers */
if (config->interface.vendor_handler) {
usb_register_request_handler(REQTYPE_TYPE_VENDOR,
config->interface.vendor_handler,
config->interface.vendor_data);
}
/* register class request handlers for each interface*/
if (config->interface.custom_handler != NULL) {
usb_register_custom_req_handler(