usb: api: Add user device status callback

By this commit user gets possibility to register USB
device satutus callback. This callback represents device state
and is added so user could know what happend to USB device.

Callback is registered by providing it to usb_enable()
USB api is extended by this callback handler.

Samples using using USB are by default provide no callback
and the usb_enable() is called with NULL parameter.

Status callback registered by hid class is deleted as now
USB device has global callback for all classes within device.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit is contained in:
Emil Obalski 2019-11-05 15:24:45 +01:00 committed by Carles Cufí
commit 2128750138
18 changed files with 36 additions and 27 deletions

View file

@ -82,7 +82,6 @@ struct hid_ops {
#ifdef CONFIG_ENABLE_HID_INT_OUT_EP
hid_int_ready_callback int_out_ready;
#endif
usb_dc_status_callback status_cb;
};
/* HID Report Definitions */

View file

@ -227,9 +227,12 @@ int usb_deconfig(void);
* before invoking this, so that any data or events on the bus are processed
* correctly by the associated class handling code.
*
* @param[in] status_cb Callback registered by user to notify
* about USB device controller state.
*
* @return 0 on success, negative errno code on fail.
*/
int usb_enable(void);
int usb_enable(usb_dc_status_callback status_cb);
/**
* @brief Disable the USB device