libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Access functions for the UART controller More...
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) |
Access functions for the UART controller
LGPL License Terms libopencm3 License
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.
[in] | uart | uint32_t uart base |
[in] | tx_pin | uint8_t TX pin number |
[in] | rx_pin | uint8_t RX pin number |
[in] | rts_pin | uint8_t RTS pin number |
[in] | cts_pin | uint8_t CTS pin number |
[in] | br | enum uart_baud baud rate |
[in] | enable_parity | bool 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().
void uart_disable | ( | uint32_t | uart | ) |
Disable the peripheral.
[in] | uart | uint32_t uart base |
Definition at line 49 of file uart.c.
References UART_ENABLE, and UART_ENABLE_DISABLED.
void uart_enable | ( | uint32_t | uart | ) |
Enable the peripheral.
[in] | uart | uint32_t uart base |
Definition at line 40 of file uart.c.
References UART_ENABLE, and UART_ENABLE_ENABLED.
void uart_send | ( | uint32_t | uart, |
uint16_t | byte | ||
) |
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().
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.
void uart_set_parity | ( | uint32_t | uart, |
int | parity | ||
) |
Definition at line 131 of file uart.c.
References UART_CONFIG, and UART_CONFIG_PARITY.
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.
[in] | uart | uart peripheral base. |
[in] | rx | RX pin. Use GPIO defines in GPIO Pin Identifiers or GPIO_UNCONNECTED if signal shall not be connected to any pin. |
[in] | tx | TX pin. Use GPIO defines in GPIO Pin Identifiers or GPIO_UNCONNECTED if signal shall not be connected to any pin. |
[in] | cts | CTS pin. Use GPIO defines in GPIO Pin Identifiers or GPIO_UNCONNECTED if signal shall not be connected to any pin. |
[in] | rts | RTS 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().
void uart_start_rx | ( | uint32_t | uart | ) |
Definition at line 156 of file uart.c.
References PERIPH_TRIGGER_TASK, and UART_TASK_STARTRX.
void uart_start_tx | ( | uint32_t | uart | ) |
Definition at line 141 of file uart.c.
References PERIPH_TRIGGER_TASK, and UART_TASK_STARTTX.
void uart_stop_rx | ( | uint32_t | uart | ) |
Definition at line 166 of file uart.c.
References PERIPH_TRIGGER_TASK, and UART_TASK_STOPRX.
void uart_stop_tx | ( | uint32_t | uart | ) |
Definition at line 151 of file uart.c.
References PERIPH_TRIGGER_TASK, and UART_TASK_STOPTX.