Skip to content

Commit

Permalink
sys/stdio_uart: add pseudomodule stdio_clear_rx
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikVE committed Nov 26, 2024
1 parent 87ae06a commit 059bb79
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions makefiles/pseudomodules.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ PSEUDOMODULES += socket_zep_hello
PSEUDOMODULES += soft_uart_modecfg
PSEUDOMODULES += stdin
PSEUDOMODULES += stdio_available
PSEUDOMODULES += stdio_clear_rx
PSEUDOMODULES += stdio_cdc_acm
PSEUDOMODULES += stdio_dispatch
PSEUDOMODULES += stdio_ethos
Expand Down
5 changes: 5 additions & 0 deletions makefiles/stdio.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ ifneq (,$(filter stdin,$(USEMODULE)))
endif
endif

ifneq (,$(filter stdio_clear_rx,$(USEMODULE)))
USEMODULE += stdin
endif

ifneq (,$(filter stdio_uart_rx,$(USEMODULE)))
USEMODULE += isrpipe
USEMODULE += stdio_uart
USEMODULE += stdio_available
USEMODULE += stdio_clear_rx
endif

ifneq (,$(filter stdio_uart,$(USEMODULE)))
Expand Down
10 changes: 10 additions & 0 deletions sys/include/stdio_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ void stdio_init(void);
int stdio_available(void);
#endif

#if IS_USED(MODULE_STDIO_CLEAR_RX) || DOXYGEN
/**
* @brief Clear the input buffer
*
* @warning This function is only available if the implementation supports
* it and the @c stdio_clear_rx module is enabled.
*/
void stdio_clear_rx(void);
#endif

/**
* @brief read @p len bytes from stdio uart into @p buffer
*
Expand Down
5 changes: 5 additions & 0 deletions sys/stdio/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ int stdio_available(void)
return tsrb_avail(&stdin_isrpipe.tsrb);
}
#endif

void stdio_clear_rx(void)
{
tsrb_clear(&stdin_isrpipe.tsrb);
}

0 comments on commit 059bb79

Please sign in to comment.