Commit 141752e4 authored by Alessandro Rubini's avatar Alessandro Rubini

uart: fix return value and add puts with a standard prototype

We include newlib headers (and link part of newlib), so any
locally-defined function must have the same prototype as standard
ones. We'll soon nee a "puts" implementation for pp_printf, so this
adds puts as an alias of uart_write_string (at no size cost) and makes
uart_write_string itself return integer (this costs a few bytes).

While I'm at it, change uart_write_byte to be slightly faster.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <>
parent 4d8eaf1d
......@@ -21,16 +21,21 @@ void uart_write_byte(int b)
if (b == '\n')
while (uart->SR & UART_SR_TX_BUSY) ;
while (uart->SR & UART_SR_TX_BUSY)
uart->TDR = b;
void uart_write_string(char *s)
int uart_write_string(const char *s)
const char *t = s;
while (*s)
return s - t;
int puts(const char *s) __attribute__((alias("uart_write_string")));
int uart_poll()
return uart->SR & UART_SR_RX_RDY;
......@@ -3,7 +3,8 @@
void uart_init(void);
void uart_write_byte(int b);
void uart_write_string(char *s);
int uart_write_string(const char *s);
int puts(const char *s);
int uart_read_byte(void);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment