aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/microblaze/lib/hal_uart.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/microblaze/lib/hal_uart.c')
-rw-r--r--firmware/microblaze/lib/hal_uart.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/firmware/microblaze/lib/hal_uart.c b/firmware/microblaze/lib/hal_uart.c
index 8f7f83a68..4d754d5e5 100644
--- a/firmware/microblaze/lib/hal_uart.c
+++ b/firmware/microblaze/lib/hal_uart.c
@@ -19,6 +19,7 @@
#include "memory_map.h"
#include "hal_uart.h"
#include "hal_io.h"
+#include "mdelay.h"
//just to save you from going insane, note that firmware/FPGA UARTs [0-2] correspond to serial ports [1-3].
//so in software, we refer to UART_DEBUG as UART0, but it transmits on pin TXD<1>. see the UART assignments in hal_uart.h.
@@ -101,6 +102,16 @@ hal_uart_getc(hal_uart_name_t u)
return uart_regs[u].rxchar;
}
+int
+hal_uart_getc_timeout(hal_uart_name_t u)
+{
+ int timeout = 0;
+ while (((uart_regs[u].rxlevel) == 0) && (timeout++ < HAL_UART_TIMEOUT_MS))
+ mdelay(1);
+
+ return (uart_regs[u].rxlevel == 0) ? 0 : uart_regs[u].rxchar;
+}
+
int hal_uart_rx_flush(hal_uart_name_t u)
{
char x;