summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/microblaze/apps/txrx_uhd.c3
-rw-r--r--firmware/microblaze/lib/hal_uart.c7
-rw-r--r--firmware/microblaze/lib/hal_uart.h1
3 files changed, 11 insertions, 0 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c
index 2065830ff..9fe17e262 100644
--- a/firmware/microblaze/apps/txrx_uhd.c
+++ b/firmware/microblaze/apps/txrx_uhd.c
@@ -324,6 +324,9 @@ void handle_udp_ctrl_packet(
case USRP2_CTRL_ID_HEY_WRITE_THIS_UART_FOR_ME_BRO:{
int num_bytes = ctrl_data_in->data.uart_args.bytes;
if(num_bytes > 20) num_bytes = 20;
+ //before we write to the UART, we flush the receive buffer
+ //this assumes that we're interested in the reply
+ hal_uart_rx_flush(ctrl_data_in->data.uart_args.dev);
fnputstr(ctrl_data_in->data.uart_args.dev, (char *) ctrl_data_in->data.uart_args.data, num_bytes);
ctrl_data_out.id = USRP2_CTRL_ID_MAN_I_TOTALLY_WROTE_THAT_UART_DUDE;
ctrl_data_out.data.uart_args.bytes = num_bytes;
diff --git a/firmware/microblaze/lib/hal_uart.c b/firmware/microblaze/lib/hal_uart.c
index a8344daf5..8f7f83a68 100644
--- a/firmware/microblaze/lib/hal_uart.c
+++ b/firmware/microblaze/lib/hal_uart.c
@@ -101,3 +101,10 @@ hal_uart_getc(hal_uart_name_t u)
return uart_regs[u].rxchar;
}
+int hal_uart_rx_flush(hal_uart_name_t u)
+{
+ char x;
+ while(uart_regs[u].rxlevel) x = uart_regs[u].rxchar;
+ return x;
+}
+
diff --git a/firmware/microblaze/lib/hal_uart.h b/firmware/microblaze/lib/hal_uart.h
index 81f4a6777..051dffe92 100644
--- a/firmware/microblaze/lib/hal_uart.h
+++ b/firmware/microblaze/lib/hal_uart.h
@@ -82,5 +82,6 @@ void hal_uart_putc_nowait(hal_uart_name_t u, int ch);
*/
int hal_uart_getc(hal_uart_name_t u);
+int hal_uart_rx_flush(hal_uart_name_t u);
#endif /* INCLUDED_HAL_UART_H */