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 <johann.fischer@nordicsemi.no>
This commit is contained in:
parent
0f5490a004
commit
e1d5416df3
4 changed files with 22 additions and 5 deletions
|
@ -1,7 +1,5 @@
|
||||||
CONFIG_USB_DEVICE_STACK=y
|
CONFIG_USB_DEVICE_STACK=y
|
||||||
CONFIG_USB_DEVICE_PRODUCT="Zephyr USB console sample"
|
CONFIG_USB_DEVICE_PRODUCT="Zephyr USB shell sample"
|
||||||
CONFIG_USB_UART_CONSOLE=y
|
CONFIG_USB_UART_CONSOLE=y
|
||||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
|
||||||
CONFIG_UART_LINE_CTRL=y
|
CONFIG_UART_LINE_CTRL=y
|
||||||
CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0"
|
|
||||||
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51
|
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51
|
||||||
|
|
|
@ -15,6 +15,7 @@ tests:
|
||||||
harness: keyboard
|
harness: keyboard
|
||||||
min_ram: 40
|
min_ram: 40
|
||||||
extra_args: OVERLAY_CONFIG="overlay-usb.conf"
|
extra_args: OVERLAY_CONFIG="overlay-usb.conf"
|
||||||
|
DTC_OVERLAY_FILE="usb.overlay"
|
||||||
sample.shell.shell_module.minimal:
|
sample.shell.shell_module.minimal:
|
||||||
filter: ( CONFIG_SERIAL and CONFIG_UART_SHELL_ON_DEV_NAME )
|
filter: ( CONFIG_SERIAL and CONFIG_UART_SHELL_ON_DEV_NAME )
|
||||||
tags: shell
|
tags: shell
|
||||||
|
|
|
@ -338,8 +338,8 @@ void main(void)
|
||||||
const struct device *dev;
|
const struct device *dev;
|
||||||
uint32_t dtr = 0;
|
uint32_t dtr = 0;
|
||||||
|
|
||||||
dev = device_get_binding(CONFIG_UART_SHELL_ON_DEV_NAME);
|
dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart));
|
||||||
if (dev == NULL || usb_enable(NULL)) {
|
if (!device_is_ready(dev) || usb_enable(NULL)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
samples/subsys/shell/shell_module/usb.overlay
Normal file
18
samples/subsys/shell/shell_module/usb.overlay
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Nordic Semiconductor ASA
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
chosen {
|
||||||
|
zephyr,shell-uart = &cdc_acm_uart0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
&zephyr_udc0 {
|
||||||
|
cdc_acm_uart0: cdc_acm_uart0 {
|
||||||
|
compatible = "zephyr,cdc-acm-uart";
|
||||||
|
label = "CDC_ACM_0";
|
||||||
|
};
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue