samples: wpan_serial: get CDC ACM UART device from devicetree

Add app.overlay which contains  cdc-acm-uart node.
Rework sample to get CDC ACM UART device from devicetree.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
Johann Fischer 2021-07-22 14:41:08 +02:00 committed by Christopher Friedt
parent 5e3319f091
commit a9a512de66
3 changed files with 15 additions and 4 deletions

View File

@ -0,0 +1,12 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
&zephyr_udc0 {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
label = "CDC_ACM_0";
};
};

View File

@ -1,6 +1,5 @@
CONFIG_GPIO=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_CDC_ACM=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y

View File

@ -528,9 +528,9 @@ void main(void)
LOG_INF("Starting wpan_serial application");
dev = device_get_binding("CDC_ACM_0");
if (!dev) {
LOG_ERR("CDC ACM device not found");
dev = DEVICE_DT_GET_ONE(zephyr_cdc_acm_uart);
if (!device_is_ready(dev)) {
LOG_ERR("CDC ACM device not ready");
return;
}