diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/io.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -32,9 +32,10 @@ static int uart1_FILE_put(char ch, FILE* unused) return 1; } -static int uart1_FILE_get(FILE* f) +int uart1_FILE_get(FILE* unused) { - return -1; + while (!UART.rfc.get(UART1)); + return UART.rbr.get(UART1); } static int uart1_FILE_flush(FILE* f) @@ -46,10 +47,11 @@ FILE _uart1_FILE = (FILE){ .put = uart1_FILE_put, .get = uart1_FILE_get, .flush = uart1_FILE_flush, - .flags = __SWR, + .flags = __SWR | __SRD, }; FILE* const stdout = &_uart1_FILE; +FILE* const stdin = &_uart1_FILE; static int uart1_init_for_stdout = 0; @@ -62,6 +64,13 @@ void init_uart1_for_stdout(void) UART.fcr.set(UART1, 0x07); UART.ier.txd_en.set(UART1, ON); UART.lcr.word_sz.set(UART1, WORD_SZ_8_BITS); + UART.fcr.fifo_en.set(UART1, 1); + + UART.div.set(UART1, 1); + UART.fcr.set(UART1, 0x07); + UART.ier.txd_en.set(UART1, ON); + UART.lcr.word_sz.set(UART1, WORD_SZ_8_BITS); + volatile uint32_t dl = (10 * 6400000 / 8 / BAUD_RATE + 5) / 10; UART.dl.set(UART1, dl); |