Remove option CONFIG_USB_UART_CONSOLE where it has no influence or enable CONFIG_SHELL_BACKEND_SERIAL_CHECK_DTR without taking a detour through CONFIG_USB_UART_CONSOLE. Check the compatibility of chosen property instead of usage of CONFIG_USB_UART_CONSOLE option. Align how to wait for the readiness of CDC ACM UART. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
87 lines
2.1 KiB
C
87 lines
2.1 KiB
C
/*
|
|
* Copyright (c) 2016 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @addtogroup t_driver_uart
|
|
* @{
|
|
* @defgroup t_uart_basic test_uart_basic_operations
|
|
* @}
|
|
*/
|
|
|
|
#include <usb/usb_device.h>
|
|
#include "test_uart.h"
|
|
|
|
#ifdef CONFIG_SHELL
|
|
TC_CMD_DEFINE(test_uart_configure)
|
|
TC_CMD_DEFINE(test_uart_config_get)
|
|
TC_CMD_DEFINE(test_uart_fifo_read)
|
|
TC_CMD_DEFINE(test_uart_fifo_fill)
|
|
TC_CMD_DEFINE(test_uart_poll_in)
|
|
TC_CMD_DEFINE(test_uart_poll_out)
|
|
TC_CMD_DEFINE(test_uart_pending)
|
|
|
|
SHELL_CMD_REGISTER(test_uart_configure, NULL, NULL,
|
|
TC_CMD_ITEM(test_uart_configure));
|
|
SHELL_CMD_REGISTER(test_uart_config_get, NULL, NULL,
|
|
TC_CMD_ITEM(test_uart_config_get));
|
|
SHELL_CMD_REGISTER(test_uart_fifo_read, NULL, NULL,
|
|
TC_CMD_ITEM(test_uart_fifo_read));
|
|
SHELL_CMD_REGISTER(test_uart_fifo_fill, NULL, NULL,
|
|
TC_CMD_ITEM(test_uart_fifo_fill));
|
|
SHELL_CMD_REGISTER(test_uart_poll_in, NULL, NULL,
|
|
TC_CMD_ITEM(test_uart_poll_in));
|
|
SHELL_CMD_REGISTER(test_uart_poll_out, NULL, NULL,
|
|
TC_CMD_ITEM(test_uart_poll_out));
|
|
SHELL_CMD_REGISTER(test_uart_pending, NULL, NULL,
|
|
TC_CMD_ITEM(test_uart_pending));
|
|
#endif
|
|
|
|
#ifndef CONFIG_UART_INTERRUPT_DRIVEN
|
|
void test_uart_fifo_fill(void)
|
|
{
|
|
ztest_test_skip();
|
|
}
|
|
|
|
void test_uart_fifo_read(void)
|
|
{
|
|
ztest_test_skip();
|
|
}
|
|
|
|
void test_uart_pending(void)
|
|
{
|
|
ztest_test_skip();
|
|
}
|
|
#endif
|
|
|
|
void test_main(void)
|
|
{
|
|
#if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart)
|
|
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),
|
|
ztest_unit_test(test_uart_config_get),
|
|
ztest_unit_test(test_uart_fifo_fill),
|
|
ztest_unit_test(test_uart_fifo_read),
|
|
ztest_unit_test(test_uart_poll_in),
|
|
ztest_unit_test(test_uart_poll_out),
|
|
ztest_unit_test(test_uart_pending));
|
|
ztest_run_test_suite(uart_basic_test);
|
|
#endif
|
|
}
|