swissChili | 56cf817 | 2022-07-30 18:47:48 -0700 | [diff] [blame] | 1 | #include "kint.h" |
| 2 | #include "serial.h" |
| 3 | |
| 4 | /* Base address for QEMU */ |
| 5 | /* TODO: Abstract for ESP32C3 */ |
| 6 | #define UART_BASE (void *)0x10000000 |
| 7 | #define UART_LSR_EMPTY_MASK 0x40 |
| 8 | |
| 9 | /* UART transmitter holding register */ |
| 10 | uchar *uart_thr = UART_BASE; |
| 11 | |
| 12 | /* UART line status register */ |
| 13 | uchar *uart_lsr = UART_BASE + 5; |
| 14 | |
| 15 | void init_serial() |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | void serial_put(char byte) |
| 20 | { |
| 21 | while (*uart_lsr ^ UART_LSR_EMPTY_MASK) |
| 22 | { |
| 23 | /* block until UART clear */ |
| 24 | } |
| 25 | |
| 26 | *uart_thr = byte; |
| 27 | } |
| 28 | |
| 29 | void serial_write(char *string) |
| 30 | { |
| 31 | while (*string) |
| 32 | { |
| 33 | serial_put(*string++); |
| 34 | } |
| 35 | } |