Skip to content

Commit 97ffcc8

Browse files
jfischer-nocfriedt
authored andcommitted
tests: uart_basic_api: add support for CDC ACM UART
Add support for CDC ACM UART. Signed-off-by: Johann Fischer <[email protected]>
1 parent dd465c4 commit 97ffcc8

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CONFIG_USB_DEVICE_STACK=y
2+
CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC ACM UART"
3+
CONFIG_USB_UART_CONSOLE=y
4+
CONFIG_UART_LINE_CTRL=y
5+
CONFIG_TEST_LOGGING_DEFAULTS=n

tests/drivers/uart/uart_basic_api/src/main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* @}
1212
*/
1313

14+
#include <usb/usb_device.h>
1415
#include "test_uart.h"
1516

1617
#ifdef CONFIG_SHELL
@@ -57,6 +58,20 @@ void test_uart_pending(void)
5758

5859
void test_main(void)
5960
{
61+
#if defined(CONFIG_USB_UART_CONSOLE)
62+
const struct device *dev;
63+
uint32_t dtr = 0;
64+
65+
dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
66+
if (!device_is_ready(dev) || usb_enable(NULL)) {
67+
return;
68+
}
69+
70+
while (!dtr) {
71+
uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
72+
k_sleep(K_MSEC(100));
73+
}
74+
#endif
6075
#ifndef CONFIG_SHELL
6176
ztest_test_suite(uart_basic_test,
6277
ztest_unit_test(test_uart_configure),

tests/drivers/uart/uart_basic_api/testcase.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ tests:
1818
tags: drivers
1919
filter: CONFIG_UART_CONSOLE
2020
harness: keyboard
21+
drivers.uart.cdc_acm:
22+
extra_args: OVERLAY_CONFIG="overlay-usb.conf"
23+
DTC_OVERLAY_FILE="usb.overlay"
24+
tags: drivers usb
25+
filter: CONFIG_UART_CONSOLE
26+
depends_on: usb_device
27+
harness: keyboard
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,console = &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)