synth/uart/uart.c
2021-03-13 15:49:28 -08:00

24 lines
425 B
C

#include "uart.h"
int uart_rx_available(struct uart* uart) {
return uart->flags & UART_STATUS_RXNE_msk != 0;
}
int uart_tx_available(struct uart* uart) {
return uart->flags & UART_STATUS_TXE_msk != 0;
}
void uart_write(struct uart* uart, const char c) {
while (!uart_tx_available(uart)) {
}
uart->data = c;
}
char uart_read(struct uart* uart) {
while (!uart_rx_available(uart)) {
}
return uart->data;
}