diff --git a/samples/bluetooth/hci_usb/CMakeLists.txt b/samples/bluetooth/hci_usb/CMakeLists.txt index 714d9c369a..9abfd99785 100644 --- a/samples/bluetooth/hci_usb/CMakeLists.txt +++ b/samples/bluetooth/hci_usb/CMakeLists.txt @@ -4,4 +4,5 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(hci_usb) +include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake) target_sources(app PRIVATE src/main.c) diff --git a/samples/bluetooth/hci_usb/Kconfig b/samples/bluetooth/hci_usb/Kconfig new file mode 100644 index 0000000000..825eba9059 --- /dev/null +++ b/samples/bluetooth/hci_usb/Kconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2024 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +# Source common USB sample options used to initialize new experimental USB +# device stack. The scope of these options is limited to USB samples in project +# tree, you cannot use them in your own application. +source "samples/subsys/usb/common/Kconfig.sample_usbd" + +source "Kconfig.zephyr" diff --git a/samples/bluetooth/hci_usb/src/main.c b/samples/bluetooth/hci_usb/src/main.c index 429358fe8e..8e91caadd3 100644 --- a/samples/bluetooth/hci_usb/src/main.c +++ b/samples/bluetooth/hci_usb/src/main.c @@ -10,65 +10,18 @@ #include #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_MANUFACTURER_DEFINE(sample_mfr, "ZEPHYR"); -USBD_DESC_PRODUCT_DEFINE(sample_product, "Zephyr USBD BT HCI"); -USBD_DESC_SERIAL_NUMBER_DEFINE(sample_sn, "0123456789ABCDEF"); - - -USBD_DEVICE_DEFINE(sample_usbd, - DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0)), - 0x2fe3, 0x000b); +#include static int enable_usb_device_next(void) { - int err; + struct usbd_contex *sample_usbd = sample_usbd_init_device(); - err = usbd_add_descriptor(&sample_usbd, &sample_lang); - if (err) { - return err; + if (sample_usbd == NULL) { + printk("Failed to initialize USB device"); + return -ENODEV; } - 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; + return usbd_enable(sample_usbd); } #endif /* CONFIG_USB_DEVICE_STACK_NEXT */ diff --git a/samples/bluetooth/hci_usb/usbd_next_prj.conf b/samples/bluetooth/hci_usb/usbd_next_prj.conf index e3071e1576..e1daa84f47 100644 --- a/samples/bluetooth/hci_usb/usbd_next_prj.conf +++ b/samples/bluetooth/hci_usb/usbd_next_prj.conf @@ -8,6 +8,8 @@ CONFIG_BT=y CONFIG_BT_HCI_RAW=y CONFIG_USB_DEVICE_STACK_NEXT=y +CONFIG_SAMPLE_USBD_PID=0x000b +CONFIG_SAMPLE_USBD_PRODUCT="Zephyr USBD BT HCI" CONFIG_USBD_BT_HCI=y CONFIG_LOG=y