diff --git a/cpu/atmega_common/periph/uart.c b/cpu/atmega_common/periph/uart.c index 63757a24313ec13fcf9360db29df3c1d79938bde..c1abacd068aecfb72ad9ae314432ae58810e0308 100644 --- a/cpu/atmega_common/periph/uart.c +++ b/cpu/atmega_common/periph/uart.c @@ -152,6 +152,18 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len) } } +void uart_poweron(uart_t uart) +{ + (void)uart; + /* not implemented (yet) */ +} + +void uart_poweroff(uart_t uart) +{ + (void)uart; + /* not implemented (yet) */ +} + static inline void isr_handler(int num) { isr_ctx[num].rx_cb(isr_ctx[num].arg, dev[num]->DR); diff --git a/cpu/kinetis/periph/uart.c b/cpu/kinetis/periph/uart.c index 50d8529819cbad093ad2904ef8ff840f1e5b2e9d..230b4a67b59ab3c77eb07e77560769c75c515b79 100644 --- a/cpu/kinetis/periph/uart.c +++ b/cpu/kinetis/periph/uart.c @@ -131,6 +131,18 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) return UART_OK; } +void uart_poweron(uart_t uart) +{ + (void)uart; + /* not implemented (yet) */ +} + +void uart_poweroff(uart_t uart) +{ + (void)uart; + /* not implemented (yet) */ +} + #if KINETIS_HAVE_UART && KINETIS_HAVE_LPUART /* Dispatch function to pass to the proper write function depending on UART type * This function is only used when the CPU supports both UART and LPUART. */ diff --git a/cpu/lpc2387/periph/uart.c b/cpu/lpc2387/periph/uart.c index 555560f6507341e004033e3c718f1824bfd6b493..59f91e39cf4bdba82e5d1d4a8604b1ea5985cac9 100644 --- a/cpu/lpc2387/periph/uart.c +++ b/cpu/lpc2387/periph/uart.c @@ -98,3 +98,15 @@ void UART0_IRQHandler(void) VICVectAddr = 0; /* Acknowledge Interrupt */ } + +void uart_poweron(uart_t uart) +{ + (void)uart; + /* not implemented (yet) */ +} + +void uart_poweroff(uart_t uart) +{ + (void)uart; + /* not implemented (yet) */ +} diff --git a/cpu/native/periph/uart.c b/cpu/native/periph/uart.c index 41a677b5543fd31291c365417fad9654ec92735c..7b58571706111be4aa0bcff7f82774f1b41b5001 100644 --- a/cpu/native/periph/uart.c +++ b/cpu/native/periph/uart.c @@ -177,3 +177,15 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len) _native_write(tty_fds[uart], data, len); } + +void uart_poweron(uart_t uart) +{ + (void)uart; + /* not implemented (yet) */ +} + +void uart_poweroff(uart_t uart) +{ + (void)uart; + /* not implemented (yet) */ +} diff --git a/tests/periph_uart/Makefile b/tests/periph_uart/Makefile index d784a42882ef53b584f1b7278f51323bee2d13c7..7fcba9a9a58899ccf20c3cfb8f0832ca2cf796e4 100644 --- a/tests/periph_uart/Makefile +++ b/tests/periph_uart/Makefile @@ -5,5 +5,6 @@ BOARD_INSUFFICIENT_MEMORY := nucleo32-f031 FEATURES_REQUIRED = periph_uart USEMODULE += shell +USEMODULE += xtimer include $(RIOTBASE)/Makefile.include diff --git a/tests/periph_uart/main.c b/tests/periph_uart/main.c index 1657cf129f1f9ad063c5aaa5b5c40b3c0326e5b7..39a4c64026af8f8a99fea85bc499b904db7c3e4f 100644 --- a/tests/periph_uart/main.c +++ b/tests/periph_uart/main.c @@ -29,6 +29,7 @@ #include "ringbuffer.h" #include "periph/uart.h" #include "uart_stdio.h" +#include "xtimer.h" #define SHELL_BUFSIZE (128U) #define UART_BUFSIZE (128U) @@ -36,6 +37,8 @@ #define PRINTER_PRIO (THREAD_PRIORITY_MAIN - 1) #define PRINTER_TYPE (0xabcd) +#define POWEROFF_DELAY (250U * US_PER_MS) /* quarter of a second */ + #ifndef UART_STDIO_DEV #define UART_STDIO_DEV (UART_UNDEF) #endif @@ -107,6 +110,15 @@ static void *printer(void *arg) return NULL; } +static void sleep_test(int num, uart_t uart) +{ + printf("UARD_DEV(%i): test uart_poweron() and uart_poweroff() -> ", num); + uart_poweroff(uart); + xtimer_usleep(POWEROFF_DELAY); + uart_poweron(uart); + puts("[OK]"); +} + static int cmd_init(int argc, char **argv) { int dev, res; @@ -134,6 +146,11 @@ static int cmd_init(int argc, char **argv) return 1; } printf("Successfully initialized UART_DEV(%i)\n", dev); + + /* also test if poweron() and poweroff() work (or at least don't break + * anything) */ + sleep_test(dev, UART_DEV(dev)); + return 0; } @@ -178,7 +195,13 @@ int main(void) "being printed to STDOUT\n\n" "NOTE: all strings need to be '\\n' terminated!\n"); - puts("UART INFO:"); + /* do sleep test for UART used as STDIO. There is a possibility that the + * value given in UART_STDIO_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(UART_STDIO_DEV, UART_STDIO_DEV); + + puts("\nUART INFO:"); printf("Available devices: %i\n", UART_NUMOF); printf("UART used for STDIO (the shell): UART_DEV(%i)\n\n", UART_STDIO_DEV);