libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
USART Defines

Defined Constants and Types for the STM32L1xx USART More...

Collaboration diagram for USART Defines:

Modules

 USART Parity Selection
 
 USART Tx/Rx Mode Selection
 
 USART Stop Bit Selection
 
 USART Hardware Flow Control Selection
 
 USART register base addresses
 Holds all the U(S)ART peripherals supported.
 
 U(S)ART convenience Flags
 We define the "common" lower flag bits using a standard name, allowing them to be used regardless of which usart peripheral version you have.
 
 USART Status register Flags
 

Macros

#define USART_PARITY_MASK   (USART_CR1_PS | USART_CR1_PCE)
 
#define USART_MODE_MASK   (USART_CR1_RE | USART_CR1_TE)
 
#define USART_CR2_STOPBITS_1   (0x00 << 12) /* 1 stop bit */
 
#define USART_CR2_STOPBITS_0_5   (0x01 << 12) /* 0.5 stop bits */
 
#define USART_CR2_STOPBITS_2   (0x02 << 12) /* 2 stop bits */
 
#define USART_CR2_STOPBITS_1_5   (0x03 << 12) /* 1.5 stop bits */
 
#define USART_CR2_STOPBITS_MASK   (0x03 << 12)
 
#define USART_CR2_STOPBITS_SHIFT   12
 
#define USART_FLOWCONTROL_MASK   (USART_CR3_RTSE | USART_CR3_CTSE)
 
#define USART_SR(usart_base)   MMIO32((usart_base) + 0x00)
 
#define USART1_SR   USART_SR(USART1_BASE)
 
#define USART2_SR   USART_SR(USART2_BASE)
 
#define USART3_SR   USART_SR(USART3_BASE)
 
#define UART4_SR   USART_SR(UART4_BASE)
 
#define UART5_SR   USART_SR(UART5_BASE)
 
#define USART_DR(usart_base)   MMIO32((usart_base) + 0x04)
 
#define USART1_DR   USART_DR(USART1_BASE)
 
#define USART2_DR   USART_DR(USART2_BASE)
 
#define USART3_DR   USART_DR(USART3_BASE)
 
#define UART4_DR   USART_DR(UART4_BASE)
 
#define UART5_DR   USART_DR(UART5_BASE)
 
#define USART_BRR(usart_base)   MMIO32((usart_base) + 0x08)
 
#define USART1_BRR   USART_BRR(USART1_BASE)
 
#define USART2_BRR   USART_BRR(USART2_BASE)
 
#define USART3_BRR   USART_BRR(USART3_BASE)
 
#define UART4_BRR   USART_BRR(UART4_BASE)
 
#define UART5_BRR   USART_BRR(UART5_BASE)
 
#define USART_CR1(usart_base)   MMIO32((usart_base) + 0x0c)
 
#define USART1_CR1   USART_CR1(USART1_BASE)
 
#define USART2_CR1   USART_CR1(USART2_BASE)
 
#define USART3_CR1   USART_CR1(USART3_BASE)
 
#define UART4_CR1   USART_CR1(UART4_BASE)
 
#define UART5_CR1   USART_CR1(UART5_BASE)
 
#define USART_CR2(usart_base)   MMIO32((usart_base) + 0x10)
 
#define USART1_CR2   USART_CR2(USART1_BASE)
 
#define USART2_CR2   USART_CR2(USART2_BASE)
 
#define USART3_CR2   USART_CR2(USART3_BASE)
 
#define UART4_CR2   USART_CR2(UART4_BASE)
 
#define UART5_CR2   USART_CR2(UART5_BASE)
 
#define USART_CR3(usart_base)   MMIO32((usart_base) + 0x14)
 
#define USART1_CR3   USART_CR3(USART1_BASE)
 
#define USART2_CR3   USART_CR3(USART2_BASE)
 
#define USART3_CR3   USART_CR3(USART3_BASE)
 
#define UART4_CR3   USART_CR3(UART4_BASE)
 
#define UART5_CR3   USART_CR3(UART5_BASE)
 
#define USART_GTPR(usart_base)   MMIO32((usart_base) + 0x18)
 
#define USART1_GTPR   USART_GTPR(USART1_BASE)
 
