-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
Fix the bug that LF CR is printed instead of CR LF. Signed-off-by: Axel Heider <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,13 +34,15 @@ int uart_getchar(ps_chardevice_t *d) | |
|
||
int uart_putchar(ps_chardevice_t *d, int c) | ||
{ | ||
while ((*REG_PTR(d->vaddr, UARTFR) & PL011_UARTFR_TXFF) != 0); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
heshamelmatary
Contributor
|
||
|
||
*REG_PTR(d->vaddr, UARTDR) = c; | ||
if (c == '\n' && (d->flags & SERIAL_AUTO_CR)) { | ||
uart_putchar(d, '\r'); | ||
} | ||
|
||
while ((*REG_PTR(d->vaddr, UARTFR) & PL011_UARTFR_TXFF) != 0) | ||
/* busy loop */ | ||
} | ||
*REG_PTR(d->vaddr, UARTDR) = c; | ||
|
||
return c; | ||
} | ||
|
||
|
I don't understand where the race will happen. We call
uart_putchar()
(recursively) with\r
first if we see a\n
. In this call it will do a blocking wait, then send\r
. Then we are back here again, do another blocking wait and send the\n
.