32#ifndef LIBOPENCM3_PAC55XX_USART_H_
33#define LIBOPENCM3_PAC55XX_USART_H_
43#define USART_RBR(usart_base) MMIO32((usart_base) + 0x0000)
45#define USART_THR(usart_base) MMIO32((usart_base) + 0x0004)
47#define USART_DLR(usart_base) MMIO32((usart_base) + 0x0008)
49#define USART_IER(usart_base) MMIO32((usart_base) + 0x000C)
51#define USART_IIR(usart_base) MMIO32((usart_base) + 0x0010)
53#define USART_FCR(usart_base) MMIO32((usart_base) + 0x0014)
55#define USART_LCR(usart_base) MMIO32((usart_base) + 0x0018)
57#define USART_LSR(usart_base) MMIO32((usart_base) + 0x0020)
59#define USART_SCR(usart_base) MMIO32((usart_base) + 0x0028)
61#define USART_EFR(usart_base) MMIO32((usart_base) + 0x002C)
67#define USART_IER_RLSIE BIT2
69#define USART_IER_THRIE BIT1
71#define USART_IER_RBRIE BIT0
77#define USART_IIR_INTSTATUS BIT0
79#define USART_IIR_TXEMPTY (0x02)
81#define USART_IIR_RXAVAIL (0x04)
83#define USART_IIR_RXLINESTAT (0x06)
85#define USART_IIR_RXTIMEOUT (0x0C)
91#define USART_FCR_FIFOEN BIT0
93#define USART_FCR_RXFIFORST BIT1
95#define USART_FCR_TXFIFORST BIT2
96#define USART_FCR_TXTL_MASK (3)
97#define USART_FCR_TXTL_SHIFT 4
99#define USART_FCR_TXTL(txtl) (((txtl) & USART_FCR_TXTL_MASK) << USART_FCR_TXTL_SHIFT)
100#define USART_FCR_RXTL_MASK (3)
101#define USART_FCR_RXTL_SHIFT 6
103#define USART_FCR_RXTL(rxtl) (((rxtl) & USART_FCR_RXTL_MASK) << USART_FCR_RXTL_SHIFT)
104#define USART_FIFO_TRIG_1CHAR (0)
105#define USART_FIFO_TRIG_4CHAR (1)
106#define USART_FIFO_TRIG_8CHAR (2)
107#define USART_FIFO_TRIG_14CHAR (3)
113#define USART_DATABITS_5 (0)
115#define USART_DATABITS_6 (0x01)
117#define USART_DATABITS_7 (0x02)
119#define USART_DATABITS_8 (0x03)
121#define USART_PSELPEN_ODD (0x01)
123#define USART_PSELPEN_EVEN (0x03)
125#define USART_PSELPEN_FORCE1 (0x05)
127#define USART_PSELPEN_FORCE0 (0x07)
129#define USART_PARITY_DISABLE (0)
131#define USART_PARITY_ODD USART_PSELPEN_ODD
133#define USART_PARITY_EVEN USART_PSELPEN_EVEN
135#define USART_PARITY_FORCE1 USART_PSELPEN_FORCE1
137#define USART_PARITY_FORCE0 USART_PSELPEN_FORCE0
139#define USART_STOPBITS_1 (0)
141#define USART_STOPBITS_1P5 USART_LCR_SBS
143#define USART_STOPBITS_2 USART_LCR_SBS
144#define USART_LCR_WLS_MASK (3)
146#define USART_LCR_WLS(wls) ((wls) & USART_LCR_WLS_MASK)
148#define USART_LCR_SBS BIT2
150#define USART_LCR_PEN BIT3
151#define USART_LCR_PSELPEN_MASK (7)
152#define USART_LCR_PSELPEN_SHIFT 3
154#define USART_LCR_PSELPEN(psel) (((psel) & USART_LCR_PSELPEN_MASK) << USART_LCR_PSELPEN_SHIFT)
156#define USART_LCR_BCON BIT6
162#define USART_LSR_RDR BIT0
164#define USART_LSR_OE BIT1
166#define USART_LSR_PE BIT2
168#define USART_LSR_FE BIT3
170#define USART_LSR_BI BIT4
172#define USART_LSR_THRE BIT5
174#define USART_LSR_TEMT BIT6
176#define USART_LSR_RXFE BIT7
180#define USART_TX_FIFO_DEPTH (16)
182#define USART_RX_FIFO_DETPH (16)
185#define USART_EFR_ENMODE BIT4
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.