#define USART2_GTPR   USART_GTPR(USART2_BASE)
 
#define USART3_GTPR   USART_GTPR(USART3_BASE)
 
#define UART4_GTPR   USART_GTPR(UART4_BASE)
 
#define UART5_GTPR   USART_GTPR(UART5_BASE)
 
#define USART_DR_MASK   0x1FF
 
#define USART_BRR_DIV_MANTISSA_MASK   (0xFFF << 4)
 
#define USART_BRR_DIV_FRACTION_MASK   0xF
 
#define USART_CR1_UE   (1 << 13)
 
#define USART_CR1_M   (1 << 12)
 
#define USART_CR1_WAKE   (1 << 11)
 
#define USART_CR1_PCE   (1 << 10)
 
#define USART_CR1_PS   (1 << 9)
 
#define USART_CR1_PEIE   (1 << 8)
 
#define USART_CR1_TXEIE   (1 << 7)
 
#define USART_CR1_TCIE   (1 << 6)
 
#define USART_CR1_RXNEIE   (1 << 5)
 
#define USART_CR1_IDLEIE   (1 << 4)
 
#define USART_CR1_TE   (1 << 3)
 
#define USART_CR1_RE   (1 << 2)
 
#define USART_CR1_RWU   (1 << 1)
 
#define USART_CR1_SBK   (1 << 0)
 
#define USART_CR2_LINEN   (1 << 14)
 
#define USART_CR2_CLKEN   (1 << 11)
 
#define USART_CR2_CPOL   (1 << 10)
 
#define USART_CR2_CPHA   (1 << 9)
 
#define USART_CR2_LBCL   (1 << 8)
 
#define USART_CR2_LBDIE   (1 << 6)
 
#define USART_CR2_LBDL   (1 << 5)
 
#define USART_CR2_ADD_MASK   0xF
 
#define USART_CR3_CTSIE   (1 << 10)
 
#define USART_CR3_CTSE   (1 << 9)
 
#define USART_CR3_RTSE   (1 << 8)
 
#define USART_CR3_DMAT   (1 << 7)
 
#define USART_CR3_DMAR   (1 << 6)
 
#define USART_CR3_SCEN   (1 << 5)
 
#define USART_CR3_NACK   (1 << 4)
 
#define USART_CR3_HDSEL   (1 << 3)
 
#define USART_CR3_IRLP   (1 << 2)
 
#define USART_CR3_IREN   (1 << 1)
 
#define USART_CR3_EIE   (1 << 0)
 
#define USART_GTPR_GT_MASK   (0xFF << 8)
 
#define USART_GTPR_PSC_MASK   0xFF
 

Functions

void usart_set_baudrate (uint32_t usart, uint32_t baud)
 USART Set Baudrate. More...
 
void usart_set_databits (uint32_t usart, uint32_t bits)
 USART Set Word Length. More...
 
void usart_set_stopbits (uint32_t usart, uint32_t stopbits)
 USART Set Stop Bit(s). More...
 
void usart_set_parity (uint32_t usart, uint32_t parity)
 USART Set Parity. More...
 
void usart_set_mode (uint32_t usart, uint32_t mode)
 USART Set Rx/Tx Mode. More...
 
void usart_set_flow_control (uint32_t usart, uint32_t flowcontrol)
 USART Set Hardware Flow Control. More...
 
void usart_enable (uint32_t usart)
 USART Enable. More...
 
void usart_disable (uint32_t usart)
 USART Disable. More...
 
void usart_send (uint32_t usart, uint16_t data)
 USART Send a Data Word. More...
 
uint16_t usart_recv (uint32_t usart)
 USART Read a Received Data Word. More...
 
void usart_wait_send_ready (uint32_t usart)
 USART Wait for Transmit Data Buffer Empty. More...
 
void usart_wait_recv_ready (uint32_t usart)
 USART Wait for Received Data Available. More...
 
void usart_send_blocking (uint32_t usart, uint16_t data)
 USART Send Data Word with Blocking. More...
 
uint16_t usart_recv_blocking (uint32_t usart)
 USART Read a Received Data Word with Blocking. More...
 
void usart_enable_rx_dma (uint32_t usart)
 USART Receiver DMA Enable. More...
 
void usart_disable_rx_dma (uint32_t usart)
 USART Receiver DMA Disable. More...
 
void usart_enable_tx_dma (uint32_t usart)
 USART Transmitter DMA Enable. More...
 
void usart_disable_tx_dma (uint32_t usart)
 USART Transmitter DMA Disable. More...
 
void usart_enable_rx_interrupt (uint32_t usart)
 USART Receiver Interrupt Enable. More...
 
void usart_disable_rx_interrupt (uint32_t usart)
 USART Receiver Interrupt Disable. More...
 
void usart_enable_tx_interrupt (uint32_t usart)
 USART Transmitter Interrupt Enable. More...
 
void usart_disable_tx_interrupt (uint32_t usart)
 USART Transmitter Interrupt Disable. More...
 
void usart_enable_tx_complete_interrupt (uint32_t usart)
 USART Transmission Complete Interrupt Enable. More...
 
void usart_disable_tx_complete_interrupt (uint32_t usart)
 USART Transmission Complete Interrupt Disable. More...
 
void usart_enable_idle_interrupt (uint32_t usart)
 USART Idle Interrupt Enable. More...
 
void usart_disable_idle_interrupt (uint32_t usart)
 USART Idle Interrupt Disable. More...
 
void usart_enable_error_interrupt (uint32_t usart)
 USART Error Interrupt Enable. More...
 
void usart_disable_error_interrupt (uint32_t usart)
 USART Error Interrupt Disable. More...
 
bool usart_get_flag (uint32_t usart, uint32_t flag)
 USART Read a Status Flag. More...
 

Detailed Description

Defined Constants and Types for the STM32L1xx USART

Version
1.0.0
Date
5 December 2012

LGPL License Terms libopencm3 License

Author
© 2009 Uwe Hermann uwe@h.nosp@m.erma.nosp@m.nn-uw.nosp@m.e.de

Macro Definition Documentation

◆ UART4_BRR

#define UART4_BRR   USART_BRR(UART4_BASE)

Definition at line 75 of file usart_common_f124.h.

◆ UART4_CR1

#define UART4_CR1   USART_CR1(UART4_BASE)

Definition at line 83 of file usart_common_f124.h.

◆ UART4_CR2

#define UART4_CR2   USART_CR2(UART4_BASE)

Definition at line 91 of file usart_common_f124.h.

◆ UART4_CR3

#define UART4_CR3   USART_CR3(UART4_BASE)

Definition at line 99 of file usart_common_f124.h.

◆ UART4_DR

#define UART4_DR   USART_DR(UART4_BASE)

Definition at line 67 of file usart_common_f124.h.

◆ UART4_GTPR

#define UART4_GTPR   USART_GTPR(UART4_BASE)

Definition at line 107 of file usart_common_f124.h.

◆ UART4_SR

#define UART4_SR   USART_SR(UART4_BASE)

Definition at line 59 of file usart_common_f124.h.

◆ UART5_BRR

#define UART5_BRR   USART_BRR(UART5_BASE)

Definition at line 76 of file usart_common_f124.h.

◆ UART5_CR1

#define UART5_CR1   USART_CR1(UART5_BASE)

Definition at line 84 of file usart_common_f124.h.

◆ UART5_CR2

#define UART5_CR2   USART_CR2(UART5_BASE)

Definition at line 92 of file usart_common_f124.h.

◆ UART5_CR3

#define UART5_CR3   USART_CR3(UART5_BASE)

Definition at line 100 of file usart_common_f124.h.

◆ UART5_DR

#define UART5_DR   USART_DR(UART5_BASE)

Definition at line 68 of file usart_common_f124.h.

◆ UART5_GTPR

#define UART5_GTPR   USART_GTPR(UART5_BASE)

Definition at line 108 of file usart_common_f124.h.

◆ UART5_SR

#define UART5_SR   USART_SR(UART5_BASE)

Definition at line 60 of file usart_common_f124.h.

◆ USART1_BRR

#define USART1_BRR   USART_BRR(USART1_BASE)

Definition at line 72 of file usart_common_f124.h.

◆ USART1_CR1

#define USART1_CR1   USART_CR1(USART1_BASE)

Definition at line 80 of file usart_common_f124.h.

◆ USART1_CR2

#define USART1_CR2   USART_CR2(USART1_BASE)

Definition at line 88 of file usart_common_f124.h.

◆ USART1_CR3

#define USART1_CR3   USART_CR3(USART1_BASE)

Definition at line 96 of file usart_common_f124.h.

◆ USART1_DR

#define USART1_DR   USART_DR(USART1_BASE)

Definition at line 64 of file usart_common_f124.h.

◆ USART1_GTPR

#define USART1_GTPR   USART_GTPR(USART1_BASE)

Definition at line 104 of file usart_common_f124.h.

◆ USART1_SR

#define USART1_SR   USART_SR(USART1_BASE)

Definition at line 56 of file usart_common_f124.h.

◆ USART2_BRR

#define USART2_BRR   USART_BRR(USART2_BASE)

Definition at line 73 of file usart_common_f124.h.

◆ USART2_CR1

#define USART2_CR1   USART_CR1(USART2_BASE)

Definition at line 81 of file usart_common_f124.h.

◆ USART2_CR2

#define USART2_CR2   USART_CR2(USART2_BASE)

Definition at line 89 of file usart_common_f124.h.

◆ USART2_CR3

#define USART2_CR3   USART_CR3(USART2_BASE)

Definition at line 97 of file usart_common_f124.h.

◆ USART2_DR

#define USART2_DR   USART_DR(USART2_BASE)

Definition at line 65 of file usart_common_f124.h.

◆ USART2_GTPR

#define USART2_GTPR   USART_GTPR(USART2_BASE)

Definition at line 105 of file usart_common_f124.h.

◆ USART2_SR

#define USART2_SR   USART_SR(USART2_BASE)

Definition at line 57 of file usart_common_f124.h.

◆ USART3_BRR

#define USART3_BRR   USART_BRR(USART3_BASE)

Definition at line 74 of file usart_common_f124.h.

◆ USART3_CR1

#define USART3_CR1   USART_CR1(USART3_BASE)

Definition at line 82 of file usart_common_f124.h.

◆ USART3_CR2

#define USART3_CR2   USART_CR2(USART3_BASE)

Definition at line 90 of file usart_common_f124.h.

◆ USART3_CR3

#define USART3_CR3   USART_CR3(USART3_BASE)

Definition at line 98 of file usart_common_f124.h.

◆ USART3_DR

#define USART3_DR   USART_DR(USART3_BASE)

Definition at line 66 of file usart_common_f124.h.

◆ USART3_GTPR

#define USART3_GTPR   USART_GTPR(USART3_BASE)

Definition at line 106 of file usart_common_f124.h.

◆ USART3_SR

#define USART3_SR   USART_SR(USART3_BASE)

Definition at line 58 of file usart_common_f124.h.

◆ USART_BRR

#define USART_BRR (   usart_base)    MMIO32((usart_base) + 0x08)

Definition at line 71 of file usart_common_f124.h.

◆ USART_BRR_DIV_FRACTION_MASK

#define USART_BRR_DIV_FRACTION_MASK   0xF

Definition at line 176 of file usart_common_f124.h.

◆ USART_BRR_DIV_MANTISSA_MASK

#define USART_BRR_DIV_MANTISSA_MASK   (0xFFF << 4)

Definition at line 174 of file usart_common_f124.h.

◆ USART_CR1

#define USART_CR1 (   usart_base)    MMIO32((usart_base) + 0x0c)

Definition at line 79 of file usart_common_f124.h.

◆ USART_CR1_IDLEIE

#define USART_CR1_IDLEIE   (1 << 4)

Definition at line 208 of file usart_common_f124.h.

◆ USART_CR1_M

#define USART_CR1_M   (1 << 12)

Definition at line 184 of file usart_common_f124.h.

◆ USART_CR1_PCE

#define USART_CR1_PCE   (1 << 10)

Definition at line 190 of file usart_common_f124.h.

◆ USART_CR1_PEIE

#define USART_CR1_PEIE   (1 << 8)

Definition at line 196 of file usart_common_f124.h.

◆ USART_CR1_PS

#define USART_CR1_PS   (1 << 9)

Definition at line 193 of file usart_common_f124.h.

◆ USART_CR1_RE

#define USART_CR1_RE   (1 << 2)

Definition at line 214 of file usart_common_f124.h.

◆ USART_CR1_RWU

#define USART_CR1_RWU   (1 << 1)

Definition at line 217 of file usart_common_f124.h.

◆ USART_CR1_RXNEIE

#define USART_CR1_RXNEIE   (1 << 5)

Definition at line 205 of file usart_common_f124.h.

◆ USART_CR1_SBK

#define USART_CR1_SBK   (1 << 0)

Definition at line 220 of file usart_common_f124.h.

◆ USART_CR1_TCIE

#define USART_CR1_TCIE   (1 << 6)

Definition at line 202 of file usart_common_f124.h.

◆ USART_CR1_TE

#define USART_CR1_TE   (1 << 3)

Definition at line 211 of file usart_common_f124.h.

◆ USART_CR1_TXEIE

#define USART_CR1_TXEIE   (1 << 7)

Definition at line 199 of file usart_common_f124.h.

◆ USART_CR1_UE

#define USART_CR1_UE   (1 << 13)

Definition at line 181 of file usart_common_f124.h.

◆ USART_CR1_WAKE

#define USART_CR1_WAKE   (1 << 11)

Definition at line 187 of file usart_common_f124.h.

◆ USART_CR2

#define USART_CR2 (   usart_base)    MMIO32((usart_base) + 0x10)

Definition at line 87 of file usart_common_f124.h.

◆ USART_CR2_ADD_MASK

#define USART_CR2_ADD_MASK   0xF

Definition at line 246 of file usart_common_f124.h.

◆ USART_CR2_CLKEN

#define USART_CR2_CLKEN   (1 << 11)

Definition at line 228 of file usart_common_f124.h.

◆ USART_CR2_CPHA

#define USART_CR2_CPHA   (1 << 9)

Definition at line 234 of file usart_common_f124.h.

◆ USART_CR2_CPOL

#define USART_CR2_CPOL   (1 << 10)

Definition at line 231 of file usart_common_f124.h.

◆ USART_CR2_LBCL

#define USART_CR2_LBCL   (1 << 8)

Definition at line 237 of file usart_common_f124.h.

◆ USART_CR2_LBDIE

#define USART_CR2_LBDIE   (1 << 6)

Definition at line 240 of file usart_common_f124.h.

◆ USART_CR2_LBDL

#define USART_CR2_LBDL   (1 << 5)

Definition at line 243 of file usart_common_f124.h.

◆ USART_CR2_LINEN

#define USART_CR2_LINEN   (1 << 14)

Definition at line 225 of file usart_common_f124.h.

◆ USART_CR2_STOPBITS_0_5

#define USART_CR2_STOPBITS_0_5   (0x01 << 12) /* 0.5 stop bits */

Definition at line 77 of file usart_common_all.h.

◆ USART_CR2_STOPBITS_1

#define USART_CR2_STOPBITS_1   (0x00 << 12) /* 1 stop bit */

Definition at line 76 of file usart_common_all.h.

◆ USART_CR2_STOPBITS_1_5

#define USART_CR2_STOPBITS_1_5   (0x03 << 12) /* 1.5 stop bits */

Definition at line 79 of file usart_common_all.h.

◆ USART_CR2_STOPBITS_2

#define USART_CR2_STOPBITS_2   (0x02 << 12) /* 2 stop bits */

Definition at line 78 of file usart_common_all.h.

◆ USART_CR2_STOPBITS_MASK

#define USART_CR2_STOPBITS_MASK   (0x03 << 12)

Definition at line 80 of file usart_common_all.h.

◆ USART_CR2_STOPBITS_SHIFT

#define USART_CR2_STOPBITS_SHIFT   12

Definition at line 81 of file usart_common_all.h.

◆ USART_CR3

#define USART_CR3 (   usart_base)    MMIO32((usart_base) + 0x14)

Definition at line 95 of file usart_common_f124.h.

◆ USART_CR3_CTSE

#define USART_CR3_CTSE   (1 << 9)

Definition at line 256 of file usart_common_f124.h.

◆ USART_CR3_CTSIE

#define USART_CR3_CTSIE   (1 << 10)

Definition at line 252 of file usart_common_f124.h.

◆ USART_CR3_DMAR

#define USART_CR3_DMAR   (1 << 6)

Definition at line 268 of file usart_common_f124.h.

◆ USART_CR3_DMAT

#define USART_CR3_DMAT   (1 << 7)

Definition at line 264 of file usart_common_f124.h.

◆ USART_CR3_EIE

#define USART_CR3_EIE   (1 << 0)

Definition at line 288 of file usart_common_f124.h.

◆ USART_CR3_HDSEL

#define USART_CR3_HDSEL   (1 << 3)

Definition at line 279 of file usart_common_f124.h.

◆ USART_CR3_IREN

#define USART_CR3_IREN   (1 << 1)

Definition at line 285 of file usart_common_f124.h.

◆ USART_CR3_IRLP

#define USART_CR3_IRLP   (1 << 2)

Definition at line 282 of file usart_common_f124.h.

◆ USART_CR3_NACK

#define USART_CR3_NACK   (1 << 4)

Definition at line 276 of file usart_common_f124.h.

◆ USART_CR3_RTSE

#define USART_CR3_RTSE   (1 << 8)

Definition at line 260 of file usart_common_f124.h.

◆ USART_CR3_SCEN

#define USART_CR3_SCEN   (1 << 5)

Definition at line 272 of file usart_common_f124.h.

◆ USART_DR

#define USART_DR (   usart_base)    MMIO32((usart_base) + 0x04)

Definition at line 63 of file usart_common_f124.h.

◆ USART_DR_MASK

#define USART_DR_MASK   0x1FF

Definition at line 169 of file usart_common_f124.h.

◆ USART_FLOWCONTROL_MASK

#define USART_FLOWCONTROL_MASK   (USART_CR3_RTSE | USART_CR3_CTSE)

Definition at line 95 of file usart_common_all.h.

◆ USART_GTPR

#define USART_GTPR (   usart_base)    MMIO32((usart_base) + 0x18)

Definition at line 103 of file usart_common_f124.h.

◆ USART_GTPR_GT_MASK

#define USART_GTPR_GT_MASK   (0xFF << 8)

Definition at line 294 of file usart_common_f124.h.

◆ USART_GTPR_PSC_MASK

#define USART_GTPR_PSC_MASK   0xFF

Definition at line 298 of file usart_common_f124.h.

◆ USART_MODE_MASK

#define USART_MODE_MASK   (USART_CR1_RE | USART_CR1_TE)

Definition at line 62 of file usart_common_all.h.

◆ USART_PARITY_MASK

#define USART_PARITY_MASK   (USART_CR1_PS | USART_CR1_PCE)

Definition at line 50 of file usart_common_all.h.

◆ USART_SR

#define USART_SR (   usart_base)    MMIO32((usart_base) + 0x00)

Definition at line 55 of file usart_common_f124.h.

Function Documentation

◆ usart_disable()

void usart_disable ( uint32_t  usart)

USART Disable.

At the end of the current frame, the USART is disabled to reduce power.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 195 of file usart_common_all.c.

References USART_CR1.

◆ usart_disable_error_interrupt()

void usart_disable_error_interrupt ( uint32_t  usart)

USART Error Interrupt Disable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 411 of file usart_common_all.c.

References USART_CR3.

◆ usart_disable_idle_interrupt()

void usart_disable_idle_interrupt ( uint32_t  usart)

USART Idle Interrupt Disable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 387 of file usart_common_all.c.

References USART_CR1.

◆ usart_disable_rx_dma()

void usart_disable_rx_dma ( uint32_t  usart)

USART Receiver DMA Disable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 259 of file usart_common_all.c.

References USART_CR3.

◆ usart_disable_rx_interrupt()

void usart_disable_rx_interrupt ( uint32_t  usart)

USART Receiver Interrupt Disable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 314 of file usart_common_all.c.

References USART_CR1.

◆ usart_disable_tx_complete_interrupt()

void usart_disable_tx_complete_interrupt ( uint32_t  usart)

USART Transmission Complete Interrupt Disable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 364 of file usart_common_all.c.

References USART_CR1.

◆ usart_disable_tx_dma()

void usart_disable_tx_dma ( uint32_t  usart)

USART Transmitter DMA Disable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 289 of file usart_common_all.c.

References USART_CR3.

◆ usart_disable_tx_interrupt()

void usart_disable_tx_interrupt ( uint32_t  usart)

USART Transmitter Interrupt Disable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 338 of file usart_common_all.c.

References USART_CR1.

◆ usart_enable()

void usart_enable ( uint32_t  usart)

USART Enable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 181 of file usart_common_all.c.

References USART_CR1, and USART_CR1_UE.

◆ usart_enable_error_interrupt()

void usart_enable_error_interrupt ( uint32_t  usart)

USART Error Interrupt Enable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 399 of file usart_common_all.c.

References USART_CR3, and USART_CR3_EIE.

◆ usart_enable_idle_interrupt()

void usart_enable_idle_interrupt ( uint32_t  usart)

USART Idle Interrupt Enable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 375 of file usart_common_all.c.

References USART_CR1, and USART_CR1_IDLEIE.

◆ usart_enable_rx_dma()

void usart_enable_rx_dma ( uint32_t  usart)

USART Receiver DMA Enable.

DMA is available on:

  • USART1 Rx DMA1 channel 5.
  • USART2 Rx DMA1 channel 6.
  • USART3 Rx DMA1 channel 3.
  • UART4 Rx DMA2 channel 3.
Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 247 of file usart_common_all.c.

References USART_CR3, and USART_CR3_DMAR.

◆ usart_enable_rx_interrupt()

void usart_enable_rx_interrupt ( uint32_t  usart)

USART Receiver Interrupt Enable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 301 of file usart_common_all.c.

References USART_CR1, and USART_CR1_RXNEIE.

◆ usart_enable_tx_complete_interrupt()

void usart_enable_tx_complete_interrupt ( uint32_t  usart)

USART Transmission Complete Interrupt Enable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 351 of file usart_common_all.c.

References USART_CR1, and USART_CR1_TCIE.

◆ usart_enable_tx_dma()

void usart_enable_tx_dma ( uint32_t  usart)

USART Transmitter DMA Enable.

DMA is available on:

  • USART1 Tx DMA1 channel 4.
  • USART2 Tx DMA1 channel 7.
  • USART3 Tx DMA1 channel 2.
  • UART4 Tx DMA2 channel 5.
Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 277 of file usart_common_all.c.

References USART_CR3, and USART_CR3_DMAT.

◆ usart_enable_tx_interrupt()

void usart_enable_tx_interrupt ( uint32_t  usart)

USART Transmitter Interrupt Enable.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 326 of file usart_common_all.c.

References USART_CR1, and USART_CR1_TXEIE.

◆ usart_get_flag()

bool usart_get_flag ( uint32_t  usart,
uint32_t  flag 
)

USART Read a Status Flag.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
[in]flagUnsigned int32. Status register flag USART Status register Flags.
Returns
boolean: flag set.

Definition at line 108 of file usart_common_f124.c.

References USART_SR.

◆ usart_recv()

uint16_t usart_recv ( uint32_t  usart)

USART Read a Received Data Word.

If parity is enabled the MSB (bit 7 or 8 depending on the word length) is the parity bit.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
Returns
unsigned 16 bit data word.

Definition at line 62 of file usart_common_f124.c.

References USART_DR, and USART_DR_MASK.

Referenced by usart_recv_blocking().

Here is the caller graph for this function:

◆ usart_recv_blocking()

uint16_t usart_recv_blocking ( uint32_t  usart)

USART Read a Received Data Word with Blocking.

Wait until a data word has been received then return the word.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
Returns
unsigned 16 bit data word.

Definition at line 227 of file usart_common_all.c.

References usart_recv(), and usart_wait_recv_ready().

Here is the call graph for this function:

◆ usart_send()

void usart_send ( uint32_t  usart,
uint16_t  data 
)

USART Send a Data Word.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
[in]dataunsigned 16 bit.

