Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions boards/arm/bl654_usb/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,27 @@ config FLASH_LOAD_OFFSET
default 0x1000
depends on !USE_DT_CODE_PARTITION

if USB_DEVICE_STACK
config USB_CDC_ACM
default n if USB_DEVICE_BLUETOOTH

config UART_LINE_CTRL
config BL654_USB_SERIAL_BACKEND_CDCACM
bool "Use CDC ACM UART as backend for BL654 USB adapter"
default y if !USB_DEVICE_BLUETOOTH
help
Use CDC ACM UART as backend for console or shell.

if BL654_USB_SERIAL_BACKEND_CDCACM

config UART_CONSOLE
default CONSOLE

config USB_DEVICE_INITIALIZE_AT_BOOT
default y

endif # USB_DEVICE_STACK
config SHELL_BACKEND_SERIAL_CHECK_DTR
default SHELL

endif #BL654_USB_SERIAL_BACKEND_CDCACM

if IEEE802154

Expand Down
6 changes: 6 additions & 0 deletions subsys/usb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ config USB_WORKQUEUE_PRIORITY
priority. This means that any work handler, once started, won't
be preempted by any other thread until finished.

config USB_DEVICE_INITIALIZE_AT_BOOT
bool "Initialize USB device support at boot"
depends on USB_CDC_ACM
help
Use CDC ACM UART as backend for console, shell, or logging.

source "subsys/usb/class/Kconfig"

endif # USB_DEVICE_STACK
11 changes: 8 additions & 3 deletions subsys/usb/usb_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,8 @@ int usb_enable(usb_dc_status_callback status_cb)
k_mutex_lock(&usb_enable_lock, K_FOREVER);

if (usb_dev.enabled == true) {
ret = 0;
LOG_WRN("USB device support already enabled");
ret = -EALREADY;
goto out;
}

Expand Down Expand Up @@ -1616,7 +1617,7 @@ static int usb_device_init(const struct device *dev)
uint8_t *device_descriptor;

if (usb_dev.enabled == true) {
return 0;
return -EALREADY;
}

/* register device descriptor */
Expand All @@ -1628,7 +1629,11 @@ static int usb_device_init(const struct device *dev)

usb_set_config(device_descriptor);

if (IS_ENABLED(CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT)) {
return usb_enable(NULL);
}

return 0;
}

SYS_INIT(usb_device_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
SYS_INIT(usb_device_init, POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY);