synth/uart/uart.c

24 lines
425 B
C
Raw Normal View History

2021-02-17 21:20:30 +00:00
#include "uart.h"
2021-03-13 23:49:28 +00:00
int uart_rx_available(struct uart* uart) {
return uart->flags & UART_STATUS_RXNE_msk != 0;
2021-02-17 21:20:30 +00:00
}
2021-03-13 23:49:28 +00:00
int uart_tx_available(struct uart* uart) {
return uart->flags & UART_STATUS_TXE_msk != 0;
2021-02-17 21:20:30 +00:00
}
2021-03-13 23:49:28 +00:00
void uart_write(struct uart* uart, const char c) {
while (!uart_tx_available(uart)) {
2021-02-17 21:20:30 +00:00
}
2021-03-13 23:49:28 +00:00
uart->data = c;
2021-02-17 21:20:30 +00:00
}
2021-03-13 23:49:28 +00:00
char uart_read(struct uart* uart) {
while (!uart_rx_available(uart)) {
2021-02-17 21:20:30 +00:00
}
2021-03-13 23:49:28 +00:00
return uart->data;
2021-02-17 21:20:30 +00:00
}