samples: bluetooth: hci_usb: Use common USB sample initialization
Convert hci_usb sample to use common USB sample initialization code. Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This commit is contained in:
parent
db23787537
commit
d05d51d869
|
@ -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)
|
||||
|
|
9
samples/bluetooth/hci_usb/Kconfig
Normal file
9
samples/bluetooth/hci_usb/Kconfig
Normal file
|
@ -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"
|
|
@ -10,65 +10,18 @@
|
|||
#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_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 <sample_usbd.h>
|
||||
|
||||
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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue