STM32L4xx_HAL_Driver  1.14.0
UART Exported Types

Data Structures

struct  UART_InitTypeDef
 UART Init Structure definition. More...
 
struct  UART_AdvFeatureInitTypeDef
 UART Advanced Features initialization structure definition. More...
 
struct  __UART_HandleTypeDef
 UART handle Structure definition. More...
 

Typedefs

typedef uint32_t HAL_UART_StateTypeDef
 HAL UART State definition. More...
 
typedef struct __UART_HandleTypeDef UART_HandleTypeDef
 UART handle Structure definition. More...
 
typedef void(* pUART_CallbackTypeDef) (UART_HandleTypeDef *huart)
 HAL UART Callback pointer definition. More...
 

Enumerations

enum  UART_ClockSourceTypeDef {
  UART_CLOCKSOURCE_PCLK1 = 0x00U, UART_CLOCKSOURCE_PCLK2 = 0x01U, UART_CLOCKSOURCE_HSI = 0x02U, UART_CLOCKSOURCE_SYSCLK = 0x04U,
  UART_CLOCKSOURCE_LSE = 0x08U, UART_CLOCKSOURCE_UNDEFINED = 0x10U
}
 UART clock sources definition. More...
 
enum  HAL_UART_CallbackIDTypeDef {
  HAL_UART_TX_HALFCOMPLETE_CB_ID = 0x00U, HAL_UART_TX_COMPLETE_CB_ID = 0x01U, HAL_UART_RX_HALFCOMPLETE_CB_ID = 0x02U, HAL_UART_RX_COMPLETE_CB_ID = 0x03U,
  HAL_UART_ERROR_CB_ID = 0x04U, HAL_UART_ABORT_COMPLETE_CB_ID = 0x05U, HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U,
  HAL_UART_WAKEUP_CB_ID = 0x08U, HAL_UART_RX_FIFO_FULL_CB_ID = 0x09U, HAL_UART_TX_FIFO_EMPTY_CB_ID = 0x0AU, HAL_UART_MSPINIT_CB_ID = 0x0BU,
  HAL_UART_MSPDEINIT_CB_ID = 0x0CU
}
 HAL UART Callback ID enumeration definition. More...
 

Detailed Description


Data Structure Documentation

◆ UART_InitTypeDef

struct UART_InitTypeDef

UART Init Structure definition.

Definition at line 47 of file stm32l4xx_hal_uart.h.

Data Fields
uint32_t BaudRate

This member configures the UART communication baud rate. The baud rate register is computed using the following formula:

LPUART:

Baud Rate Register = ((256 * lpuart_ker_ckpres) / ((huart->Init.BaudRate))) where lpuart_ker_ck_pres is the UART input clock (divided by a prescaler if applicable)

UART:

  • If oversampling is 16 or in LIN mode, Baud Rate Register = ((uart_ker_ckpres) / ((huart->Init.BaudRate)))
  • If oversampling is 8, Baud Rate Register[15:4] = ((2 * uart_ker_ckpres) / ((huart->Init.BaudRate)))[15:4] Baud Rate Register[3] = 0 Baud Rate Register[2:0] = (((2 * uart_ker_ckpres) / ((huart->Init.BaudRate)))[3:0]) >> 1 where uart_ker_ck_pres is the UART input clock (divided by a prescaler if applicable)
uint32_t ClockPrescaler

Specifies the prescaler value used to divide the UART clock source. This parameter can be a value of UART Clock Prescaler.

uint32_t HwFlowCtl

Specifies whether the hardware flow control mode is enabled or disabled. This parameter can be a value of UART Hardware Flow Control.

uint32_t Mode

Specifies whether the Receive or Transmit mode is enabled or disabled. This parameter can be a value of UART Transfer Mode.

uint32_t OneBitSampling

Specifies whether a single sample or three samples' majority vote is selected. Selecting the single sample method increases the receiver tolerance to clock deviations. This parameter can be a value of UART One Bit Sampling Method.

uint32_t OverSampling

Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to f_PCLK/8). This parameter can be a value of UART Over Sampling.

uint32_t Parity

Specifies the parity mode. This parameter can be a value of UART Parity

Note
When parity is enabled, the computed parity is inserted at the MSB position of the transmitted data (9th bit when the word length is set to 9 data bits; 8th bit when the word length is set to 8 data bits).
uint32_t StopBits

Specifies the number of stop bits transmitted. This parameter can be a value of UART Number of Stop Bits.

uint32_t WordLength

Specifies the number of data bits transmitted or received in a frame. This parameter can be a value of UARTEx Word Length.

◆ UART_AdvFeatureInitTypeDef

struct UART_AdvFeatureInitTypeDef

UART Advanced Features initialization structure definition.

Definition at line 102 of file stm32l4xx_hal_uart.h.

Data Fields
uint32_t AdvFeatureInit

Specifies which advanced UART features is initialized. Several Advanced Features may be initialized at the same time . This parameter can be a value of UART Advanced Feature Initialization Type.

uint32_t AutoBaudRateEnable

Specifies whether auto Baud rate detection is enabled. This parameter can be a value of UART Advanced Feature Auto BaudRate Enable.

uint32_t AutoBaudRateMode

If auto Baud rate detection is enabled, specifies how the rate detection is carried out. This parameter can be a value of UART Advanced Feature AutoBaud Rate Mode.

uint32_t DataInvert

Specifies whether data are inverted (positive/direct logic vs negative/inverted logic). This parameter can be a value of UART Advanced Feature Binary Data Inversion.

uint32_t DMADisableonRxError

Specifies whether the DMA is disabled in case of reception error. This parameter can be a value of UART Advanced Feature DMA Disable On Rx Error.

uint32_t MSBFirst

Specifies whether MSB is sent first on UART line. This parameter can be a value of UART Advanced Feature MSB First.

uint32_t OverrunDisable

Specifies whether the reception overrun detection is disabled. This parameter can be a value of UART Advanced Feature Overrun Disable.

uint32_t RxPinLevelInvert

Specifies whether the RX pin active level is inverted. This parameter can be a value of UART Advanced Feature RX Pin Active Level Inversion.

uint32_t Swap

Specifies whether TX and RX pins are swapped. This parameter can be a value of UART Advanced Feature RX TX Pins Swap.

uint32_t TxPinLevelInvert

Specifies whether the TX pin active level is inverted. This parameter can be a value of UART Advanced Feature TX Pin Active Level Inversion.

◆ __UART_HandleTypeDef

struct __UART_HandleTypeDef

UART handle Structure definition.

Definition at line 197 of file stm32l4xx_hal_uart.h.

Data Fields

USART_TypeDef * Instance
 
UART_InitTypeDef Init
 
UART_AdvFeatureInitTypeDef AdvancedInit
 
uint8_t * pTxBuffPtr
 
uint16_t TxXferSize
 
__IO uint16_t TxXferCount
 
uint8_t * pRxBuffPtr
 
uint16_t RxXferSize
 
__IO uint16_t RxXferCount
 
uint16_t Mask
 
uint32_t FifoMode
 
uint16_t NbRxDataToProcess
 
uint16_t NbTxDataToProcess
 
void(* RxISR )(struct __UART_HandleTypeDef *huart)
 
void(* TxISR )(struct __UART_HandleTypeDef *huart)
 
DMA_HandleTypeDefhdmatx
 
DMA_HandleTypeDefhdmarx
 
HAL_LockTypeDef Lock
 
__IO HAL_UART_StateTypeDef gState
 
__IO HAL_UART_StateTypeDef RxState
 
__IO uint32_t ErrorCode
 
void(* TxHalfCpltCallback )(struct __UART_HandleTypeDef *huart)
 
void(* TxCpltCallback )(struct __UART_HandleTypeDef *huart)
 
void(* RxHalfCpltCallback )(struct __UART_HandleTypeDef *huart)
 
void(* RxCpltCallback )(struct __UART_HandleTypeDef *huart)
 
void(* ErrorCallback )(struct __UART_HandleTypeDef *huart)
 
void(* AbortCpltCallback )(struct __UART_HandleTypeDef *huart)
 
void(* AbortTransmitCpltCallback )(struct __UART_HandleTypeDef *huart)
 
void(* AbortReceiveCpltCallback )(struct __UART_HandleTypeDef *huart)
 
void(* WakeupCallback )(struct __UART_HandleTypeDef *huart)
 
void(* RxFifoFullCallback )(struct __UART_HandleTypeDef *huart)
 
void(* TxFifoEmptyCallback )(struct __UART_HandleTypeDef *huart)
 
void(* MspInitCallback )(struct __UART_HandleTypeDef *huart)
 
void(* MspDeInitCallback )(struct __UART_HandleTypeDef *huart)
 

Field Documentation

◆ AbortCpltCallback

void(* __UART_HandleTypeDef::AbortCpltCallback) (struct __UART_HandleTypeDef *huart)

UART Abort Complete Callback

Definition at line 253 of file stm32l4xx_hal_uart.h.

◆ AbortReceiveCpltCallback

void(* __UART_HandleTypeDef::AbortReceiveCpltCallback) (struct __UART_HandleTypeDef *huart)

UART Abort Receive Complete Callback

Definition at line 255 of file stm32l4xx_hal_uart.h.

◆ AbortTransmitCpltCallback

void(* __UART_HandleTypeDef::AbortTransmitCpltCallback) (struct __UART_HandleTypeDef *huart)

UART Abort Transmit Complete Callback

Definition at line 254 of file stm32l4xx_hal_uart.h.

◆ AdvancedInit

UART_AdvFeatureInitTypeDef __UART_HandleTypeDef::AdvancedInit

UART Advanced Features initialization parameters

Definition at line 203 of file stm32l4xx_hal_uart.h.

◆ ErrorCallback

void(* __UART_HandleTypeDef::ErrorCallback) (struct __UART_HandleTypeDef *huart)

UART Error Callback

Definition at line 252 of file stm32l4xx_hal_uart.h.

◆ ErrorCode

__IO uint32_t __UART_HandleTypeDef::ErrorCode

UART Error code

Definition at line 245 of file stm32l4xx_hal_uart.h.

◆ FifoMode

uint32_t __UART_HandleTypeDef::FifoMode

Specifies if the FIFO mode is being used. This parameter can be a value of UARTEx FIFO mode.

Definition at line 220 of file stm32l4xx_hal_uart.h.

◆ gState

__IO HAL_UART_StateTypeDef __UART_HandleTypeDef::gState

UART state information related to global Handle management and also related to Tx operations. This parameter can be a value of HAL_UART_StateTypeDef

Definition at line 238 of file stm32l4xx_hal_uart.h.

◆ hdmarx

DMA_HandleTypeDef* __UART_HandleTypeDef::hdmarx

UART Rx DMA Handle parameters

Definition at line 234 of file stm32l4xx_hal_uart.h.

◆ hdmatx

DMA_HandleTypeDef* __UART_HandleTypeDef::hdmatx

UART Tx DMA Handle parameters

Definition at line 232 of file stm32l4xx_hal_uart.h.

◆ Init

UART_InitTypeDef __UART_HandleTypeDef::Init

UART communication parameters

Definition at line 201 of file stm32l4xx_hal_uart.h.

◆ Instance

USART_TypeDef* __UART_HandleTypeDef::Instance

UART registers base address

Definition at line 199 of file stm32l4xx_hal_uart.h.

◆ Lock

HAL_LockTypeDef __UART_HandleTypeDef::Lock

Locking object

Definition at line 236 of file stm32l4xx_hal_uart.h.

◆ Mask

uint16_t __UART_HandleTypeDef::Mask

UART Rx RDR register mask

Definition at line 217 of file stm32l4xx_hal_uart.h.

◆ MspDeInitCallback

void(* __UART_HandleTypeDef::MspDeInitCallback) (struct __UART_HandleTypeDef *huart)

UART Msp DeInit callback

Definition at line 263 of file stm32l4xx_hal_uart.h.

◆ MspInitCallback

void(* __UART_HandleTypeDef::MspInitCallback) (struct __UART_HandleTypeDef *huart)

UART Msp Init callback

Definition at line 262 of file stm32l4xx_hal_uart.h.

◆ NbRxDataToProcess

uint16_t __UART_HandleTypeDef::NbRxDataToProcess

Number of data to process during RX ISR execution

Definition at line 223 of file stm32l4xx_hal_uart.h.

◆ NbTxDataToProcess

uint16_t __UART_HandleTypeDef::NbTxDataToProcess

Number of data to process during TX ISR execution

Definition at line 225 of file stm32l4xx_hal_uart.h.

◆ pRxBuffPtr

uint8_t* __UART_HandleTypeDef::pRxBuffPtr

Pointer to UART Rx transfer Buffer

Definition at line 211 of file stm32l4xx_hal_uart.h.

◆ pTxBuffPtr

uint8_t* __UART_HandleTypeDef::pTxBuffPtr

Pointer to UART Tx transfer Buffer

Definition at line 205 of file stm32l4xx_hal_uart.h.

◆ RxCpltCallback

void(* __UART_HandleTypeDef::RxCpltCallback) (struct __UART_HandleTypeDef *huart)

UART Rx Complete Callback

Definition at line 251 of file stm32l4xx_hal_uart.h.

◆ RxFifoFullCallback

void(* __UART_HandleTypeDef::RxFifoFullCallback) (struct __UART_HandleTypeDef *huart)

UART Rx Fifo Full Callback

Definition at line 258 of file stm32l4xx_hal_uart.h.

◆ RxHalfCpltCallback

void(* __UART_HandleTypeDef::RxHalfCpltCallback) (struct __UART_HandleTypeDef *huart)

UART Rx Half Complete Callback

Definition at line 250 of file stm32l4xx_hal_uart.h.

◆ RxISR

void(* __UART_HandleTypeDef::RxISR) (struct __UART_HandleTypeDef *huart)

Function pointer on Rx IRQ handler

Definition at line 228 of file stm32l4xx_hal_uart.h.

◆ RxState

__IO HAL_UART_StateTypeDef __UART_HandleTypeDef::RxState

UART state information related to Rx operations. This parameter can be a value of HAL_UART_StateTypeDef

Definition at line 242 of file stm32l4xx_hal_uart.h.

◆ RxXferCount

__IO uint16_t __UART_HandleTypeDef::RxXferCount

UART Rx Transfer Counter

Definition at line 215 of file stm32l4xx_hal_uart.h.

◆ RxXferSize

uint16_t __UART_HandleTypeDef::RxXferSize

UART Rx Transfer size

Definition at line 213 of file stm32l4xx_hal_uart.h.

◆ TxCpltCallback

void(* __UART_HandleTypeDef::TxCpltCallback) (struct __UART_HandleTypeDef *huart)

UART Tx Complete Callback

Definition at line 249 of file stm32l4xx_hal_uart.h.

◆ TxFifoEmptyCallback

void(* __UART_HandleTypeDef::TxFifoEmptyCallback) (struct __UART_HandleTypeDef *huart)

UART Tx Fifo Empty Callback

Definition at line 259 of file stm32l4xx_hal_uart.h.

◆ TxHalfCpltCallback

void(* __UART_HandleTypeDef::TxHalfCpltCallback) (struct __UART_HandleTypeDef *huart)

UART Tx Half Complete Callback

Definition at line 248 of file stm32l4xx_hal_uart.h.

◆ TxISR

void(* __UART_HandleTypeDef::TxISR) (struct __UART_HandleTypeDef *huart)

Function pointer on Tx IRQ handler

Definition at line 230 of file stm32l4xx_hal_uart.h.

◆ TxXferCount

__IO uint16_t __UART_HandleTypeDef::TxXferCount

UART Tx Transfer Counter

Definition at line 209 of file stm32l4xx_hal_uart.h.

◆ TxXferSize

uint16_t __UART_HandleTypeDef::TxXferSize

UART Tx Transfer size

Definition at line 207 of file stm32l4xx_hal_uart.h.

◆ WakeupCallback

void(* __UART_HandleTypeDef::WakeupCallback) (struct __UART_HandleTypeDef *huart)

UART Wakeup Callback

Definition at line 256 of file stm32l4xx_hal_uart.h.

Typedef Documentation

◆ HAL_UART_StateTypeDef

typedef uint32_t HAL_UART_StateTypeDef

HAL UART State definition.

Note
HAL UART State value is a combination of 2 different substates: gState and RxState (see UART State Code Definition).
  • gState contains UART state information related to global Handle management and also information related to Tx operations. gState value coding follow below described bitmap : b7-b6 Error information 00 : No Error 01 : (Not Used) 10 : Timeout 11 : Error b5 Peripheral initialization status 0 : Reset (Peripheral not initialized) 1 : Init done (Peripheral not initialized. HAL UART Init function already called) b4-b3 (not used) xx : Should be set to 00 b2 Intrinsic process state 0 : Ready 1 : Busy (Peripheral busy with some configuration or internal operations) b1 (not used) x : Should be set to 0 b0 Tx state 0 : Ready (no Tx operation ongoing) 1 : Busy (Tx operation ongoing)
  • RxState contains information related to Rx operations. RxState value coding follow below described bitmap : b7-b6 (not used) xx : Should be set to 00 b5 Peripheral initialization status 0 : Reset (Peripheral not initialized) 1 : Init done (Peripheral not initialized) b4-b2 (not used) xxx : Should be set to 000 b1 Rx state 0 : Ready (no Rx operation ongoing) 1 : Busy (Rx operation ongoing) b0 (not used) x : Should be set to 0.

Definition at line 179 of file stm32l4xx_hal_uart.h.

◆ pUART_CallbackTypeDef

typedef void(* pUART_CallbackTypeDef) (UART_HandleTypeDef *huart)

HAL UART Callback pointer definition.

pointer to an UART callback function

Definition at line 296 of file stm32l4xx_hal_uart.h.

◆ UART_HandleTypeDef

UART handle Structure definition.

Enumeration Type Documentation

◆ HAL_UART_CallbackIDTypeDef

HAL UART Callback ID enumeration definition.

Enumerator
HAL_UART_TX_HALFCOMPLETE_CB_ID 

UART Tx Half Complete Callback ID

HAL_UART_TX_COMPLETE_CB_ID 

UART Tx Complete Callback ID

HAL_UART_RX_HALFCOMPLETE_CB_ID 

UART Rx Half Complete Callback ID

HAL_UART_RX_COMPLETE_CB_ID 

UART Rx Complete Callback ID

HAL_UART_ERROR_CB_ID 

UART Error Callback ID

HAL_UART_ABORT_COMPLETE_CB_ID 

UART Abort Complete Callback ID

HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID 

UART Abort Transmit Complete Callback ID

HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID 

UART Abort Receive Complete Callback ID

HAL_UART_WAKEUP_CB_ID 

UART Wakeup Callback ID

HAL_UART_RX_FIFO_FULL_CB_ID 

UART Rx Fifo Full Callback ID

HAL_UART_TX_FIFO_EMPTY_CB_ID 

UART Tx Fifo Empty Callback ID

HAL_UART_MSPINIT_CB_ID 

UART MspInit callback ID

HAL_UART_MSPDEINIT_CB_ID 

UART MspDeInit callback ID

Definition at line 272 of file stm32l4xx_hal_uart.h.

273 {
278  HAL_UART_ERROR_CB_ID = 0x04U,
282  HAL_UART_WAKEUP_CB_ID = 0x08U,
283 #if defined(USART_CR1_FIFOEN)
286 #endif /* USART_CR1_FIFOEN */
287 
288  HAL_UART_MSPINIT_CB_ID = 0x0BU,
289  HAL_UART_MSPDEINIT_CB_ID = 0x0CU
HAL_UART_CallbackIDTypeDef
HAL UART Callback ID enumeration definition.

◆ UART_ClockSourceTypeDef

UART clock sources definition.

Enumerator
UART_CLOCKSOURCE_PCLK1 

PCLK1 clock source

UART_CLOCKSOURCE_PCLK2 

PCLK2 clock source

UART_CLOCKSOURCE_HSI 

HSI clock source

UART_CLOCKSOURCE_SYSCLK 

SYSCLK clock source

UART_CLOCKSOURCE_LSE 

LSE clock source

UART_CLOCKSOURCE_UNDEFINED 

Undefined clock source

Definition at line 184 of file stm32l4xx_hal_uart.h.