Skip to content

Commit

Permalink
ensure FIFO has space before transmit
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Felmeden <[email protected]>
  • Loading branch information
josh-felm committed Jan 19, 2024
1 parent 785263f commit 0900305
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions loader/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0900305

Please sign in to comment.