more progress on UART read
This commit is contained in:
parent
7265728932
commit
8d5cd862ab
9 changed files with 77 additions and 31 deletions
|
@ -6,6 +6,7 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
static volatile bool ctrl_c_received = false;
|
||||
static char last_char = '\0';
|
||||
|
||||
void sigint_handler(int sig_num) {
|
||||
ctrl_c_received = true;
|
||||
|
@ -37,8 +38,10 @@ void restore_terminal() {
|
|||
}
|
||||
|
||||
char get_char_from_terminal() {
|
||||
char c = getchar();
|
||||
return c;
|
||||
if (is_char_available()) {
|
||||
last_char = getchar(); // Update last_char if new character is available
|
||||
}
|
||||
return last_char; // Return the last available character (or '\0' initially)
|
||||
}
|
||||
|
||||
void write_char_to_terminal(char chr) {
|
||||
|
@ -71,4 +74,4 @@ int is_char_available() {
|
|||
// No character available
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue