From 09003055e48d17f88725152c2922a49162959d4f Mon Sep 17 00:00:00 2001 From: Josh Felmeden Date: Fri, 19 Jan 2024 15:26:41 +0000 Subject: [PATCH] ensure FIFO has space before transmit Signed-off-by: Josh Felmeden --- loader/src/loader.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/loader/src/loader.c b/loader/src/loader.c index 440db8df..72750c0f 100644 --- a/loader/src/loader.c +++ b/loader/src/loader.c @@ -152,9 +152,14 @@ putc(uint8_t ch) static void putc(uint8_t ch) { - while (!(*UART_REG(STAT) & STAT_TDRE)) { } - if (ch == '\n') + if (ch == '\n') { + // ensure FIFO has space + while (!(*UART_REG(STAT) & STAT_TDRE)) { } *UART_REG(TRANSMIT) = '\r'; + } + + // ensure FIFO has space + while (!(*UART_REG(STAT) & STAT_TDRE)) { } *UART_REG(TRANSMIT) = ch; } #else