1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #11310 from OTAkeys/make_uart_stdio_rx_optional

sys: make uart_stdio RX optional (attempt #2)
This commit is contained in:
Kaspar Schleiser 2019-05-09 13:32:05 +02:00 committed by GitHub
commit a9f1a85f10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 5 deletions

View File

@ -397,8 +397,18 @@ ifneq (,$(filter stdio_rtt,$(USEMODULE)))
USEMODULE += xtimer
endif
ifneq (,$(filter stdio_uart,$(USEMODULE)))
ifneq (,$(filter shell,$(USEMODULE)))
ifneq (,$(filter stdio_uart,$(USEMODULE)))
USEMODULE += stdio_uart_rx
endif
endif
ifneq (,$(filter stdio_uart_rx,$(USEMODULE)))
USEMODULE += isrpipe
USEMODULE += stdio_uart
endif
ifneq (,$(filter stdio_uart,$(USEMODULE)))
FEATURES_REQUIRED += periph_uart
endif

View File

@ -69,6 +69,7 @@ PSEUDOMODULES += sock
PSEUDOMODULES += sock_ip
PSEUDOMODULES += sock_tcp
PSEUDOMODULES += sock_udp
PSEUDOMODULES += stdio_uart_rx
# print ascii representation in function od_hex_dump()
PSEUDOMODULES += od_string

View File

@ -27,6 +27,8 @@
* @}
*/
#include <errno.h>
#include "stdio_uart.h"
#include "board.h"
@ -45,16 +47,31 @@ extern ethos_t ethos;
#define ENABLE_DEBUG 0
#include "debug.h"
#ifdef MODULE_STDIO_UART_RX
static char _rx_buf_mem[STDIO_UART_RX_BUFSIZE];
isrpipe_t stdio_uart_isrpipe = ISRPIPE_INIT(_rx_buf_mem);
#endif
void stdio_init(void)
{
#ifndef USE_ETHOS_FOR_STDIO
uart_init(STDIO_UART_DEV, STDIO_UART_BAUDRATE, (uart_rx_cb_t) isrpipe_write_one, &stdio_uart_isrpipe);
uart_rx_cb_t cb;
void *arg;
#ifdef MODULE_STDIO_UART_RX
cb = (uart_rx_cb_t) isrpipe_write_one;
arg = &stdio_uart_isrpipe;
#else
uart_init(ETHOS_UART, ETHOS_BAUDRATE, (uart_rx_cb_t) isrpipe_write_one, &stdio_uart_isrpipe);
#ifdef USE_ETHOS_FOR_STDIO
#error "ethos needs stdio_uart_rx"
#endif
cb = NULL;
arg = NULL;
#endif
#ifndef USE_ETHOS_FOR_STDIO
uart_init(STDIO_UART_DEV, STDIO_UART_BAUDRATE, cb, arg);
#else
uart_init(ETHOS_UART, ETHOS_BAUDRATE, cb, arg);
#endif
#if MODULE_VFS
vfs_bind_stdio();
@ -63,7 +80,13 @@ void stdio_init(void)
ssize_t stdio_read(void* buffer, size_t count)
{
#ifdef MODULE_STDIO_UART_RX
return (ssize_t)isrpipe_read(&stdio_uart_isrpipe, (char *)buffer, count);
#else
(void)buffer;
(void)count;
return -ENOTSUP;
#endif
}
ssize_t stdio_write(const void* buffer, size_t len)