libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
UART transmission and reception

Sending and receiving data through the UART More...

Collaboration diagram for UART transmission and reception:

Functions

void uart_send (uint32_t uart, uint16_t data)
 UART Send a Data Word. More...
 
uint16_t uart_recv (uint32_t uart)
 UART Read a Received Data Word. More...
 
void uart_wait_send_ready (uint32_t uart)
 UART Wait for Transmit Data Buffer Not Full. More...
 
void uart_wait_recv_ready (uint32_t uart)
 UART Wait for Received Data Available. More...
 
void uart_send_blocking (uint32_t uart, uint16_t data)
 UART Send Data Word with Blocking. More...
 
uint16_t uart_recv_blocking (uint32_t uart)
 UART Read a Received Data Word with Blocking. More...
 

Detailed Description

Sending and receiving data through the UART

Primitives for sending and receiving data are provided, uart_send() and uart_recv(). These primitives do not check if data can be transmitted or wait for data. If waiting until data is available or can be transmitted is desired, blocking primitives are also available, uart_send_blocking() and uart_recv_blocking().

These primitives only handle one byte at at time, and thus may be unsuited for some applications. You may also consider using UART DMA control.

Function Documentation

◆ uart_recv()

uint16_t uart_recv ( uint32_t  uart)

UART Read a Received Data Word.

Parameters
[in]uartUART block register address base UART register base addresses
Returns
data from the Rx FIFO.

Definition at line 287 of file uart.c.

References UART_DR, and UART_DR_DATA_MASK.

Referenced by uart_recv_blocking().

Here is the caller graph for this function:

◆ uart_recv_blocking()

uint16_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]uartUART block register address base UART register base addresses
Returns
data from the Rx FIFO.

Definition at line 344 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,
uint16_t  data 
)

UART Send a Data Word.

Parameters
[in]uartUART block register address base UART register base addresses
[in]datadata to send.

Definition at line 275 of file uart.c.

References UART_DR.

Referenced by uart_send_blocking().

Here is the caller graph for this function:

◆ uart_send_blocking()

void uart_send_blocking ( uint32_t  uart,
uint16_t  data 
)

UART Send Data Word with Blocking.

Blocks until the transmit data FIFO can accept the next data word for transmission.

Parameters
[in]uartUART block register address base UART register base addresses

Definition at line 330 of file uart.c.

References uart_send(), and uart_wait_send_ready().

Here is the call graph for this function:

◆ uart_wait_recv_ready()

void uart_wait_recv_ready ( uint32_t  uart)

UART Wait for Received Data Available.

Blocks until the receive data FIFO holds a at least valid received data word.

Parameters
[in]uartUART block register address base UART register base addresses

Definition at line 316 of file uart.c.

References UART_FR, and UART_FR_RXFE.

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 Not Full.

Blocks until the transmit data FIFO is not empty and can accept the next data word.
Even if the FIFO is not empty, this function will return as long as there is room for at least one more word.

Parameters
[in]uartUART block register address base UART register base addresses

Definition at line 303 of file uart.c.

References UART_FR, and UART_FR_TXFF.

Referenced by uart_send_blocking().

Here is the caller graph for this function: