libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
UART peripheral API

Access functions for the UART controller More...

Collaboration diagram for UART peripheral API:

Functions

void uart_enable (uint32_t uart)
 Enable the peripheral. More...
 
void uart_disable (uint32_t uart)
 Disable the peripheral. More...
 
void uart_configure (uint32_t uart, uint32_t tx_pin, uint32_t rx_pin, uint32_t rts_pin, uint32_t cts_pin, enum uart_baud br, bool enable_parity)
 Configure UART parameters in single call. More...
 
void uart_set_pins (uint32_t uart, uint32_t rx, uint32_t tx, uint32_t cts, uint32_t rts)
 Select GPIO pins to be used by this peripheral. More...
 
void uart_set_baudrate (uint32_t uart, enum uart_baud br)
 
void uart_set_parity (uint32_t uart, int parity)
 
void uart_set_flow_control (uint32_t uart, int flow)
 
void uart_start_tx (uint32_t uart)
 
void uart_send (uint32_t uart, uint16_t byte)
 
void uart_stop_tx (uint32_t uart)
 
void uart_start_rx (uint32_t uart)
 
uint16_t uart_recv (uint32_t uart)
 
void uart_stop_rx (uint32_t uart)
 

Detailed Description

Access functions for the UART controller

LGPL License Terms libopencm3 License

Author
© 2016 Maxim Sloyko maxim.nosp@m.s@go.nosp@m.ogle..nosp@m.com

Function Documentation

◆ uart_configure()

void uart_configure ( uint32_t  uart,
uint32_t  tx_pin,
uint32_t  rx_pin,
uint32_t  rts_pin,
uint32_t  cts_pin,
enum uart_baud  br,
bool  enable_parity 
)

Configure UART parameters in single call.

Any pin number can be set to 0xff (or any number larger than UART_MAX_PIN) to disconnect that pin.

Parameters
[in]uartuint32_t uart base
[in]tx_pinuint8_t TX pin number
[in]rx_pinuint8_t RX pin number
[in]rts_pinuint8_t RTS pin number
[in]cts_pinuint8_t CTS pin number
[in]brenum uart_baud baud rate
[in]enable_paritybool If true, enable parity bit

Definition at line 67 of file uart.c.

References UART_CONFIG, UART_CONFIG_HWFC, UART_CONFIG_PARITY, UART_MAX_PIN, uart_set_baudrate(), and uart_set_pins().

Here is the call graph for this function:

◆ uart_disable()

void uart_disable ( uint32_t  uart)

Disable the peripheral.

Parameters
[in]uartuint32_t uart base

Definition at line 49 of file uart.c.

References UART_ENABLE, and UART_ENABLE_DISABLED.

◆ uart_enable()

void uart_enable ( uint32_t  uart)

Enable the peripheral.

Parameters
[in]uartuint32_t uart base

Definition at line 40 of file uart.c.

References UART_ENABLE, and UART_ENABLE_ENABLED.

◆ uart_recv()

uint16_t uart_recv ( uint32_t  uart)

Definition at line 161 of file uart.c.

References UART_RXD.

◆ uart_send()

void uart_send ( uint32_t  uart,
uint16_t  byte 
)

Definition at line 146 of file uart.c.

References UART_TXD.

◆ uart_set_baudrate()

void uart_set_baudrate ( uint32_t  uart,
enum uart_baud  br 
)

Definition at line 126 of file uart.c.

References UART_BAUDRATE.

Referenced by uart_configure().

Here is the caller graph for this function:

◆ uart_set_flow_control()

void uart_set_flow_control ( uint32_t  uart,
int  flow 
)

Definition at line 136 of file uart.c.

References UART_CONFIG, and UART_CONFIG_HWFC.

◆ uart_set_parity()

void uart_set_parity ( uint32_t  uart,
int  parity 
)

Definition at line 131 of file uart.c.

References UART_CONFIG, and UART_CONFIG_PARITY.

◆ uart_set_pins()

void uart_set_pins ( uint32_t  uart,
uint32_t  rx,
uint32_t  tx,
uint32_t  cts,
uint32_t  rts 
)

Select GPIO pins to be used by this peripheral.

This needs to be configured while UART peripheral is disabled.

Parameters
[in]uartuart peripheral base.
[in]rxRX pin. Use GPIO defines in GPIO Pin Identifiers or GPIO_UNCONNECTED if signal shall not be connected to any pin.
[in]txTX pin. Use GPIO defines in GPIO Pin Identifiers or GPIO_UNCONNECTED if signal shall not be connected to any pin.
[in]ctsCTS pin. Use GPIO defines in GPIO Pin Identifiers or GPIO_UNCONNECTED if signal shall not be connected to any pin.
[in]rtsRTS pin. Use GPIO defines in GPIO Pin Identifiers or GPIO_UNCONNECTED if signal shall not be connected to any pin.

Definition at line 97 of file uart.c.

References __GPIO2PIN, GPIO_UNCONNECTED, UART_PSELCTS, UART_PSELRTS, UART_PSELRXD, and UART_PSELTXD.

Referenced by uart_configure().

Here is the caller graph for this function:

◆ uart_start_rx()

void uart_start_rx ( uint32_t  uart)

Definition at line 156 of file uart.c.

References PERIPH_TRIGGER_TASK, and UART_TASK_STARTRX.

◆ uart_start_tx()

void uart_start_tx ( uint32_t  uart)

Definition at line 141 of file uart.c.

References PERIPH_TRIGGER_TASK, and UART_TASK_STARTTX.

◆ uart_stop_rx()

void uart_stop_rx ( uint32_t  uart)

Definition at line 166 of file uart.c.

References PERIPH_TRIGGER_TASK, and UART_TASK_STOPRX.

◆ uart_stop_tx()

void uart_stop_tx ( uint32_t  uart)

Definition at line 151 of file uart.c.

References PERIPH_TRIGGER_TASK, and UART_TASK_STOPTX.