Definition at line 45 of file usart_common_f124.c.

References USART_DR, and USART_DR_MASK.

Referenced by usart_send_blocking().

Here is the caller graph for this function:

◆ usart_send_blocking()

void usart_send_blocking ( uint32_t  usart,
uint16_t  data 
)

USART Send Data Word with Blocking.

Blocks until the transmit data buffer becomes empty then writes the next data word for transmission.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
[in]dataunsigned 16 bit.

Definition at line 211 of file usart_common_all.c.

References usart_send(), and usart_wait_send_ready().

Here is the call graph for this function:

◆ usart_set_baudrate()

void usart_set_baudrate ( uint32_t  usart,
uint32_t  baud 
)

USART Set Baudrate.

The baud rate is computed from the APB high-speed prescaler clock (for USART1/6) or the APB low-speed prescaler clock (for other USARTs). These values must be correctly set before calling this function (refer to the rcc_clock_setup-* functions in RCC).

Note: For LPUART, baudrates over 2**24 (~16.7 Mbaud) may overflow the calculation and are therefore not supported by this function.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
[in]baudunsigned 32 bit. Baud rate specified in Hz.

Definition at line 53 of file usart_common_all.c.

References rcc_get_usart_clk_freq(), and USART_BRR.

Here is the call graph for this function:

◆ usart_set_databits()

void usart_set_databits ( uint32_t  usart,
uint32_t  bits 
)

USART Set Word Length.

The word length is set to 8 or 9 bits. Note that the last bit will be a parity bit if parity is enabled, in which case the data length will be 7 or 8 bits respectively.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
[in]bitsunsigned 32 bit. Word length in bits 8 or 9.

Definition at line 89 of file usart_common_all.c.

References USART_CR1, and USART_CR1_M.

◆ usart_set_flow_control()

void usart_set_flow_control ( uint32_t  usart,
uint32_t  flowcontrol 
)

USART Set Hardware Flow Control.

The flow control bit can be selected as none, RTS, CTS or RTS+CTS.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
[in]flowcontrolunsigned 32 bit. Flowcontrol USART Hardware Flow Control Selection.

Definition at line 165 of file usart_common_all.c.

References USART_CR3.

◆ usart_set_mode()

void usart_set_mode ( uint32_t  usart,
uint32_t  mode 
)

USART Set Rx/Tx Mode.

The mode can be selected as Rx only, Tx only or Rx+Tx.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
[in]modeunsigned 32 bit. Mode USART Tx/Rx Mode Selection.

Definition at line 146 of file usart_common_all.c.

References USART_CR1.

◆ usart_set_parity()

void usart_set_parity ( uint32_t  usart,
uint32_t  parity 
)

USART Set Parity.

The parity bit can be selected as none, even or odd.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
[in]parityunsigned 32 bit. Parity USART Parity Selection.

Definition at line 127 of file usart_common_all.c.

References USART_CR1.

◆ usart_set_stopbits()

void usart_set_stopbits ( uint32_t  usart,
uint32_t  stopbits 
)

USART Set Stop Bit(s).

The stop bits are specified as 0.5, 1, 1.5 or 2.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses
[in]stopbitsunsigned 32 bit. Stop bits USART Stop Bit Selection.

Definition at line 108 of file usart_common_all.c.

References USART_CR2.

◆ usart_wait_recv_ready()

void usart_wait_recv_ready ( uint32_t  usart)

USART Wait for Received Data Available.

Blocks until the receive data buffer holds a valid received data word.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 93 of file usart_common_f124.c.

References USART_SR, and USART_SR_RXNE.

Referenced by usart_recv_blocking().

Here is the caller graph for this function:

◆ usart_wait_send_ready()

void usart_wait_send_ready ( uint32_t  usart)

USART Wait for Transmit Data Buffer Empty.

Blocks until the transmit data buffer becomes empty and is ready to accept the next data word.

Parameters
[in]usartunsigned 32 bit. USART block register address base USART register base addresses

Definition at line 78 of file usart_common_f124.c.

References USART_SR, and USART_SR_TXE.

Referenced by usart_send_blocking().

Here is the caller graph for this function: