Commit 21287501 authored by Emil Obalski's avatar Emil Obalski Committed by Carles Cufi
Browse files

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: default avatarEmil Obalski <emil.obalski@nordicsemi.no>
parent d65027d8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -599,7 +599,7 @@ static int uart_console_init(struct device *arg)
#if defined(CONFIG_USB_UART_CONSOLE) && defined(CONFIG_USB_UART_DTR_WAIT)
	int ret;

	ret = usb_enable();
	ret = usb_enable(NULL);
	if (ret != 0) {
		return ret;
	}
+0 −1
Original line number Diff line number Diff line
@@ -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 */
+4 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ void main(void)
{
	int ret;

	ret = usb_enable();
	ret = usb_enable(NULL);
	if (ret != 0) {
		printk("Failed to enable USB");
		return;
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ int usb_transport_init(usb_transport_receive_callback_t callback)

	receive_data_cb = callback;

	ret = usb_enable();
	ret = usb_enable(NULL);
	if (ret != 0) {
		LOG_ERR("Failed to enable USB");
		return;
Loading