EFR32 Mighty Gecko 1 Software Documentation  efr32mg1-doc-5.1.2
em_usart.h File Reference

Detailed Description

Universal synchronous/asynchronous receiver/transmitter (USART/UART) peripheral API.

Version
5.1.2

License

Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no obligation to support this Software. Silicon Labs is providing the Software "AS IS", with no express or implied warranties of any kind, including, but not limited to, any implied warranties of merchantability or fitness for any particular purpose or warranties against infringement of any proprietary rights of a third party.

Silicon Labs will not be liable for any consequential, incidental, or special damages, or any other relief, or for any claim by any third party, arising from your use of this Software.

Definition in file em_usart.h.

#include "em_device.h"
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  USART_InitAsync_TypeDef
 
struct  USART_InitI2s_TypeDef
 
struct  USART_InitIrDA_TypeDef
 
struct  USART_InitSync_TypeDef
 
struct  USART_PrsTriggerInit_TypeDef
 

Macros

#define USART_INITASYNC_DEFAULT
 
#define USART_INITI2S_DEFAULT
 
#define USART_INITIRDA_DEFAULT
 
#define USART_INITPRSTRIGGER_DEFAULT
 
#define USART_INITSYNC_DEFAULT
 

Enumerations

enum  USART_ClockMode_TypeDef {
  usartClockMode0 = USART_CTRL_CLKPOL_IDLELOW | USART_CTRL_CLKPHA_SAMPLELEADING,
  usartClockMode1 = USART_CTRL_CLKPOL_IDLELOW | USART_CTRL_CLKPHA_SAMPLETRAILING,
  usartClockMode2 = USART_CTRL_CLKPOL_IDLEHIGH | USART_CTRL_CLKPHA_SAMPLELEADING,
  usartClockMode3 = USART_CTRL_CLKPOL_IDLEHIGH | USART_CTRL_CLKPHA_SAMPLETRAILING
}
 
enum  USART_Databits_TypeDef {
  usartDatabits4 = USART_FRAME_DATABITS_FOUR,
  usartDatabits5 = USART_FRAME_DATABITS_FIVE,
  usartDatabits6 = USART_FRAME_DATABITS_SIX,
  usartDatabits7 = USART_FRAME_DATABITS_SEVEN,
  usartDatabits8 = USART_FRAME_DATABITS_EIGHT,
  usartDatabits9 = USART_FRAME_DATABITS_NINE,
  usartDatabits10 = USART_FRAME_DATABITS_TEN,
  usartDatabits11 = USART_FRAME_DATABITS_ELEVEN,
  usartDatabits12 = USART_FRAME_DATABITS_TWELVE,
  usartDatabits13 = USART_FRAME_DATABITS_THIRTEEN,
  usartDatabits14 = USART_FRAME_DATABITS_FOURTEEN,
  usartDatabits15 = USART_FRAME_DATABITS_FIFTEEN,
  usartDatabits16 = USART_FRAME_DATABITS_SIXTEEN
}
 
enum  USART_Enable_TypeDef {
  usartDisable = 0x0,
  usartEnableRx = USART_CMD_RXEN,
  usartEnableTx = USART_CMD_TXEN,
  usartEnable = (USART_CMD_RXEN | USART_CMD_TXEN)
}
 
enum  USART_I2sFormat_TypeDef {
  usartI2sFormatW32D32 = USART_I2SCTRL_FORMAT_W32D32,
  usartI2sFormatW32D24M = USART_I2SCTRL_FORMAT_W32D24M,
  usartI2sFormatW32D24 = USART_I2SCTRL_FORMAT_W32D24,
  usartI2sFormatW32D16 = USART_I2SCTRL_FORMAT_W32D16,
  usartI2sFormatW32D8 = USART_I2SCTRL_FORMAT_W32D8,
  usartI2sFormatW16D16 = USART_I2SCTRL_FORMAT_W16D16,
  usartI2sFormatW16D8 = USART_I2SCTRL_FORMAT_W16D8,
  usartI2sFormatW8D8 = USART_I2SCTRL_FORMAT_W8D8
}
 
enum  USART_I2sJustify_TypeDef {
  usartI2sJustifyLeft = USART_I2SCTRL_JUSTIFY_LEFT,
  usartI2sJustifyRight = USART_I2SCTRL_JUSTIFY_RIGHT
}
 
enum  USART_IrDAPrsSel_Typedef {
  usartIrDAPrsCh0 = USART_IRCTRL_IRPRSSEL_PRSCH0,
  usartIrDAPrsCh1 = USART_IRCTRL_IRPRSSEL_PRSCH1,
  usartIrDAPrsCh2 = USART_IRCTRL_IRPRSSEL_PRSCH2,
  usartIrDAPrsCh3 = USART_IRCTRL_IRPRSSEL_PRSCH3,
  usartIrDAPrsCh4 = USART_IRCTRL_IRPRSSEL_PRSCH4,
  usartIrDAPrsCh5 = USART_IRCTRL_IRPRSSEL_PRSCH5,
  usartIrDAPrsCh6 = USART_IRCTRL_IRPRSSEL_PRSCH6,
  usartIrDAPrsCh7 = USART_IRCTRL_IRPRSSEL_PRSCH7
}
 
enum  USART_IrDAPw_Typedef {
  usartIrDAPwONE = USART_IRCTRL_IRPW_ONE,
  usartIrDAPwTWO = USART_IRCTRL_IRPW_TWO,
  usartIrDAPwTHREE = USART_IRCTRL_IRPW_THREE,
  usartIrDAPwFOUR = USART_IRCTRL_IRPW_FOUR
}
 
enum  USART_OVS_TypeDef {
  usartOVS16 = USART_CTRL_OVS_X16,
  usartOVS8 = USART_CTRL_OVS_X8,
  usartOVS6 = USART_CTRL_OVS_X6,
  usartOVS4 = USART_CTRL_OVS_X4
}
 
enum  USART_Parity_TypeDef {
  usartNoParity = USART_FRAME_PARITY_NONE,
  usartEvenParity = USART_FRAME_PARITY_EVEN,
  usartOddParity = USART_FRAME_PARITY_ODD
}
 
enum  USART_PrsRxCh_TypeDef {
  usartPrsRxCh0 = USART_INPUT_RXPRSSEL_PRSCH0,
  usartPrsRxCh1 = USART_INPUT_RXPRSSEL_PRSCH1,
  usartPrsRxCh2 = USART_INPUT_RXPRSSEL_PRSCH2,
  usartPrsRxCh3 = USART_INPUT_RXPRSSEL_PRSCH3,
  usartPrsRxCh4 = USART_INPUT_RXPRSSEL_PRSCH4,
  usartPrsRxCh5 = USART_INPUT_RXPRSSEL_PRSCH5,
  usartPrsRxCh6 = USART_INPUT_RXPRSSEL_PRSCH6,
  usartPrsRxCh7 = USART_INPUT_RXPRSSEL_PRSCH7,
  usartPrsRxCh8 = USART_INPUT_RXPRSSEL_PRSCH8,
  usartPrsRxCh9 = USART_INPUT_RXPRSSEL_PRSCH9,
  usartPrsRxCh10 = USART_INPUT_RXPRSSEL_PRSCH10,
  usartPrsRxCh11 = USART_INPUT_RXPRSSEL_PRSCH11
}
 
enum  USART_PrsTriggerCh_TypeDef {
  usartPrsTriggerCh0 = USART_TRIGCTRL_TSEL_PRSCH0,
  usartPrsTriggerCh1 = USART_TRIGCTRL_TSEL_PRSCH1,
  usartPrsTriggerCh2 = USART_TRIGCTRL_TSEL_PRSCH2,
  usartPrsTriggerCh3 = USART_TRIGCTRL_TSEL_PRSCH3,
  usartPrsTriggerCh4 = USART_TRIGCTRL_TSEL_PRSCH4,
  usartPrsTriggerCh5 = USART_TRIGCTRL_TSEL_PRSCH5,
  usartPrsTriggerCh6 = USART_TRIGCTRL_TSEL_PRSCH6,
  usartPrsTriggerCh7 = USART_TRIGCTRL_TSEL_PRSCH7
}
 
enum  USART_Stopbits_TypeDef {
  usartStopbits0p5 = USART_FRAME_STOPBITS_HALF,
  usartStopbits1 = USART_FRAME_STOPBITS_ONE,
  usartStopbits1p5 = USART_FRAME_STOPBITS_ONEANDAHALF,
  usartStopbits2 = USART_FRAME_STOPBITS_TWO
}
 

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 specified baudrate). More...
 
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). More...
 
uint32_t USART_BaudrateGet (USART_TypeDef *usart)
 Get current baudrate for USART/UART. More...
 
void USART_BaudrateSyncSet (USART_TypeDef *usart, uint32_t refFreq, uint32_t baudrate)
 Configure USART operating in synchronous mode to use a given baudrate (or as close as possible to specified baudrate). More...
 
void USART_Enable (USART_TypeDef *usart, USART_Enable_TypeDef enable)
 Enable/disable USART/UART receiver and/or transmitter. More...
 
void USART_InitAsync (USART_TypeDef *usart, const USART_InitAsync_TypeDef *init)
 Init USART/UART for normal asynchronous mode. More...
 
void USART_InitI2s (USART_TypeDef *usart, USART_InitI2s_TypeDef *init)
 Init USART for I2S mode. More...
 
__STATIC_INLINE void USART_InitIrDA (const USART_InitIrDA_TypeDef *init)
 Init DEFAULT_IRDA_USART for asynchronous IrDA mode. More...
 
void USART_InitPrsTrigger (USART_TypeDef *usart, const USART_PrsTriggerInit_TypeDef *init)
 Initialize automatic transmissions using PRS channel as trigger. More...
 
void USART_InitSync (USART_TypeDef *usart, const USART_InitSync_TypeDef *init)
 Init USART for synchronous mode. More...
 
__STATIC_INLINE void USART_IntClear (USART_TypeDef *usart, uint32_t flags)
 Clear one or more pending USART interrupts. More...
 
__STATIC_INLINE void USART_IntDisable (USART_TypeDef *usart, uint32_t flags)
 Disable one or more USART interrupts. More...
 
__STATIC_INLINE void USART_IntEnable (USART_TypeDef *usart, uint32_t flags)
 Enable one or more USART interrupts. More...
 
__STATIC_INLINE uint32_t USART_IntGet (USART_TypeDef *usart)
 Get pending USART interrupt flags. More...
 
__STATIC_INLINE uint32_t USART_IntGetEnabled (USART_TypeDef *usart)
 Get enabled and pending USART interrupt flags. Useful for handling more interrupt sources in the same interrupt handler. More...
 
__STATIC_INLINE void USART_IntSet (USART_TypeDef *usart, uint32_t flags)
 Set one or more pending USART interrupts from SW. More...
 
void USART_Reset (USART_TypeDef *usart)
 Reset USART/UART to same state as after a HW reset. More...
 
uint8_t USART_Rx (USART_TypeDef *usart)
 Receive one 4-8 bit frame, (or part of 10-16 bit frame). More...
 
__STATIC_INLINE uint8_t USART_RxDataGet (USART_TypeDef *usart)
 Receive one 4-8 bit frame, (or part of 10-16 bit frame). More...
 
__STATIC_INLINE uint16_t USART_RxDataXGet (USART_TypeDef *usart)
 Receive one 4-9 bit frame, (or part of 10-16 bit frame) with extended information. More...
 
uint16_t USART_RxDouble (USART_TypeDef *usart)
 Receive two 4-8 bit frames, or one 10-16 bit frame. More...
 
uint32_t USART_RxDoubleExt (USART_TypeDef *usart)
 Receive two 4-9 bit frames, or one 10-16 bit frame with extended information. More...
 
__STATIC_INLINE uint16_t USART_RxDoubleGet (USART_TypeDef *usart)
 Receive two 4-8 bit frames, or one 10-16 bit frame. More...
 
__STATIC_INLINE uint32_t USART_RxDoubleXGet (USART_TypeDef *usart)
 Receive two 4-9 bit frames, or one 10-16 bit frame with extended information. More...
 
uint16_t USART_RxExt (USART_TypeDef *usart)
 Receive one 4-9 bit frame, (or part of 10-16 bit frame) with extended information. More...
 
uint8_t USART_SpiTransfer (USART_TypeDef *usart, uint8_t data)
 Perform one 8 bit frame SPI transfer. More...
 
__STATIC_INLINE uint32_t USART_StatusGet (USART_TypeDef *usart)
 Get USART STATUS register. More...
 
void USART_Tx (USART_TypeDef *usart, uint8_t data)
 Transmit one 4-9 bit frame. More...
 
void USART_TxDouble (USART_TypeDef *usart, uint16_t data)
 Transmit two 4-9 bit frames, or one 10-16 bit frame. More...
 
void USART_TxDoubleExt (USART_TypeDef *usart, uint32_t data)
 Transmit two 4-9 bit frames, or one 10-16 bit frame with extended control. More...
 
void USART_TxExt (USART_TypeDef *usart, uint16_t data)
 Transmit one 4-9 bit frame with extended control. More...
 
void USARTn_InitIrDA (USART_TypeDef *usart, const USART_InitIrDA_TypeDef *init)
 Init USART for asynchronous IrDA mode. More...