diff --git a/sys/include/stdio_uart.h b/sys/include/stdio_uart.h index 7935ccda90..6fc55de01b 100644 --- a/sys/include/stdio_uart.h +++ b/sys/include/stdio_uart.h @@ -111,13 +111,6 @@ extern "C" { #define STDIO_UART_BAUDRATE (115200) #endif -#ifndef STDIO_UART_RX_BUFSIZE -/** - * @brief Buffer size for STDIO - */ -#define STDIO_UART_RX_BUFSIZE (64) -#endif - #ifdef __cplusplus } #endif diff --git a/sys/stdio_uart/stdio_uart.c b/sys/stdio_uart/stdio_uart.c index 5568d3e815..f7b8109687 100644 --- a/sys/stdio_uart/stdio_uart.c +++ b/sys/stdio_uart/stdio_uart.c @@ -31,51 +31,33 @@ #include #include "board.h" -#include "isrpipe.h" #include "kernel_defines.h" #include "periph/uart.h" +#include "stdio_base.h" #include "stdio_uart.h" #define ENABLE_DEBUG 0 #include "debug.h" -static uint8_t _rx_buf_mem[STDIO_UART_RX_BUFSIZE]; -isrpipe_t stdio_uart_isrpipe = ISRPIPE_INIT(_rx_buf_mem); - static void _isrpipe_write_one_wrapper(void *arg, uint8_t value) { isrpipe_write_one(arg, value); } -void stdio_init(void) +static void _init(void) { uart_rx_cb_t cb = NULL; void *arg = NULL; if (IS_USED(MODULE_STDIO_UART_RX)) { cb = _isrpipe_write_one_wrapper; - arg = &stdio_uart_isrpipe; + arg = &stdin_isrpipe; } uart_init(STDIO_UART_DEV, STDIO_UART_BAUDRATE, cb, arg); } -#if IS_USED(MODULE_STDIO_AVAILABLE) -int stdio_available(void) -{ - return tsrb_avail(&stdio_uart_isrpipe.tsrb); -} -#endif - -ssize_t stdio_read(void* buffer, size_t count) -{ - if (IS_USED(MODULE_STDIO_UART_RX)) { - return (ssize_t)isrpipe_read(&stdio_uart_isrpipe, buffer, count); - } - return -ENOTSUP; -} - -ssize_t stdio_write(const void *buffer, size_t len) +static ssize_t _write(const void *buffer, size_t len) { ssize_t result = len; if (IS_USED(MODULE_STDIO_UART_ONLCR)) { @@ -101,3 +83,10 @@ ssize_t stdio_write(const void *buffer, size_t len) } return result; } + +static void _detach(void) +{ + uart_poweroff(STDIO_UART_DEV); +} + +STDIO_PROVIDER(STDIO_UART, _init, _detach, _write)