samples: sensortile_box: get chosen console device from devicetree
Add app.overlay which contains chosen 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:
parent
f460848002
commit
43d214bf5b
3 changed files with 20 additions and 4 deletions
18
samples/boards/sensortile_box/app.overlay
Normal file
18
samples/boards/sensortile_box/app.overlay
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/ {
|
||||
chosen {
|
||||
zephyr,console = &cdc_acm_uart0;
|
||||
};
|
||||
};
|
||||
|
||||
&zephyr_udc0 {
|
||||
cdc_acm_uart0: cdc_acm_uart0 {
|
||||
compatible = "zephyr,cdc-acm-uart";
|
||||
label = "CDC_ACM_0";
|
||||
};
|
||||
};
|
|
@ -32,5 +32,4 @@ CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC SensorTile.box"
|
|||
CONFIG_USB_UART_CONSOLE=y
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
CONFIG_UART_LINE_CTRL=y
|
||||
CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0"
|
||||
CONFIG_CBPRINTF_FP_SUPPORT=y
|
||||
|
|
|
@ -250,14 +250,13 @@ static void iis3dhhc_config(const struct device *iis3dhhc)
|
|||
void main(void)
|
||||
{
|
||||
static const struct device *led0, *led1;
|
||||
const struct device *dev = device_get_binding(
|
||||
CONFIG_UART_CONSOLE_ON_DEV_NAME);
|
||||
const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
|
||||
int i, on = 1;
|
||||
int cnt = 1;
|
||||
uint32_t dtr = 0;
|
||||
|
||||
/* Application must enable USB by itself */
|
||||
if (usb_enable(NULL)) {
|
||||
if (!device_is_ready(dev) || usb_enable(NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue