MNRS-BM-BSP/include/ehrenberg/devices/uart.h

31 lines
810 B
C
Raw Permalink Normal View History

2024-05-30 18:32:23 +02:00
#ifndef _DEVICES_UART_H
#define _DEVICES_UART_H
2024-01-13 23:06:01 +01:00
#include <stdint.h>
2024-05-30 18:32:23 +02:00
#include "gen/uart.h"
2024-01-13 23:06:01 +01:00
2024-06-10 10:13:07 +02:00
static inline uint32_t uart_get_tx_free(volatile uart_t* reg){
return get_uart_rx_tx_reg_tx_free(reg);
}
2024-06-10 10:13:07 +02:00
static inline uint32_t uart_get_tx_empty(volatile uart_t* reg){
return get_uart_rx_tx_reg_tx_empty(reg);
}
2024-06-10 10:13:07 +02:00
static inline uint32_t uart_get_rx_avail(volatile uart_t* reg){
return get_uart_rx_tx_reg_rx_avail(reg);
}
static inline void uart_write(volatile uart_t* reg, uint8_t data){
2024-02-22 17:09:35 +01:00
while(get_uart_rx_tx_reg_tx_free(reg) == 0);
set_uart_rx_tx_reg_data(reg, data);
2024-01-13 23:06:01 +01:00
}
2024-06-10 10:13:07 +02:00
static inline inline uint8_t uart_read(volatile uart_t* reg){
2024-02-22 17:09:35 +01:00
uint32_t res = get_uart_rx_tx_reg_data(reg);
while((res&0x10000) == 0) res = get_uart_rx_tx_reg_data(reg);
2024-01-13 23:06:01 +01:00
return res;
}
2024-05-30 18:32:23 +02:00
#endif /* _DEVICES_UART_H */