usb: Allow to select configuration for composite devices
Composite multifunction USB devices should be able to know about configuration change, implement it through existing callback. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
d5486e2e73
commit
4efaefba5c
|
@ -452,7 +452,7 @@ static void usb_dw_handle_reset(void)
|
|||
|
||||
/* Inform upper layers */
|
||||
if (usb_dw_ctrl.status_cb) {
|
||||
usb_dw_ctrl.status_cb(USB_DC_RESET);
|
||||
usb_dw_ctrl.status_cb(USB_DC_RESET, NULL);
|
||||
}
|
||||
|
||||
/* Clear device address during reset. */
|
||||
|
@ -476,7 +476,7 @@ static void usb_dw_handle_enum_done(void)
|
|||
|
||||
/* Inform upper layers */
|
||||
if (usb_dw_ctrl.status_cb) {
|
||||
usb_dw_ctrl.status_cb(USB_DC_CONNECTED);
|
||||
usb_dw_ctrl.status_cb(USB_DC_CONNECTED, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -513,7 +513,7 @@ static void usb_dw_isr_handler(void)
|
|||
USB_DW->gintsts = USB_DW_GINTSTS_USB_SUSP;
|
||||
|
||||
if (usb_dw_ctrl.status_cb) {
|
||||
usb_dw_ctrl.status_cb(USB_DC_SUSPEND);
|
||||
usb_dw_ctrl.status_cb(USB_DC_SUSPEND, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,7 @@ static void usb_dw_isr_handler(void)
|
|||
USB_DW->gintsts = USB_DW_GINTSTS_WK_UP_INT;
|
||||
|
||||
if (usb_dw_ctrl.status_cb) {
|
||||
usb_dw_ctrl.status_cb(USB_DC_RESUME);
|
||||
usb_dw_ctrl.status_cb(USB_DC_RESUME, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,8 @@ typedef void (*usb_dc_ep_callback)(u8_t ep,
|
|||
/**
|
||||
* Callback function signature for the device
|
||||
*/
|
||||
typedef void (*usb_dc_status_callback)(enum usb_dc_status_code cb_status);
|
||||
typedef void (*usb_dc_status_callback)(enum usb_dc_status_code cb_status,
|
||||
u8_t *param);
|
||||
|
||||
/**
|
||||
* @brief attach USB for device connection
|
||||
|
|
|
@ -61,7 +61,8 @@ struct usb_setup_packet {
|
|||
/**
|
||||
* Callback function signature for the device
|
||||
*/
|
||||
typedef void (*usb_status_callback)(enum usb_dc_status_code status_code);
|
||||
typedef void (*usb_status_callback)(enum usb_dc_status_code status_code,
|
||||
u8_t *param);
|
||||
|
||||
/**
|
||||
* Callback function signature for the USB Endpoint status
|
||||
|
|
|
@ -549,10 +549,12 @@ static struct usb_ep_cfg_data btusb_ep[] = {
|
|||
#endif
|
||||
};
|
||||
|
||||
static void btusb_status_cb(enum usb_dc_status_code status)
|
||||
static void btusb_status_cb(enum usb_dc_status_code status, u8_t *param)
|
||||
{
|
||||
struct btusb_dev_data_t * const dev_data = DEV_DATA(btusb_dev);
|
||||
|
||||
ARG_UNUSED(param);
|
||||
|
||||
/* Store the new status */
|
||||
dev_data->usb_status = status;
|
||||
|
||||
|
|
|
@ -224,10 +224,12 @@ static struct usb_ep_cfg_data wpanusb_ep[] = {
|
|||
},
|
||||
};
|
||||
|
||||
static void wpanusb_status_cb(enum usb_dc_status_code status)
|
||||
static void wpanusb_status_cb(enum usb_dc_status_code status, u8_t *param)
|
||||
{
|
||||
struct wpanusb_dev_data_t * const dev_data = DEV_DATA(wpanusb_dev);
|
||||
|
||||
ARG_UNUSED(param);
|
||||
|
||||
/* Store the new status */
|
||||
dev_data->usb_status = status;
|
||||
|
||||
|
|
|
@ -539,8 +539,10 @@ static int dfu_class_handle_req(struct usb_setup_packet *pSetup,
|
|||
*
|
||||
* @return N/A.
|
||||
*/
|
||||
static void dfu_status_cb(enum usb_dc_status_code status)
|
||||
static void dfu_status_cb(enum usb_dc_status_code status, u8_t *param)
|
||||
{
|
||||
ARG_UNUSED(param);
|
||||
|
||||
/* Check the USB status and do needed action if required */
|
||||
switch (status) {
|
||||
case USB_DC_ERROR:
|
||||
|
|
|
@ -488,11 +488,14 @@ static void webusb_serial_int_in(u8_t ep,
|
|||
*
|
||||
* @return N/A.
|
||||
*/
|
||||
static void webusb_serial_dev_status_cb(enum usb_dc_status_code status)
|
||||
static void webusb_serial_dev_status_cb(enum usb_dc_status_code status,
|
||||
u8_t *param)
|
||||
{
|
||||
struct webusb_serial_dev_data_t * const dev_data =
|
||||
DEV_DATA(webusb_serial_dev);
|
||||
|
||||
ARG_UNUSED(param);
|
||||
|
||||
/* Store the new status */
|
||||
dev_data->usb_status = status;
|
||||
|
||||
|
|
|
@ -397,10 +397,12 @@ static void cdc_acm_int_in(u8_t ep, enum usb_dc_ep_cb_status_code ep_status)
|
|||
*
|
||||
* @return N/A.
|
||||
*/
|
||||
static void cdc_acm_dev_status_cb(enum usb_dc_status_code status)
|
||||
static void cdc_acm_dev_status_cb(enum usb_dc_status_code status, u8_t *param)
|
||||
{
|
||||
struct cdc_acm_dev_data_t * const dev_data = DEV_DATA(cdc_acm_dev);
|
||||
|
||||
ARG_UNUSED(param);
|
||||
|
||||
/* Store the new status */
|
||||
dev_data->usb_status = status;
|
||||
|
||||
|
|
|
@ -811,8 +811,9 @@ static void mass_storage_bulk_in(u8_t ep,
|
|||
*
|
||||
* @return N/A.
|
||||
*/
|
||||
static void mass_storage_status_cb(enum usb_dc_status_code status)
|
||||
static void mass_storage_status_cb(enum usb_dc_status_code status, u8_t *param)
|
||||
{
|
||||
ARG_UNUSED(param);
|
||||
|
||||
/* Check the USB status and do needed action if required */
|
||||
switch (status) {
|
||||
|
|
|
@ -465,8 +465,10 @@ static bool usb_set_configuration(u8_t config_index, u8_t alt_setting)
|
|||
/* skip to next descriptor */
|
||||
p += p[DESC_bLength];
|
||||
}
|
||||
if (usb_dev.status_callback)
|
||||
usb_dev.status_callback(USB_DC_CONFIGURED);
|
||||
|
||||
if (usb_dev.status_callback) {
|
||||
usb_dev.status_callback(USB_DC_CONFIGURED, &config_index);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue