Skip to content

Commit

Permalink
sys/stdio_uart: add stdio_clear_stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikVE committed Nov 27, 2024
1 parent 87ae06a commit 6f9edfe
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 @@ -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);
}
}

0 comments on commit 6f9edfe

Please sign in to comment.