Skip to content

Commit e1d5416

Browse files
jfischer-nocfriedt
authored andcommitted
samples: shell: get CDC ACM UART device from devicetree
Add usb.overlay which contains chosen node and cdc-acm-uart node. Change sample to get CDC ACM UART device from devicetree. Signed-off-by: Johann Fischer <[email protected]>
1 parent 0f5490a commit e1d5416

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
CONFIG_USB_DEVICE_STACK=y
2-
CONFIG_USB_DEVICE_PRODUCT="Zephyr USB console sample"
2+
CONFIG_USB_DEVICE_PRODUCT="Zephyr USB shell sample"
33
CONFIG_USB_UART_CONSOLE=y
4-
CONFIG_UART_INTERRUPT_DRIVEN=y
54
CONFIG_UART_LINE_CTRL=y
6-
CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0"
75
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51

samples/subsys/shell/shell_module/sample.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ tests:
1515
harness: keyboard
1616
min_ram: 40
1717
extra_args: OVERLAY_CONFIG="overlay-usb.conf"
18+
DTC_OVERLAY_FILE="usb.overlay"
1819
sample.shell.shell_module.minimal:
1920
filter: ( CONFIG_SERIAL and CONFIG_UART_SHELL_ON_DEV_NAME )
2021
tags: shell

samples/subsys/shell/shell_module/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ void main(void)
338338
const struct device *dev;
339339
uint32_t dtr = 0;
340340

341-
dev = device_get_binding(CONFIG_UART_SHELL_ON_DEV_NAME);
342-
if (dev == NULL || usb_enable(NULL)) {
341+
dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart));
342+
if (!device_is_ready(dev) || usb_enable(NULL)) {
343343
return;
344344
}
345345

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2021 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,shell-uart = &cdc_acm_uart0;
10+
};
11+
};
12+
13+
&zephyr_udc0 {
14+
cdc_acm_uart0: cdc_acm_uart0 {
15+
compatible = "zephyr,cdc-acm-uart";
16+
label = "CDC_ACM_0";
17+
};
18+
};

0 commit comments

Comments
 (0)