libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
UART register base addresses
Collaboration diagram for UART register base addresses:

Modules

 UART Parity Selection
 
 USART Hardware Flow Control Selection
 

Macros

#define UART0   UART0_BASE
 
#define UART1   UART1_BASE
 
#define UART2   UART2_BASE
 
#define UART3   UART3_BASE
 
#define UART4   UART4_BASE
 
#define UART5   UART5_BASE
 
#define UART_BDH(uart_base)   MMIO8((uart_base) + 0x00)
 
#define UART_BDL(uart_base)   MMIO8((uart_base) + 0x01)
 
#define UART_C1(uart_base)   MMIO8((uart_base) + 0x02)
 
#define UART_C2(uart_base)   MMIO8((uart_base) + 0x03)
 
#define UART_S1(uart_base)   MMIO8((uart_base) + 0x04)
 
#define UART_S2(uart_base)   MMIO8((uart_base) + 0x05)
 
#define UART_C3(uart_base)   MMIO8((uart_base) + 0x06)
 
#define UART_D(uart_base)   MMIO8((uart_base) + 0x07)
 
#define UART_MA1(uart_base)   MMIO8((uart_base) + 0x08)
 
#define UART_MA2(uart_base)   MMIO8((uart_base) + 0x09)
 
#define UART_C4(uart_base)   MMIO8((uart_base) + 0x0A)
 
#define UART_C5(uart_base)   MMIO8((uart_base) + 0x0B)
 
#define UART_ED(uart_base)   MMIO8((uart_base) + 0x0C)
 
#define UART_MODEM(uart_base)   MMIO8((uart_base) + 0x0D)
 
#define UART_BDH_LBKDIE   (1 << 7)
 
#define UART_BDH_RXEDGIE   (1 << 6)
 
#define UART_BDH_SBR_MASK   0x1f
 
#define UART_BDL_SBR_MASK   0xff
 
#define UART_C1_LOOPS   (1 << 7)
 
#define UART_C1_RSRC   (1 << 5)
 
#define UART_C1_M   (1 << 4)
 
#define UART_C1_WAKE   (1 << 3)
 
#define UART_C1_ILT   (1 << 2)
 
#define UART_C1_PE   (1 << 1)
 
#define UART_C1_PT   (1 << 0)
 
#define UART_C2_TIE   (1 << 7)
 
#define UART_C2_TCIE   (1 << 6)
 
#define UART_C2_RIE   (1 << 5)
 
#define UART_C2_ILIE   (1 << 4)
 
#define UART_C2_TE   (1 << 3)
 
#define UART_C2_RE   (1 << 2)
 
#define UART_C2_RWU   (1 << 1)
 
#define UART_C2_SBK   (1 << 0)
 
#define UART_S1_TDRE   (1 << 7)
 
#define UART_S1_TC   (1 << 6)
 
#define UART_S1_RDRF   (1 << 5)
 
#define UART_S1_IDLE   (1 << 4)
 
#define UART_S1_OR   (1 << 3)
 
#define UART_S1_NF   (1 << 2)
 
#define UART_S1_FE   (1 << 1)
 
#define UART_S1_PF   (1 << 0)
 
#define UART_S2_LBKDIF   (1 << 7)
 
#define UART_S2_RXEDGIF   (1 << 6)
 
#define UART_S2_MSBF   (1 << 5)
 
#define UART_S2_RXINV   (1 << 4)
 
#define UART_S2_RWUID   (1 << 3)
 
#define UART_S2_BRK13   (1 << 2)
 
#define UART_S2_LBKDE   (1 << 1)
 
#define UART_S2_RAF   (1 << 0)
 
#define UART_C3_R8   (1 << 7)
 
#define UART_C3_T8   (1 << 6)
 
#define UART_C3_TXDIR   (1 << 5)
 
#define UART_C3_TXINV   (1 << 4)
 
#define UART_C3_ORIE   (1 << 3)
 
#define UART_C3_NEIE   (1 << 2)
 
#define UART_C3_FEIE   (1 << 1)
 
#define UART_C3_PEIE   (1 << 0)
 
#define UART_MODEM_RXRTSE   (1 << 3)
 
#define UART_MODEM_TXRTSPOL   (1 << 2)
 
#define UART_MODEM_TXRTSE   (1 << 1)
 
#define UART_MODEM_TXCTSE   (1 << 0)
 
#define UART_PARITY_MASK   0x3
 
#define UART_FLOWCONTROL_MASK   (UART_MODEM_RXRTSE | UART_MODEM_TXCTSE)
 

Functions

void uart_enable (uint32_t uart)
 UART Enable. More...
 
void uart_disable (uint32_t uart)
 UART Disable. More...
 
void uart_set_baudrate (uint32_t uart, uint32_t baud)
 UART Set Baudrate. More...
 
void uart_set_parity (uint32_t uart, uint8_t parity)
 UART Set Parity. More...
 
void uart_set_flow_control (uint32_t uart, uint8_t flowcontrol)
 UART Set Hardware Flow Control. More...
 
void uart_send (uint32_t uart, uint8_t data)
 UART Send a Data Word. More...
 
void uart_send_blocking (uint32_t usart, uint8_t data)
 UART Send Data byte blocking. More...
 
void uart_wait_send_ready (uint32_t uart)
 UART Wait for Transmit Data Buffer Empty. More...
 
uint8_t uart_recv (uint32_t uart)
 UART Read a Received Data Word. More...
 
uint8_t uart_recv_blocking (uint32_t uart)
 UART Read a Received Data Word with Blocking. More...
 
void uart_wait_recv_ready (uint32_t uart)
 UART Wait for Received Data Available. More...
 

Detailed Description

Macro Definition Documentation

◆ UART0

#define UART0   UART0_BASE

Definition at line 48 of file uart.h.

◆ UART1

#define UART1   UART1_BASE

Definition at line 49 of file uart.h.

◆ UART2

#define UART2   UART2_BASE

Definition at line 50 of file uart.h.

◆ UART3

#define UART3   UART3_BASE

Definition at line 51 of file uart.h.

◆ UART4

#define UART4   UART4_BASE

Definition at line 52 of file uart.h.

◆ UART5

#define UART5   UART5_BASE

Definition at line 53 of file uart.h.

◆ UART_BDH

#define UART_BDH (   uart_base)    MMIO8((uart_base) + 0x00)

Definition at line 57 of file uart.h.

◆ UART_BDH_LBKDIE

#define UART_BDH_LBKDIE   (1 << 7)

Definition at line 76 of file uart.h.

◆ UART_BDH_RXEDGIE

#define UART_BDH_RXEDGIE   (1 << 6)

Definition at line 77 of file uart.h.

◆ UART_BDH_SBR_MASK

#define UART_BDH_SBR_MASK   0x1f

Definition at line 78 of file uart.h.

◆ UART_BDL

#define UART_BDL (   uart_base)    MMIO8((uart_base) + 0x01)

Definition at line 58 of file uart.h.

◆ UART_BDL_SBR_MASK

#define UART_BDL_SBR_MASK   0xff

Definition at line 81 of file uart.h.

◆ UART_C1

#define UART_C1 (   uart_base)    MMIO8((uart_base) + 0x02)

Definition at line 59 of file uart.h.

◆ UART_C1_ILT

#define UART_C1_ILT   (1 << 2)

Definition at line 88 of file uart.h.

◆ UART_C1_LOOPS

#define UART_C1_LOOPS   (1 << 7)

Definition at line 84 of file uart.h.

◆ UART_C1_M

#define UART_C1_M   (1 << 4)

Definition at line 86 of file uart.h.

◆ UART_C1_PE

#define UART_C1_PE   (1 << 1)

Definition at line 89 of file uart.h.

◆ UART_C1_PT

#define UART_C1_PT   (1 << 0)

Definition at line 90 of file uart.h.

◆ UART_C1_RSRC

#define UART_C1_RSRC   (1 << 5)

Definition at line 85 of file uart.h.

◆ UART_C1_WAKE

#define UART_C1_WAKE   (1 << 3)

Definition at line 87 of file uart.h.

◆ UART_C2

#define UART_C2 (   uart_base)    MMIO8((uart_base) + 0x03)

Definition at line 60 of file uart.h.

◆ UART_C2_ILIE

#define UART_C2_ILIE   (1 << 4)

Definition at line 96 of file uart.h.

◆ UART_C2_RE

#define UART_C2_RE   (1 << 2)

Definition at line 98 of file uart.h.

◆ UART_C2_RIE

#define UART_C2_RIE   (1 << 5)

Definition at line 95 of file uart.h.

◆ UART_C2_RWU

#define UART_C2_RWU   (1 << 1)

Definition at line 99 of file uart.h.

◆ UART_C2_SBK

#define UART_C2_SBK   (1 << 0)

Definition at line 100 of file uart.h.

◆ UART_C2_TCIE

#define UART_C2_TCIE   (1 << 6)

Definition at line 94 of file uart.h.

◆ UART_C2_TE

#define UART_C2_TE   (1 << 3)

Definition at line 97 of file uart.h.

◆ UART_C2_TIE

#define UART_C2_TIE   (1 << 7)

Definition at line 93 of file uart.h.

◆ UART_C3

#define UART_C3 (   uart_base)    MMIO8((uart_base) + 0x06)

Definition at line 63 of file uart.h.

◆ UART_C3_FEIE

#define UART_C3_FEIE   (1 << 1)

Definition at line 129 of file uart.h.

◆ UART_C3_NEIE

#define UART_C3_NEIE   (1 << 2)

Definition at line 128 of file uart.h.

◆ UART_C3_ORIE

#define UART_C3_ORIE   (1 << 3)

Definition at line 127 of file uart.h.

◆ UART_C3_PEIE

#define UART_C3_PEIE   (1 << 0)

Definition at line 130 of file uart.h.

◆ UART_C3_R8

#define UART_C3_R8   (1 << 7)

Definition at line 123 of file uart.h.

◆ UART_C3_T8

#define UART_C3_T8   (1 << 6)

Definition at line 124 of file uart.h.

◆ UART_C3_TXDIR

#define UART_C3_TXDIR   (1 << 5)

Definition at line 125 of file uart.h.

◆ UART_C3_TXINV

#define UART_C3_TXINV   (1 << 4)

Definition at line 126 of file uart.h.

◆ UART_C4

#define UART_C4 (   uart_base)    MMIO8((uart_base) + 0x0A)

Definition at line 67 of file uart.h.

◆ UART_C5

#define UART_C5 (   uart_base)    MMIO8((uart_base) + 0x0B)

Definition at line 68 of file uart.h.

◆ UART_D

#define UART_D (   uart_base)    MMIO8((uart_base) + 0x07)

Definition at line 64 of file uart.h.

◆ UART_ED

#define UART_ED (   uart_base)    MMIO8((uart_base) + 0x0C)

Definition at line 69 of file uart.h.

◆ UART_FLOWCONTROL_MASK

#define UART_FLOWCONTROL_MASK   (UART_MODEM_RXRTSE | UART_MODEM_TXCTSE)

Definition at line 160 of file uart.h.

◆ UART_MA1

#define UART_MA1 (   uart_base)    MMIO8((uart_base) + 0x08)

Definition at line 65 of file uart.h.

◆ UART_MA2

#define UART_MA2 (   uart_base)    MMIO8((uart_base) + 0x09)

Definition at line 66 of file uart.h.

◆ UART_MODEM

#define UART_MODEM (   uart_base)    MMIO8((uart_base) + 0x0D)

Definition at line 70 of file uart.h.

◆ UART_MODEM_RXRTSE

#define UART_MODEM_RXRTSE   (1 << 3)

Definition at line 133 of file uart.h.

◆ UART_MODEM_TXCTSE

#define UART_MODEM_TXCTSE   (1 << 0)

Definition at line 136 of file uart.h.

◆ UART_MODEM_TXRTSE

#define UART_MODEM_TXRTSE   (1 << 1)

Definition at line 135 of file uart.h.

◆ UART_MODEM_TXRTSPOL

#define UART_MODEM_TXRTSPOL   (1 << 2)

Definition at line 134 of file uart.h.

◆ UART_PARITY_MASK

#define UART_PARITY_MASK   0x3

Definition at line 147 of file uart.h.

◆ UART_S1

#define UART_S1 (   uart_base)    MMIO8((uart_base) + 0x04)

Definition at line 61 of file uart.h.

◆ UART_S1_FE

#define UART_S1_FE   (1 << 1)

Definition at line 109 of file uart.h.

◆ UART_S1_IDLE

#define UART_S1_IDLE   (1 << 4)

Definition at line 106 of file uart.h.

◆ UART_S1_NF

#define UART_S1_NF   (1 << 2)

Definition at line 108 of file uart.h.

◆ UART_S1_OR

#define UART_S1_OR   (1 << 3)

Definition at line 107 of file uart.h.

◆ UART_S1_PF

#define UART_S1_PF   (1 << 0)

Definition at line 110 of file uart.h.

◆ UART_S1_RDRF

#define UART_S1_RDRF   (1 << 5)

Definition at line 105 of file uart.h.

◆ UART_S1_TC

#define UART_S1_TC   (1 << 6)

Definition at line 104 of file uart.h.

◆ UART_S1_TDRE

#define UART_S1_TDRE   (1 << 7)

Definition at line 103 of file uart.h.

◆ UART_S2

#define UART_S2 (   uart_base)    MMIO8((uart_base) + 0x05)

Definition at line 62 of file uart.h.

◆ UART_S2_BRK13

#define UART_S2_BRK13   (1 << 2)

Definition at line 118 of file uart.h.

◆ UART_S2_LBKDE

#define UART_S2_LBKDE   (1 << 1)

Definition at line 119 of file uart.h.

◆ UART_S2_LBKDIF

#define UART_S2_LBKDIF   (1 << 7)

Definition at line 113 of file uart.h.

◆ UART_S2_MSBF

#define UART_S2_MSBF   (1 << 5)

Definition at line 115 of file uart.h.

◆ UART_S2_RAF

#define UART_S2_RAF   (1 << 0)

Definition at line 120 of file uart.h.

◆ UART_S2_RWUID

#define UART_S2_RWUID   (1 << 3)

Definition at line 117 of file uart.h.

◆ UART_S2_RXEDGIF

#define UART_S2_RXEDGIF   (1 << 6)

Definition at line 114 of file uart.h.

◆ UART_S2_RXINV

#define UART_S2_RXINV   (1 << 4)

Definition at line 116 of file uart.h.

Function Documentation

◆ uart_disable()

void uart_disable ( uint32_t  uart)

UART Disable.

At the end of the current frame, the UART is disabled to reduce power.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses

Definition at line 127 of file uart.c.

References UART_C2, UART_C2_RE, and UART_C2_TE.

◆ uart_enable()

void uart_enable ( uint32_t  uart)

UART Enable.

Enable Tramitter and Receiver

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses

Definition at line 113 of file uart.c.

References UART_C2, UART_C2_RE, and UART_C2_TE.

◆ uart_recv()

uint8_t uart_recv ( uint32_t  uart)

UART Read a Received Data Word.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses
Returns
unsigned 8 bit data word.

Definition at line 185 of file uart.c.

References UART_D.

Referenced by uart_recv_blocking().

Here is the caller graph for this function:

◆ uart_recv_blocking()

uint8_t uart_recv_blocking ( uint32_t  uart)

UART Read a Received Data Word with Blocking.

Wait until a data word has been received then return the word.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses
Returns
unsigned 16 bit data word.

Definition at line 217 of file uart.c.

References uart_recv(), and uart_wait_recv_ready().

Here is the call graph for this function:

◆ uart_send()

void uart_send ( uint32_t  uart,
uint8_t  data 
)

UART Send a Data Word.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses
[in]dataunsigned 8 bit.

Definition at line 140 of file uart.c.

References UART_D.

Referenced by uart_send_blocking().

Here is the caller graph for this function:

◆ uart_send_blocking()

void uart_send_blocking ( uint32_t  uart,
uint8_t  data 
)

UART Send Data byte blocking.

Blocks until the transmit data buffer becomes empty before sending the next (given) byte.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses
[in]dataunsigned 8 bit.

Definition at line 171 of file uart.c.

References uart_send(), and uart_wait_send_ready().

Here is the call graph for this function:

◆ uart_set_baudrate()

void uart_set_baudrate ( uint32_t  uart,
uint32_t  baud 
)

UART Set Baudrate.

The baud rate is computed from the IPG bus clock. The bus clock must be calculated by using ccm_calculate_clocks before calling this function.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses
[in]baudunsigned 32 bit. Baud rate specified in Hz.

Definition at line 53 of file uart.c.

References ccm_ipg_bus_clk, UART_BDH, UART_BDH_SBR_MASK, UART_BDL, and UART_BDL_SBR_MASK.

◆ uart_set_flow_control()

void uart_set_flow_control ( uint32_t  uart,
uint8_t  flowcontrol 
)

UART Set Hardware Flow Control.

The flow control bit can be selected as none, RTS, CTS or RTS+CTS.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses
[in]flowcontrolunsigned 8 bit. Flowcontrol uart_cr3_flowcontrol.

Definition at line 95 of file uart.c.

References UART_MODEM.

◆ uart_set_parity()

void uart_set_parity ( uint32_t  uart,
uint8_t  parity 
)

UART Set Parity.

The parity bit can be selected as none, even or odd.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses
[in]parityunsigned 8 bit. Parity UART Parity Selection.

Definition at line 76 of file uart.c.

References UART_C1.

◆ uart_wait_recv_ready()

void uart_wait_recv_ready ( uint32_t  uart)

UART Wait for Received Data Available.

Blocks until the receive data buffer holds a valid received data word.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses

Definition at line 200 of file uart.c.

References UART_S1, and UART_S1_RDRF.

Referenced by uart_recv_blocking().

Here is the caller graph for this function:

◆ uart_wait_send_ready()

void uart_wait_send_ready ( uint32_t  uart)

UART Wait for Transmit Data Buffer Empty.

Blocks until the transmit data buffer becomes empty and is ready to accept the next data word.

Parameters
[in]uartunsigned 32 bit. UART block register address base UART register base addresses

Definition at line 155 of file uart.c.

References UART_S1, and UART_S1_TC.

Referenced by uart_send_blocking().

Here is the caller graph for this function: