Add app.overlay which contains chosen node and cdc-acm-uart node. Rework sample to get CDC ACM UART device from devicetree. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
36 lines
743 B
C
36 lines
743 B
C
/*
|
|
* Copyright (c) 2016 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr.h>
|
|
#include <sys/printk.h>
|
|
#include <usb/usb_device.h>
|
|
#include <drivers/uart.h>
|
|
|
|
BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart),
|
|
"Console device is not ACM CDC UART device");
|
|
|
|
void main(void)
|
|
{
|
|
const struct device *dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
|
|
uint32_t dtr = 0;
|
|
|
|
if (usb_enable(NULL)) {
|
|
return;
|
|
}
|
|
|
|
/* Poll if the DTR flag was set */
|
|
while (!dtr) {
|
|
uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
|
|
/* Give CPU resources to low priority threads. */
|
|
k_sleep(K_MSEC(100));
|
|
}
|
|
|
|
while (1) {
|
|
printk("Hello World! %s\n", CONFIG_ARCH);
|
|
k_sleep(K_SECONDS(1));
|
|
}
|
|
}
|