Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/stdio_uart: add stdio_clear_stdin #19837

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -78,3 +78,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);
}
}