tests: uart_basic_api: add support for CDC ACM UART
Add support for CDC ACM UART. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
parent
dd465c48cb
commit
97ffcc8a7a
4 changed files with 45 additions and 0 deletions
5
tests/drivers/uart/uart_basic_api/overlay-usb.conf
Normal file
5
tests/drivers/uart/uart_basic_api/overlay-usb.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
CONFIG_USB_DEVICE_STACK=y
|
||||
CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC ACM UART"
|
||||
CONFIG_USB_UART_CONSOLE=y
|
||||
CONFIG_UART_LINE_CTRL=y
|
||||
CONFIG_TEST_LOGGING_DEFAULTS=n
|
|
@ -11,6 +11,7 @@
|
|||
* @}
|
||||
*/
|
||||
|
||||
#include <usb/usb_device.h>
|
||||
#include "test_uart.h"
|
||||
|
||||
#ifdef CONFIG_SHELL
|
||||
|
@ -57,6 +58,20 @@ void test_uart_pending(void)
|
|||
|
||||
void test_main(void)
|
||||
{
|
||||
#if defined(CONFIG_USB_UART_CONSOLE)
|
||||
const struct device *dev;
|
||||
uint32_t dtr = 0;
|
||||
|
||||
dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
|
||||
if (!device_is_ready(dev) || usb_enable(NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (!dtr) {
|
||||
uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
|
||||
k_sleep(K_MSEC(100));
|
||||
}
|
||||
#endif
|
||||
#ifndef CONFIG_SHELL
|
||||
ztest_test_suite(uart_basic_test,
|
||||
ztest_unit_test(test_uart_configure),
|
||||
|
|
|
@ -18,3 +18,10 @@ tests:
|
|||
tags: drivers
|
||||
filter: CONFIG_UART_CONSOLE
|
||||
harness: keyboard
|
||||
drivers.uart.cdc_acm:
|
||||
extra_args: OVERLAY_CONFIG="overlay-usb.conf"
|
||||
DTC_OVERLAY_FILE="usb.overlay"
|
||||
tags: drivers usb
|
||||
filter: CONFIG_UART_CONSOLE
|
||||
depends_on: usb_device
|
||||
harness: keyboard
|
||||
|
|
18
tests/drivers/uart/uart_basic_api/usb.overlay
Normal file
18
tests/drivers/uart/uart_basic_api/usb.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";
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue