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
9 changes: 3 additions & 6 deletions drivers/usb/udc/udc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ static void ep_update_mps(const struct device *dev,
uint16_t *const mps)
{
struct udc_device_caps caps = udc_caps(dev);
const uint16_t spec_iso_mps = caps.hs ? 1024 : 1023;
const uint16_t spec_int_mps = caps.hs ? 1024 : 64;
const uint16_t spec_bulk_mps = caps.hs ? 512 : 64;

Expand All @@ -269,12 +268,10 @@ static void ep_update_mps(const struct device *dev,
case USB_EP_TYPE_INTERRUPT:
*mps = MIN(cfg->caps.mps, spec_int_mps);
break;
case USB_EP_TYPE_ISO:
*mps = MIN(cfg->caps.mps, spec_iso_mps);
break;
case USB_EP_TYPE_CONTROL:
*mps = 64U;
break;
__fallthrough;
case USB_EP_TYPE_ISO:
__fallthrough;
default:
return;
}
Expand Down
6 changes: 6 additions & 0 deletions samples/bluetooth/hci_usb/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ tests:
tags: usb bluetooth
# FIXME: exclude due to build error
platform_exclude: 96b_carbon
sample.bluetooth.hci_usb.device_next:
harness: bluetooth
depends_on: usb_device ble
tags: usb bluetooth
extra_args: CONF_FILE="usbd_next_prj.conf"
platform_allow: nrf52840dk_nrf52840
68 changes: 68 additions & 0 deletions samples/bluetooth/hci_usb/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,80 @@
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#include <zephyr/usb/usb_device.h>
#include <zephyr/usb/usbd.h>

#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
USBD_CONFIGURATION_DEFINE(config_1,
USB_SCD_SELF_POWERED,
200);

USBD_DESC_LANG_DEFINE(sample_lang);
USBD_DESC_STRING_DEFINE(sample_mfr, "ZEPHYR", 1);
USBD_DESC_STRING_DEFINE(sample_product, "Zephyr USBD BT HCI", 2);
USBD_DESC_STRING_DEFINE(sample_sn, "0123456789ABCDEF", 3);

USBD_DEVICE_DEFINE(sample_usbd,
DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0)),
0x2fe3, 0x000b);

static int enable_usb_device_next(void)
{
int err;

err = usbd_add_descriptor(&sample_usbd, &sample_lang);
if (err) {
return err;
}

err = usbd_add_descriptor(&sample_usbd, &sample_mfr);
if (err) {
return err;
}

err = usbd_add_descriptor(&sample_usbd, &sample_product);
if (err) {
return err;
}

err = usbd_add_descriptor(&sample_usbd, &sample_sn);
if (err) {
return err;
}

err = usbd_add_configuration(&sample_usbd, &config_1);
if (err) {
return err;
}

err = usbd_register_class(&sample_usbd, "bt_hci_0", 1);
if (err) {
return err;
}

err = usbd_init(&sample_usbd);
if (err) {
return err;
}

err = usbd_enable(&sample_usbd);
if (err) {
return err;
}

return 0;
}
#endif /* CONFIG_USB_DEVICE_STACK_NEXT */

void main(void)
{
int ret;

#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
ret = enable_usb_device_next();
#else
ret = usb_enable(NULL);
#endif

if (ret != 0) {
printk("Failed to enable USB");
return;
Expand Down
15 changes: 15 additions & 0 deletions samples/bluetooth/hci_usb/usbd_next_prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CONFIG_STDOUT_CONSOLE=y
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y

CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_USBD_BT_HCI=y

CONFIG_LOG=y
CONFIG_USBD_LOG_LEVEL_WRN=y
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
5 changes: 5 additions & 0 deletions subsys/usb/device_next/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ zephyr_library_sources_ifdef(
class/usbd_cdc_acm.c
)

zephyr_library_sources_ifdef(
CONFIG_USBD_BT_HCI
class/bt_hci.c
)

zephyr_linker_sources(DATA_SECTIONS usbd_data.ld)
1 change: 1 addition & 0 deletions subsys/usb/device_next/class/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

rsource "Kconfig.loopback"
rsource "Kconfig.cdc_acm"
rsource "Kconfig.bt"
35 changes: 35 additions & 0 deletions subsys/usb/device_next/class/Kconfig.bt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config USBD_BT_HCI
bool "Bluetooth HCI USB Transport Layer"
select BT
select BT_HCI_RAW
help
Bluetooth HCI USB Transport Layer

if USBD_BT_HCI

config USBD_BT_HCI_TX_THREAD_PRIORITY
int "TX thread priority"
default 8
help
Bluetooth HCI USB Transport Layer TX thread priority.

config USBD_BT_HCI_TX_STACK_SIZE
int "TX thread stack size"
default 512
help
Bluetooth HCI USB Transport Layer TX thread stack size.

config USBD_BT_HCI_RX_THREAD_PRIORITY
int "RX thread priority"
default 8
help
Bluetooth HCI USB Transport Layer RX thread priority.

module = USBD_BT_HCI
module-str = usbd bt hci
source "subsys/logging/Kconfig.template.log_config"

endif
Loading