41 const uint32_t pclk = 150000000;
42 uint32_t denom = (baud << 4);
43 uint32_t dlr = 0xFFFFu & ((pclk + denom / 2) / denom);
45 return pclk / (dlr << 4);
#define USART_EFR_ENMODE
Enable Enhanced Mode to use TX and RX FIFO trigger level interrupts.
void usart_enable_rls_interrupt(uint32_t usart)
Enable RX Line Status Interrupt Enable the RX Line Status interrupt.
void usart_fifo_enable(uint32_t usart)
Enable FIFOs Enable both TX and RX FIFOs.
uint8_t usart_recv(uint32_t usart)
Read byte from the RX FIFO.
void usart_enable_tx_interrupt(uint32_t usart)
Enable TX Interrupt Enable the TX Holding Register Empty interrupt.
void usart_set_fifo_depth(uint32_t usart, uint8_t tx_depth, uint8_t rx_depth)
Set the TX and RX FIFO depth.
void usart_enhanced_enable(uint32_t usart)
Enable Enhanced Mode Enable enhanced mode to generate interrupts when FIFO thresholds in FCR are reac...
void usart_clear_tx_fifo(uint32_t usart)
Clear the TX FIFO Clears the TX FIFO.
void usart_disable_rx_interrupt(uint32_t usart)
Disable RX Interrupts Disable both the Receive Data Available and Character Timeout interrupts.
uint32_t usart_set_baudrate(uint32_t usart, uint32_t baud)
USART Set Baudrate The baud rate is computed assuming a peripheral clock of 150MHz.
void usart_send(uint32_t usart, uint8_t data)
Write byte to TX FIFO.
void usart_configure_lcr(uint32_t usart, uint8_t data_bits, uint8_t stop_bits, uint8_t parity)
USART Configure Line Control Register This register sets the data bits, stop bits,...
void usart_clear_rx_fifo(uint32_t usart)
Clear the RX FIFO Clears the RX FIFO.
void usart_enable_rx_interrupt(uint32_t usart)
Enable RX Interrupts Enable both the Receive Data Available and Character Timeout interrupts.
void usart_fifo_disable(uint32_t usart)
Disable FIFOs Disable both TX and RX FIFOs.
void usart_break_enable(uint32_t usart)
Enable Break Control Enables break control bit that forces TX pin to logic low.
void usart_disable_rls_interrupt(uint32_t usart)
Disable RX Line Status Interrupt Disable the RX Line Status interrupt.
void usart_enhanced_disable(uint32_t usart)
Disable Enhanced Mode Disable enhanced mode to generate interrupts when FIFO thresholds in FCR are re...
void usart_break_disable(uint32_t usart)
Disable Break Control Disables break control bit that forces TX pin to logic low.
void usart_disable_tx_interrupt(uint32_t usart)
Disable TX Interrupt Disable the TX Holding Register Empty interrupt.
#define USART_FCR_RXTL(rxtl)
RX Trigger Level.
#define USART_FCR_RXFIFORST
RX FIFO Reset.
#define USART_FCR_FIFOEN
Enable both UART RX and TX FIFOs, must be set before writing rest of FCR.
#define USART_FCR_TXFIFORST
TX FIFO Reset.
#define USART_FCR_TXTL(txtl)
TX Trigger Level.
#define USART_IER_RBRIE
Enable the RX Buffer Register Interrupt.
#define USART_IER_RLSIE
Enable RX line status interrupt.
#define USART_IER_THRIE
Enable the TX Holding Empty interrupt.
#define USART_LCR_BCON
Break Control: Enabling this bit forces TX to logic 0.
#define USART_LCR_SBS
Set LCR:SBS for 1.5 or 2 stop bits, Clear for 1 stop bit.
#define USART_LCR_WLS(wls)
Word length select: 5-8 databits.
#define USART_LCR_PSELPEN(psel)
LCR:PSEL and LCR:PEN control parity.
#define USART_STOPBITS_2
LCR:SBS Use 2 stop bits.
#define USART_FCR(usart_base)
FIFO Control Register RW, default 0000 0000h.
#define USART_LCR(usart_base)
Line control Register RW, default 0000 0000h.
#define USART_THR(usart_base)
Transmit Holding Register WO, only bits 7:0 used.
#define USART_DLR(usart_base)
Divisor Latch Register RW, default 0000 0001h, only bits 15:0 used.
#define USART_EFR(usart_base)
Enhanced Mode Register RW, default 0000 000h.
#define USART_IER(usart_base)
Interrupt Enable Register RW, default 0000 0000h.
#define USART_RBR(usart_base)
Receive Buffer Register RO, only bits 7:0 used.