From e7ea668a7f5e5be3c632b192d122028878db580d Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 21 Nov 2024 14:01:01 +0100 Subject: [PATCH 1/2] tests/periph/selftest_shield: release UART after test Calling `uart_poweroff()` when done with the UART test allows sharing the underlying hardware e.g. to provide other peripheral interfaces. One example of this would be the SERCOM3 on the Adafruit Metro M4 Express that is used to provide UART on D1/D0 and SPI on D11/D12/D13. --- tests/periph/selftest_shield/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/periph/selftest_shield/main.c b/tests/periph/selftest_shield/main.c index ad4316c95f..9ab2f7c4a5 100644 --- a/tests/periph/selftest_shield/main.c +++ b/tests/periph/selftest_shield/main.c @@ -790,6 +790,9 @@ static bool periph_uart_rxtx_test(uint32_t symbolrate, uint32_t timer_freq) failed |= TEST(memcmp(testdata, serial_buf.data, sizeof(serial_buf.data)) == 0); failed |= TEST(serial_buf.pos == sizeof(testdata)); + /* disable UART again, in case it is a shared peripheral */ + uart_poweroff(UART_TEST_DEV); + return failed; } From a51d4bd7d9491bdd78e6d98906cc6151fbdb3bd4 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 21 Nov 2024 20:23:30 +0100 Subject: [PATCH 2/2] tests/periph/selftest_shield: fix logic to enable UART test We cannot use the D0/D1 UART if it is also used for STDIO. However, the logic did not take into account whether `stdio_uart` was used at all. This fixes the issue. --- tests/periph/selftest_shield/main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/periph/selftest_shield/main.c b/tests/periph/selftest_shield/main.c index 9ab2f7c4a5..1cb19dff9e 100644 --- a/tests/periph/selftest_shield/main.c +++ b/tests/periph/selftest_shield/main.c @@ -55,10 +55,14 @@ /* In order to run the periph_uart test all of the following needs to be true: * - periph_uart needs to be used * - an I/O mapping for the UART at D0/D1 needs to be provided - * - this UART dev is not busy with stdio + * - this UART dev is not busy with stdio (either not using `stdio_uart` or a different UART is used for stdio) */ #if defined(ARDUINO_UART_D0D1) && defined(MODULE_PERIPH_UART) -# define ENABLE_UART_TEST (STDIO_UART_DEV != ARDUINO_UART_D0D1) +# if MODULE_STDIO_UART +# define ENABLE_UART_TEST (STDIO_UART_DEV != ARDUINO_UART_D0D1) +# else +# define ENABLE_UART_TEST 1 +# endif # define UART_TEST_DEV ARDUINO_UART_D0D1 #else # define ENABLE_UART_TEST 0