From 4c96cd2d5f7cb8de7d48b5dbd728af7fda572d9d Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 4 Sep 2022 18:20:46 +0200 Subject: uart fixed --- fw/fe310/eos/soc/uart.c | 5 +++++ fw/fe310/eos/soc/uart.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fw/fe310/eos/soc/uart.c b/fw/fe310/eos/soc/uart.c index 589832a..1cff781 100644 --- a/fw/fe310/eos/soc/uart.c +++ b/fw/fe310/eos/soc/uart.c @@ -121,3 +121,8 @@ int eos_uart_getc(int block) { } return r & 0xff; } + +void eos_uart_flush_rx(void) { + volatile uint32_t r; + while (!(r = UART0_REG(UART_REG_RXFIFO) & 0x80000000)); +} diff --git a/fw/fe310/eos/soc/uart.h b/fw/fe310/eos/soc/uart.h index caaf6c6..41329fb 100644 --- a/fw/fe310/eos/soc/uart.h +++ b/fw/fe310/eos/soc/uart.h @@ -22,4 +22,5 @@ void eos_uart_txwm_clear(void); void eos_uart_rxwm_set(uint8_t wm); void eos_uart_rxwm_clear(void); int eos_uart_putc(int c, int block); -int eos_uart_getc(int block); \ No newline at end of file +int eos_uart_getc(int block); +void eos_uart_flush_rx(void); -- cgit v1.2.3