From aac593a7c9010ca97277b77552c8cafc648d6cc5 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sun, 26 Apr 2020 20:30:49 +0200 Subject: [PATCH] tests/periph_uart: fix for !stdio_uart Only include `stdio_uart.h` if stdio over UART is used. This makes it possible to use the default stdio UART0 for the test. This is needed if e.g. the default stdio of a board is USB CDC ACM. --- tests/periph_uart/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/periph_uart/main.c b/tests/periph_uart/main.c index e0f9cf88f9..90afb22167 100644 --- a/tests/periph_uart/main.c +++ b/tests/periph_uart/main.c @@ -28,9 +28,12 @@ #include "msg.h" #include "ringbuffer.h" #include "periph/uart.h" -#include "stdio_uart.h" #include "xtimer.h" +#ifdef MODULE_STDIO_UART +#include "stdio_uart.h" +#endif + #ifndef SHELL_BUFSIZE #define SHELL_BUFSIZE (128U) #endif @@ -283,11 +286,15 @@ int main(void) * value given in STDIO_UART_DEV is not a numeral (depends on the CPU * implementation), so we rather break the output by printing a * non-numerical value instead of breaking the UART device descriptor */ - sleep_test(STDIO_UART_DEV, STDIO_UART_DEV); + if (STDIO_UART_DEV != UART_UNDEF) { + sleep_test(STDIO_UART_DEV, STDIO_UART_DEV); + } puts("\nUART INFO:"); printf("Available devices: %i\n", UART_NUMOF); - printf("UART used for STDIO (the shell): UART_DEV(%i)\n\n", STDIO_UART_DEV); + if (STDIO_UART_DEV != UART_UNDEF) { + printf("UART used for STDIO (the shell): UART_DEV(%i)\n\n", STDIO_UART_DEV); + } /* initialize ringbuffers */ for (unsigned i = 0; i < UART_NUMOF; i++) {