Skip to content

Commit

Permalink
Merge pull request #19837 from HendrikVE/stdio_uart_add_flush_rx
Browse files Browse the repository at this point in the history
sys/stdio_uart: add stdio_clear_stdin
  • Loading branch information
maribu authored Nov 27, 2024
2 parents 5fa8f65 + 6f9edfe commit 67a22db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sys/include/stdio_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ void stdio_init(void);
int stdio_available(void);
#endif

/**
* @brief Clear the input buffer
*
* @note Requires 'USEMODULE += stdin'
*
* @warning This function does only work if the stdio implementation supports it.
*/
void stdio_clear_stdin(void);

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

void stdio_clear_stdin(void)
{
if (IS_USED(MODULE_STDIN)) {
tsrb_clear(&stdin_isrpipe.tsrb);
}
}

0 comments on commit 67a22db

Please sign in to comment.