24 lines
425 B
C
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;
|
|
}
|