36#ifndef LIBOPENCM3_LM4F_UART_H
37#define LIBOPENCM3_LM4F_UART_H
49#define UART0 UART0_BASE
50#define UART1 UART1_BASE
51#define UART2 UART2_BASE
52#define UART3 UART3_BASE
53#define UART4 UART4_BASE
54#define UART5 UART5_BASE
55#define UART6 UART6_BASE
56#define UART7 UART7_BASE
64#define UART_DR(uart_base) MMIO32((uart_base) + 0x00)
67#define UART_RSR(uart_base) MMIO32((uart_base) + 0x04)
68#define UART_ECR(uart_base) MMIO32((uart_base) + 0x04)
71#define UART_FR(uart_base) MMIO32((uart_base) + 0x18)
74#define UART_ILPR(uart_base) MMIO32((uart_base) + 0x20)
77#define UART_IBRD(uart_base) MMIO32((uart_base) + 0x24)
80#define UART_FBRD(uart_base) MMIO32((uart_base) + 0x28)
83#define UART_LCRH(uart_base) MMIO32((uart_base) + 0x2C)
86#define UART_CTL(uart_base) MMIO32((uart_base) + 0x30)
89#define UART_IFLS(uart_base) MMIO32((uart_base) + 0x34)
92#define UART_IM(uart_base) MMIO32((uart_base) + 0x38)
95#define UART_RIS(uart_base) MMIO32((uart_base) + 0x3C)
98#define UART_MIS(uart_base) MMIO32((uart_base) + 0x40)
101#define UART_ICR(uart_base) MMIO32((uart_base) + 0x44)
104#define UART_DMACTL(uart_base) MMIO32((uart_base) + 0x48)
107#define UART_LCTL(uart_base) MMIO32((uart_base) + 0x90)
110#define UART_LSS(uart_base) MMIO32((uart_base) + 0x94)
113#define UART_LTIM(uart_base) MMIO32((uart_base) + 0x98)
116#define UART_9BITADDR(uart_base) MMIO32((uart_base) + 0xA4)
119#define UART_9BITAMASK(uart_base) MMIO32((uart_base) + 0xA8)
122#define UART_PP(uart_base) MMIO32((uart_base) + 0xFC0)
125#define UART_CC(uart_base) MMIO32((uart_base) + 0xFC8)
128#define UART_PERIPH_ID4(uart_base) MMIO32((uart_base) + 0xFD0)
131#define UART_PERIPH_ID5(uart_base) MMIO32((uart_base) + 0xFD4)
134#define UART_PERIPH_ID6(uart_base) MMIO32((uart_base) + 0xFD8)
137#define UART_PERIPH_ID7(uart_base) MMIO32((uart_base) + 0xFDC)
140#define UART_PERIPH_ID0(uart_base) MMIO32((uart_base) + 0xFE0)
143#define UART_PERIPH_ID1(uart_base) MMIO32((uart_base) + 0xFE4)
146#define UART_PERIPH_ID2(uart_base) MMIO32((uart_base) + 0xFE8)
149#define UART_PERIPH_ID3(uart_base) MMIO32((uart_base) + 0xFEC)
152#define UART_PCELL_ID0(uart_base) MMIO32((uart_base) + 0xFF0)
155#define UART_PCELL_ID1(uart_base) MMIO32((uart_base) + 0xFF4)
158#define UART_PCELL_ID2(uart_base) MMIO32((uart_base) + 0xFF8)
161#define UART_PCELL_ID3(uart_base) MMIO32((uart_base) + 0xFFC)
168#define UART_DR_OE (1 << 11)
170#define UART_DR_BE (1 << 10)
172#define UART_DR_PE (1 << 9)
174#define UART_DR_FE (1 << 8)
176#define UART_DR_DATA_MASK (0xFF << 0)
182#define UART_RSR_OE (1 << 3)
184#define UART_RSR_BE (1 << 2)
186#define UART_RSR_PE (1 << 1)
188#define UART_RSR_FE (1 << 0)
194#define UART_FR_TXFE (1 << 7)
196#define UART_FR_RXFF (1 << 6)
198#define UART_FR_TXFF (1 << 5)
200#define UART_FR_RXFE (1 << 4)
202#define UART_FR_BUSY (1 << 3)
204#define UART_FR_CTS (1 << 0)
210#define UART_LCRH_SPS (1 << 7)
212#define UART_LCRH_WLEN_MASK (3 << 5)
213#define UART_LCRH_WLEN_5 (0 << 5)
214#define UART_LCRH_WLEN_6 (1 << 5)
215#define UART_LCRH_WLEN_7 (2 << 5)
216#define UART_LCRH_WLEN_8 (3 << 5)
218#define UART_LCRH_FEN (1 << 4)
220#define UART_LCRH_STP2 (1 << 3)
222#define UART_LCRH_EPS (1 << 2)
224#define UART_LCRH_PEN (1 << 1)
226#define UART_LCRH_BRK (1 << 0)
232#define UART_CTL_CTSEN (1 << 15)
234#define UART_CTL_RTSEN (1 << 14)
236#define UART_CTL_RTS (1 << 11)
238#define UART_CTL_DTR (1 << 10)
240#define UART_CTL_RXE (1 << 9)
242#define UART_CTL_TXE (1 << 8)
244#define UART_CTL_LBE (1 << 7)
246#define UART_CTL_LIN (1 << 6)
248#define UART_CTL_HSE (1 << 5)
250#define UART_CTL_EOT (1 << 4)
252#define UART_CTL_SMART (1 << 3)
254#define UART_CTL_SIRLIP (1 << 2)
256#define UART_CTL_SIREN (1 << 1)
258#define UART_CTL_UARTEN (1 << 0)
264#define UART_IFLS_RXIFLSEL_MASK (7 << 3)
265#define UART_IFLS_RXIFLSEL_1_8 (0 << 3)
266#define UART_IFLS_RXIFLSEL_1_4 (1 << 3)
267#define UART_IFLS_RXIFLSEL_1_2 (2 << 3)
268#define UART_IFLS_RXIFLSEL_3_4 (3 << 3)
269#define UART_IFLS_RXIFLSEL_7_8 (4 << 3)
271#define UART_IFLS_TXIFLSEL_MASK (7 << 0)
272#define UART_IFLS_TXIFLSEL_7_8 (0 << 0)
273#define UART_IFLS_TXIFLSEL_3_4 (1 << 0)
274#define UART_IFLS_TXIFLSEL_1_2 (2 << 0)
275#define UART_IFLS_TXIFLSEL_1_4 (3 << 0)
276#define UART_IFLS_TXIFLSEL_1_8 (4 << 0)
285#define UART_IM_LME5IM (1 << 15)
287#define UART_IM_LME1IM (1 << 14)
289#define UART_IM_LMSBIM (1 << 13)
291#define UART_IM_9BITIM (1 << 12)
293#define UART_IM_OEIM (1 << 10)
295#define UART_IM_BEIM (1 << 9)
297#define UART_IM_PEIM (1 << 8)
299#define UART_IM_FEIM (1 << 7)
301#define UART_IM_RTIM (1 << 6)
303#define UART_IM_TXIM (1 << 5)
305#define UART_IM_RXIM (1 << 4)
307#define UART_IM_DSRIM (1 << 3)
309#define UART_IM_DCDIM (1 << 2)
311#define UART_IM_CTSIM (1 << 1)
313#define UART_IM_RIIM (1 << 0)
319#define UART_DMACTL_DMAERR (1 << 2)
321#define UART_DMACTL_TXDMAE (1 << 1)
323#define UART_DMACTL_RXDMAE (1 << 0)
329#define UART_LCTL_BLEN_MASK (3 << 4)
330#define UART_LCTL_BLEN_16T (3 << 4)
331#define UART_LCTL_BLEN_15T (2 << 4)
332#define UART_LCTL_BLEN_14T (1 << 4)
333#define UART_LCTL_BLEN_13T (0 << 4)
335#define UART_LCTL_MASTER (1 << 0)
341#define UART_UART_9BITADDR_9BITEN (1 << 15)
343#define UART_UART_9BITADDR_ADDR_MASK (0xFF << 0)
349#define UART_UART_PP_NB (1 << 1)
351#define UART_UART_PP_SC (1 << 0)
357#define UART_CC_CS_MASK (0xF << 0)
358#define UART_CC_CS_SYSCLK (0x0 << 0)
359#define UART_CC_CS_PIOSC (0x5 << 0)
456void uart_send(uint32_t uart, uint16_t data);
void uart_enable_fifo(uint32_t uart)
Enable FIFO for the UART.
void uart_disable(uint32_t uart)
Disable the UART.
void uart_disable_rx_dma(uint32_t uart)
Disable the UART Receive DMA.
void uart_set_baudrate(uint32_t uart, uint32_t baud)
Set UART baudrate.
#define UART_FR_TXFE
Tx FIFO empty.
void uart_enable_rx_dma(uint32_t uart)
Enable the UART Receive DMA.
void uart_enable_interrupts(uint32_t uart, enum uart_interrupt_flag ints)
Enable Specific UART Interrupts.
void uart_send(uint32_t uart, uint16_t data)
UART Send a Data Word.
#define UART_IM_TXIM
Transmit interrupt mask.
void uart_send_blocking(uint32_t uart, uint16_t data)
UART Send Data Word with Blocking.
void uart_disable_tx_interrupt(uint32_t uart)
Disable the UART Transmit Interrupt.
#define UART_FR_TXFF
Tx FIFO full.
void uart_disable_interrupts(uint32_t uart, enum uart_interrupt_flag ints)
Enable Specific UART Interrupts.
#define UART_IM_OEIM
Overrun error interrupt mask.
void uart_set_mode(uint32_t uart, uint32_t mode)
void uart_set_fifo_trigger_levels(uint32_t uart, enum uart_fifo_rx_trigger_level rx_level, enum uart_fifo_tx_trigger_level tx_level)
Set the FIFO trigger levels.
#define UART_IM_LME5IM
LIN mode edge 5 interrupt mask.
#define UART_IM_DCDIM
Data Carrier Detect modem interrupt mask.
void uart_wait_recv_ready(uint32_t uart)
UART Wait for Received Data Available.
#define UART_IM_BEIM
Break error interrupt mask.
#define UART_IM_DSRIM
Data Set Ready modem interrupt mask.
#define UART_IFLS_TXIFLSEL_1_2
#define UART_IM_RTIM
Receive time-out interrupt mask.
uint16_t uart_recv(uint32_t uart)
UART Read a Received Data Word.
uint16_t uart_recv_blocking(uint32_t uart)
UART Read a Received Data Word with Blocking.
#define UART_IFLS_RXIFLSEL_3_4
void uart_disable_rx_interrupt(uint32_t uart)
Disable the UART Receive Interrupt.
#define UART_IFLS_TXIFLSEL_3_4
void uart_set_parity(uint32_t uart, enum uart_parity parity)
Set UART parity.
#define UART_IFLS_TXIFLSEL_1_8
#define UART_IM_PEIM
Parity error interrupt mask.
#define UART_FR_RXFF
Rx FIFO full.
#define UART_IFLS_RXIFLSEL_1_4
#define UART_IFLS_RXIFLSEL_1_2
#define UART_IFLS_TXIFLSEL_1_4
void uart_enable_tx_dma(uint32_t uart)
Enable the UART Transmit DMA.
void uart_clock_from_sysclk(uint32_t uart)
Clock the UART module from the system clock.
void uart_disable_tx_dma(uint32_t uart)
Disable the UART Transmit DMA.
void uart_wait_send_ready(uint32_t uart)
UART Wait for Transmit Data Buffer Not Full.
#define UART_FR_RXFE
Rx FIFO empty.
#define UART_IM_FEIM
Framing error interrupt mask.
void uart_enable_tx_interrupt(uint32_t uart)
Enable the UART Transmit Interrupt.
void uart_clear_interrupt_flag(uint32_t uart, enum uart_interrupt_flag ints)
Mark interrupt as serviced.
void uart_clock_from_piosc(uint32_t uart)
Clock the UART module from the internal oscillator.
#define UART_IM_RXIM
Receive interrupt mask.
uart_fifo_rx_trigger_level
UART RX FIFO interrupt trigger levels.
void uart_set_flow_control(uint32_t uart, enum uart_flowctl flow)
Set the flow control scheme.
#define UART_IM_LME1IM
LIN mode edge 1 interrupt mask.
void uart_enable_rx_interrupt(uint32_t uart)
Enable the UART Receive Interrupt.
#define UART_IFLS_RXIFLSEL_7_8
#define UART_IM_RIIM
Ring Indicator modem interrupt mask.
void uart_enable(uint32_t uart)
Enable the UART.
#define UART_IFLS_TXIFLSEL_7_8
uart_interrupt_flag
UART interrupt masks.
void uart_disable_fifo(uint32_t uart)
Disable FIFO for the UART.
#define UART_IFLS_RXIFLSEL_1_8
void uart_set_databits(uint32_t uart, uint8_t databits)
Set UART databits.
#define UART_IM_9BITIM
9-bit mode interrupt mask
#define UART_MIS(uart_base)
#define UART_IM_LMSBIM
LIN mode sync break interrupt mask.
void uart_set_stopbits(uint32_t uart, uint8_t stopbits)
Set UART stopbits.
uart_fifo_tx_trigger_level
UART TX FIFO interrupt trigger levels.
#define UART_FR(uart_base)
#define UART_IM_CTSIM
Clear To Send modem interrupt mask.
static bool uart_is_tx_fifo_full(uint32_t uart)
Determine if the TX fifo is full.
static bool uart_is_rx_fifo_full(uint32_t uart)
Determine if the RX fifo is full.
static bool uart_is_rx_fifo_empty(uint32_t uart)
Determine if the RX fifo is empty.
static bool uart_is_tx_fifo_empty(uint32_t uart)
Determine if the TX fifo is empty.
static bool uart_is_interrupt_source(uint32_t uart, enum uart_interrupt_flag source)
Determine if interrupt is generated by the given source.