USART - Synchronous/Asynchronous Serial
Description
Universal Synchronous/Asynchronous Receiver/Transmitter Peripheral API.
The Universal Synchronous/Asynchronous Receiver/Transmitter (USART) is a very flexible serial I/O module. It supports full duplex asynchronous UART communication as well as RS-485, SPI, MicroWire, and 3-wire. It can also interface with ISO7816 Smart-Cards, and IrDA devices.
The USART has a wide selection of operating modes, frame formats, and baud rates. All features are supported through the API of this module.
Triple buffering and DMA support makes high data-rates possible with minimal CPU intervention. It is possible to transmit and receive large frames while the MCU remains in EM1 Sleep.
This module does not support DMA configuration. The UARTDRV and SPIDRV drivers provide full support for DMA and more.
The following steps are necessary for basic operation:
Clock enable:
To initialize the USART for asynchronous operation (e.g., UART):
To initialize the USART for synchronous operation (e.g., SPI):
After pins are assigned for the application/board, enable pins at the desired location. Available locations can be obtained from the Pin Definitions section in the data sheet.
- Note
- UARTDRV supports all types of UART flow control. Software assisted hardware flow control is available for parts without true UART hardware flow control.
Data Structures |
|
struct | USART_InitAsync_TypeDef |
Asynchronous mode initialization structure.
|
|
struct | USART_PrsTriggerInit_TypeDef |
USART PRS trigger enable.
|
|
struct | USART_InitSync_TypeDef |
Synchronous mode initialization structure.
|
|
struct | USART_InitIrDA_TypeDef |
IrDA mode initialization structure.
|
|
struct | USART_InitI2s_TypeDef |
I2S mode initialization structure.
|
|
Functions |
|
void | USART_BaudrateAsyncSet (USART_TypeDef *usart, uint32_t refFreq, uint32_t baudrate, USART_OVS_TypeDef ovs) |
Configure USART/UART operating in asynchronous mode to use a given baudrate (or as close as possible to a specified baudrate).
|
|
uint32_t | USART_BaudrateCalc (uint32_t refFreq, uint32_t clkdiv, bool syncmode, USART_OVS_TypeDef ovs) |
Calculate baudrate for USART/UART given reference frequency, clock division, and oversampling rate (if async mode).
|
|
uint32_t | USART_BaudrateGet (USART_TypeDef *usart) |
Get the current baudrate for USART/UART.
|
|
void | USART_BaudrateSyncSet (USART_TypeDef *usart, uint32_t refFreq, uint32_t baudrate) |
Configure the USART operating in synchronous mode to use a given baudrate (or as close as possible to a specified baudrate).
|
|
void | USART_Enable (USART_TypeDef *usart, USART_Enable_TypeDef enable) |
Enable/disable USART/UART receiver and/or transmitter.
|
|
void | USART_InitAsync (USART_TypeDef *usart, const USART_InitAsync_TypeDef *init) |
Initialize USART/UART for normal asynchronous mode.
|
|
void | USART_InitSync (USART_TypeDef *usart, const USART_InitSync_TypeDef *init) |
Initialize USART for synchronous mode.
|
|
void | USARTn_InitIrDA (USART_TypeDef *usart, const USART_InitIrDA_TypeDef *init) |
Initialize USART for asynchronous IrDA mode.
|
|
void | USART_InitI2s (USART_TypeDef *usart, USART_InitI2s_TypeDef *init) |
Initialize USART for I2S mode.
|
|
void | USART_InitPrsTrigger (USART_TypeDef *usart, const USART_PrsTriggerInit_TypeDef *init) |
Initialize the automatic transmissions using PRS channel as a trigger.
|
|
void | USART_IntClear (USART_TypeDef *usart, uint32_t flags) |
Clear one or more pending USART interrupts.
|
|
void | USART_IntDisable (USART_TypeDef *usart, uint32_t flags) |
Disable one or more USART interrupts.
|
|
void | USART_IntEnable (USART_TypeDef *usart, uint32_t flags) |
Enable one or more USART interrupts.
|
|
uint32_t | USART_IntGet (USART_TypeDef *usart) |
Get pending USART interrupt flags.
|
|
uint32_t | USART_IntGetEnabled (USART_TypeDef *usart) |
Get enabled and pending USART interrupt flags.
|
|
void | USART_IntSet (USART_TypeDef *usart, uint32_t flags) |
Set one or more pending USART interrupts from SW.
|
|
uint32_t | USART_StatusGet (USART_TypeDef *usart) |
Get USART STATUS register.
|
|
void | USART_Reset (USART_TypeDef *usart) |
Reset USART/UART to the same state that it was in after a hardware reset.
|
|
uint8_t | USART_Rx (USART_TypeDef *usart) |
Receive one 4-8 bit frame, (or part of 10-16 bit frame).
|
|
uint16_t | USART_RxDouble (USART_TypeDef *usart) |
Receive two 4-8 bit frames or one 10-16 bit frame.
|
|
uint32_t | USART_RxDoubleExt (USART_TypeDef *usart) |
Receive two 4-9 bit frames, or one 10-16 bit frame with extended information.
|
|
uint16_t | USART_RxExt (USART_TypeDef *usart) |
Receive one 4-9 bit frame (or part of 10-16 bit frame) with extended information.
|
|
uint8_t | USART_RxDataGet (USART_TypeDef *usart) |
Receive one 4-8 bit frame, (or part of 10-16 bit frame).
|
|
uint16_t | USART_RxDoubleGet (USART_TypeDef *usart) |
Receive two 4-8 bit frames, or one 10-16 bit frame.
|
|
uint32_t | USART_RxDoubleXGet (USART_TypeDef *usart) |
Receive two 4-9 bit frames, or one 10-16 bit frame with extended information.
|
|
uint16_t | USART_RxDataXGet (USART_TypeDef *usart) |
Receive one 4-9 bit frame, (or part of 10-16 bit frame) with extended information.
|
|
uint8_t | USART_SpiTransfer (USART_TypeDef *usart, uint8_t data) |
Perform one 8 bit frame SPI transfer.
|
|
void | USART_Tx (USART_TypeDef *usart, uint8_t data) |
Transmit one 4-9 bit frame.
|
|
void | USART_TxDouble (USART_TypeDef *usart, uint16_t data) |
Transmit two 4-9 bit frames or one 10-16 bit frame.
|
|
void | USART_TxDoubleExt (USART_TypeDef *usart, uint32_t data) |
Transmit two 4-9 bit frames or one 10-16 bit frame with extended control.
|
|
void | USART_TxExt (USART_TypeDef *usart, uint16_t data) |