mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 06:23:53 +01:00
Merge pull request #17446 from gschorcht/sys/std_available
sys/stdio: add optional function stdio_available
This commit is contained in:
commit
74b38ca641
@ -152,6 +152,7 @@ PSEUDOMODULES += sock_udp
|
||||
PSEUDOMODULES += socket_zep_hello
|
||||
PSEUDOMODULES += soft_uart_modecfg
|
||||
PSEUDOMODULES += stdin
|
||||
PSEUDOMODULES += stdio_available
|
||||
PSEUDOMODULES += stdio_cdc_acm
|
||||
PSEUDOMODULES += stdio_ethos
|
||||
PSEUDOMODULES += stdio_uart_rx
|
||||
|
||||
@ -17,6 +17,7 @@ endif
|
||||
ifneq (,$(filter stdio_cdc_acm,$(USEMODULE)))
|
||||
USEMODULE += usbus_cdc_acm
|
||||
USEMODULE += isrpipe
|
||||
USEMODULE += stdio_available
|
||||
endif
|
||||
|
||||
ifneq (,$(filter stdio_rtt,$(USEMODULE)))
|
||||
@ -37,6 +38,7 @@ endif
|
||||
ifneq (,$(filter stdio_uart_rx,$(USEMODULE)))
|
||||
USEMODULE += isrpipe
|
||||
USEMODULE += stdio_uart
|
||||
USEMODULE += stdio_available
|
||||
endif
|
||||
|
||||
ifneq (,$(filter stdio_uart,$(USEMODULE)))
|
||||
|
||||
@ -49,10 +49,16 @@ config MODULE_STDIO_UART_RX
|
||||
bool
|
||||
depends on MODULE_STDIO_UART
|
||||
select MODULE_ISRPIPE
|
||||
select MODULE_STDIO_AVAILABLE
|
||||
default y if MODULE_STDIN
|
||||
help
|
||||
Reception when using UART-based STDIO needs to be enabled.
|
||||
|
||||
config MODULE_STDIO_AVAILABLE
|
||||
bool
|
||||
help
|
||||
Indicates that the implementation supports function stdio_available
|
||||
|
||||
config MODULE_PRINTF_FLOAT
|
||||
bool "Float support in printf"
|
||||
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -34,6 +36,18 @@ extern "C" {
|
||||
*/
|
||||
void stdio_init(void);
|
||||
|
||||
#if IS_USED(MODULE_STDIO_AVAILABLE) || DOXYGEN
|
||||
/**
|
||||
* @brief Get the number of bytes available for reading from stdio.
|
||||
*
|
||||
* @warning This function is only available if the implementation supports
|
||||
* it and the @c stdio_available module is enabled.
|
||||
*
|
||||
* @return number of available bytes
|
||||
*/
|
||||
int stdio_available(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief read @p len bytes from stdio uart into @p buffer
|
||||
*
|
||||
|
||||
@ -67,6 +67,13 @@ void stdio_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
#ifdef MODULE_STDIO_UART_RX
|
||||
|
||||
@ -58,5 +58,6 @@ config MODULE_STDIO_CDC_ACM
|
||||
bool "CDC ACM"
|
||||
depends on MODULE_USBUS_CDC_ACM
|
||||
select MODULE_ISRPIPE
|
||||
select MODULE_STDIO_AVAILABLE
|
||||
|
||||
endchoice
|
||||
|
||||
@ -51,6 +51,13 @@ void stdio_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if IS_USED(MODULE_STDIO_AVAILABLE)
|
||||
int stdio_available(void)
|
||||
{
|
||||
return tsrb_avail(&_cdc_stdio_isrpipe.tsrb);
|
||||
}
|
||||
#endif
|
||||
|
||||
ssize_t stdio_read(void* buffer, size_t len)
|
||||
{
|
||||
(void)buffer;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user