STM32L486xx HAL User Manual
Defines
UART Exported Macros
UART

Defines

#define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__)
 Reset UART handle states.
#define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__)
 Flush the UART Data registers.
#define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__)   ((__HANDLE__)->Instance->ICR = (__FLAG__))
 Clear the specified UART pending flag.
#define __HAL_UART_CLEAR_PEFLAG(__HANDLE__)   __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_PEF)
 Clear the UART PE pending flag.
#define __HAL_UART_CLEAR_FEFLAG(__HANDLE__)   __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_FEF)
 Clear the UART FE pending flag.
#define __HAL_UART_CLEAR_NEFLAG(__HANDLE__)   __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_NEF)
 Clear the UART NE pending flag.
#define __HAL_UART_CLEAR_OREFLAG(__HANDLE__)   __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_OREF)
 Clear the UART ORE pending flag.
#define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__)   __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_IDLEF)
 Clear the UART IDLE pending flag.
#define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__)   (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
 Check whether the specified UART flag is set or not.
#define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__)
 Enable the specified UART interrupt.
#define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__)
 Disable the specified UART interrupt.
#define __HAL_UART_GET_IT(__HANDLE__, __INTERRUPT__)   ((((__HANDLE__)->Instance->ISR & (1U << ((__INTERRUPT__)>> 8U))) != RESET) ? SET : RESET)
 Check whether the specified UART interrupt has occurred or not.
#define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)
 Check whether the specified UART interrupt source is enabled or not.
#define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__)   ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
 Clear the specified UART ISR flag, in setting the proper ICR register flag.
#define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__)   ((__HANDLE__)->Instance->RQR |= (__REQ__))
 Set a specific UART request flag.
#define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__)   ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
 Enable the UART one bit sample method.
#define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__)   ((__HANDLE__)->Instance->CR3 &= ~USART_CR3_ONEBIT)
 Disable the UART one bit sample method.
#define __HAL_UART_ENABLE(__HANDLE__)   ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
 Enable UART.
#define __HAL_UART_DISABLE(__HANDLE__)   ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
 Disable UART.
#define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__)
 Enable CTS flow control.
#define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__)
 Disable CTS flow control.
#define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__)
 Enable RTS flow control.
#define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__)
 Disable RTS flow control.

Define Documentation

#define __HAL_UART_CLEAR_FEFLAG (   __HANDLE__)    __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_FEF)

Clear the UART FE pending flag.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 881 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_CLEAR_FLAG (   __HANDLE__,
  __FLAG__ 
)    ((__HANDLE__)->Instance->ICR = (__FLAG__))

Clear the specified UART pending flag.

Parameters:
__HANDLE__specifies the UART Handle.
__FLAG__specifies the flag to check. This parameter can be any combination of the following values:
Return values:
None

Definition at line 869 of file stm32l4xx_hal_uart.h.

Referenced by HAL_UART_Abort(), HAL_UART_Abort_IT(), HAL_UART_AbortReceive(), HAL_UART_AbortReceive_IT(), HAL_UART_DMAResume(), HAL_UART_IRQHandler(), HAL_UART_Transmit_DMA(), UART_DMARxAbortCallback(), UART_DMARxOnlyAbortCallback(), and UART_DMATxAbortCallback().

#define __HAL_UART_CLEAR_IDLEFLAG (   __HANDLE__)    __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_IDLEF)

Clear the UART IDLE pending flag.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 899 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_CLEAR_IT (   __HANDLE__,
  __IT_CLEAR__ 
)    ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))

Clear the specified UART ISR flag, in setting the proper ICR register flag.

Parameters:
__HANDLE__specifies the UART Handle.
__IT_CLEAR__specifies the interrupt clear register flag that needs to be set to clear the corresponding interrupt This parameter can be one of the following values:
Return values:
None

Definition at line 1063 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_CLEAR_NEFLAG (   __HANDLE__)    __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_NEF)

Clear the UART NE pending flag.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 887 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_CLEAR_OREFLAG (   __HANDLE__)    __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_OREF)

Clear the UART ORE pending flag.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 893 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_CLEAR_PEFLAG (   __HANDLE__)    __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_PEF)

Clear the UART PE pending flag.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 875 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_DISABLE (   __HANDLE__)    ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)

Disable UART.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 1100 of file stm32l4xx_hal_uart.h.

Referenced by HAL_HalfDuplex_Init(), HAL_LIN_Init(), HAL_MultiProcessor_Init(), HAL_MultiProcessorEx_AddressLength_Set(), HAL_RS485Ex_Init(), HAL_UART_DeInit(), HAL_UART_Init(), and HAL_UARTEx_StopModeWakeUpSourceConfig().

#define __HAL_UART_DISABLE_IT (   __HANDLE__,
  __INTERRUPT__ 
)
Value:
(((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
                                                           ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
                                                           ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))))

Disable the specified UART interrupt.

Parameters:
__HANDLE__specifies the UART Handle.
__INTERRUPT__specifies the UART interrupt source to disable. This parameter can be one of the following values:
  • UART_IT_RXFF RXFIFO Full interrupt
  • UART_IT_TXFE TXFIFO Empty interrupt
  • UART_IT_RXFT RXFIFO threshold interrupt
  • UART_IT_TXFT TXFIFO threshold interrupt
  • UART_IT_WUF Wakeup from stop mode interrupt
  • UART_IT_CM Character match interrupt
  • UART_IT_CTS CTS change interrupt
  • UART_IT_LBD LIN Break detection interrupt
  • UART_IT_TXE Transmit Data Register empty interrupt
  • UART_IT_TXFNF TX FIFO not full interrupt
  • UART_IT_TC Transmission complete interrupt
  • UART_IT_RXNE Receive Data register not empty interrupt
  • UART_IT_RXFNE RXFIFO not empty interrupt
  • UART_IT_IDLE Idle line detection interrupt
  • UART_IT_PE Parity Error interrupt
  • UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
Return values:
None

Definition at line 991 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_ENABLE (   __HANDLE__)    ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)

Enable UART.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 1094 of file stm32l4xx_hal_uart.h.

Referenced by HAL_HalfDuplex_Init(), HAL_LIN_Init(), HAL_MultiProcessor_Init(), HAL_MultiProcessorEx_AddressLength_Set(), HAL_RS485Ex_Init(), HAL_UART_Init(), and HAL_UARTEx_StopModeWakeUpSourceConfig().

#define __HAL_UART_ENABLE_IT (   __HANDLE__,
  __INTERRUPT__ 
)
Value:
(((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
                                                           ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
                                                           ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))))

Enable the specified UART interrupt.

Parameters:
__HANDLE__specifies the UART Handle.
__INTERRUPT__specifies the UART interrupt source to enable. This parameter can be one of the following values:
  • UART_IT_RXFF RXFIFO Full interrupt
  • UART_IT_TXFE TXFIFO Empty interrupt
  • UART_IT_RXFT RXFIFO threshold interrupt
  • UART_IT_TXFT TXFIFO threshold interrupt
  • UART_IT_WUF Wakeup from stop mode interrupt
  • UART_IT_CM Character match interrupt
  • UART_IT_CTS CTS change interrupt
  • UART_IT_LBD LIN Break detection interrupt
  • UART_IT_TXE Transmit Data Register empty interrupt
  • UART_IT_TXFNF TX FIFO not full interrupt
  • UART_IT_TC Transmission complete interrupt
  • UART_IT_RXNE Receive Data register not empty interrupt
  • UART_IT_RXFNE RXFIFO not empty interrupt
  • UART_IT_IDLE Idle line detection interrupt
  • UART_IT_PE Parity Error interrupt
  • UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
Return values:
None

Definition at line 964 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_FLUSH_DRREGISTER (   __HANDLE__)
Value:
do{                \
      SET_BIT((__HANDLE__)->Instance->RQR, UART_RXDATA_FLUSH_REQUEST); \
      SET_BIT((__HANDLE__)->Instance->RQR, UART_TXDATA_FLUSH_REQUEST); \
    }  while(0U)

Flush the UART Data registers.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 846 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_GET_FLAG (   __HANDLE__,
  __FLAG__ 
)    (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))

Check whether the specified UART flag is set or not.

Parameters:
__HANDLE__specifies the UART Handle.
__FLAG__specifies the flag to check. This parameter can be one of the following values:
Return values:
Thenew state of __FLAG__ (TRUE or FALSE).

Definition at line 940 of file stm32l4xx_hal_uart.h.

Referenced by UART_WaitOnFlagUntilTimeout().

#define __HAL_UART_GET_IT (   __HANDLE__,
  __INTERRUPT__ 
)    ((((__HANDLE__)->Instance->ISR & (1U << ((__INTERRUPT__)>> 8U))) != RESET) ? SET : RESET)

Check whether the specified UART interrupt has occurred or not.

Parameters:
__HANDLE__specifies the UART Handle.
__INTERRUPT__specifies the UART interrupt to check. This parameter can be one of the following values:
  • UART_IT_RXFF RXFIFO Full interrupt
  • UART_IT_TXFE TXFIFO Empty interrupt
  • UART_IT_RXFT RXFIFO threshold interrupt
  • UART_IT_TXFT TXFIFO threshold interrupt
  • UART_IT_WUF Wakeup from stop mode interrupt
  • UART_IT_CM Character match interrupt
  • UART_IT_CTS CTS change interrupt
  • UART_IT_LBD LIN Break detection interrupt
  • UART_IT_TXE Transmit Data Register empty interrupt
  • UART_IT_TXFNF TX FIFO not full interrupt
  • UART_IT_TC Transmission complete interrupt
  • UART_IT_RXNE Receive Data register not empty interrupt
  • UART_IT_RXFNE RXFIFO not empty interrupt
  • UART_IT_IDLE Idle line detection interrupt
  • UART_IT_PE Parity Error interrupt
  • UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
Return values:
Thenew state of __INTERRUPT__ (SET or RESET).

Definition at line 1017 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_GET_IT_SOURCE (   __HANDLE__,
  __INTERRUPT__ 
)
Value:
((((((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U) ? (__HANDLE__)->Instance->CR1 : \
                                                               (((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U) ? (__HANDLE__)->Instance->CR2 : \
                                                               (__HANDLE__)->Instance->CR3)) & (1U << (((uint16_t)(__INTERRUPT__)) & UART_IT_MASK)))  != RESET) ? SET : RESET)

Check whether the specified UART interrupt source is enabled or not.

Parameters:
__HANDLE__specifies the UART Handle.
__INTERRUPT__specifies the UART interrupt source to check. This parameter can be one of the following values:
  • UART_IT_RXFF RXFIFO Full interrupt
  • UART_IT_TXFE TXFIFO Empty interrupt
  • UART_IT_RXFT RXFIFO threshold interrupt
  • UART_IT_TXFT TXFIFO threshold interrupt
  • UART_IT_WUF Wakeup from stop mode interrupt
  • UART_IT_CM Character match interrupt
  • UART_IT_CTS CTS change interrupt
  • UART_IT_LBD LIN Break detection interrupt
  • UART_IT_TXE Transmit Data Register empty interrupt
  • UART_IT_TXFNF TX FIFO not full interrupt
  • UART_IT_TC Transmission complete interrupt
  • UART_IT_RXNE Receive Data register not empty interrupt
  • UART_IT_RXFNE RXFIFO not empty interrupt
  • UART_IT_IDLE Idle line detection interrupt
  • UART_IT_PE Parity Error interrupt
  • UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
Return values:
Thenew state of __INTERRUPT__ (SET or RESET).

Definition at line 1041 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_HWCONTROL_CTS_DISABLE (   __HANDLE__)
Value:
do{                                                       \
    CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
    (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE);      \
  } while(0U)

Disable CTS flow control.

Note:
This macro allows to disable CTS hardware flow control for a given UART instance, without need to call HAL_UART_Init() function. As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
As macro is expected to be used for modifying CTS Hw flow control feature activation, without need for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 1132 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_HWCONTROL_CTS_ENABLE (   __HANDLE__)
Value:
do{                                                      \
    SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE);  \
    (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE;        \
  } while(0U)

Enable CTS flow control.

Note:
This macro allows to enable CTS hardware flow control for a given UART instance, without need to call HAL_UART_Init() function. As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
As macro is expected to be used for modifying CTS Hw flow control feature activation, without need for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 1114 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_HWCONTROL_RTS_DISABLE (   __HANDLE__)
Value:
do{                                                      \
    CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
    (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE);     \
  } while(0U)

Disable RTS flow control.

Note:
This macro allows to disable RTS hardware flow control for a given UART instance, without need to call HAL_UART_Init() function. As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
As macro is expected to be used for modifying RTS Hw flow control feature activation, without need for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 1168 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_HWCONTROL_RTS_ENABLE (   __HANDLE__)
Value:
do{                                                     \
    SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
    (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE;       \
  } while(0U)

Enable RTS flow control.

Note:
This macro allows to enable RTS hardware flow control for a given UART instance, without need to call HAL_UART_Init() function. As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
As macro is expected to be used for modifying RTS Hw flow control feature activation, without need for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 1150 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_ONE_BIT_SAMPLE_DISABLE (   __HANDLE__)    ((__HANDLE__)->Instance->CR3 &= ~USART_CR3_ONEBIT)

Disable the UART one bit sample method.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 1088 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_ONE_BIT_SAMPLE_ENABLE (   __HANDLE__)    ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)

Enable the UART one bit sample method.

Parameters:
__HANDLE__specifies the UART Handle.
Return values:
None

Definition at line 1082 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_RESET_HANDLE_STATE (   __HANDLE__)
Value:
do{                                                   \
                                                       (__HANDLE__)->gState = HAL_UART_STATE_RESET;      \
                                                       (__HANDLE__)->RxState = HAL_UART_STATE_RESET;     \
                                                       (__HANDLE__)->MspInitCallback = NULL;             \
                                                       (__HANDLE__)->MspDeInitCallback = NULL;           \
                                                     } while(0U)

Reset UART handle states.

Parameters:
__HANDLE__UART handle.
Return values:
None

Definition at line 829 of file stm32l4xx_hal_uart.h.

#define __HAL_UART_SEND_REQ (   __HANDLE__,
  __REQ__ 
)    ((__HANDLE__)->Instance->RQR |= (__REQ__))

Set a specific UART request flag.

Parameters:
__HANDLE__specifies the UART Handle.
__REQ__specifies the request flag to set This parameter can be one of the following values:
Return values:
None

Definition at line 1076 of file stm32l4xx_hal_uart.h.

Referenced by HAL_MultiProcessor_EnterMuteMode(), HAL_UART_Abort(), HAL_UART_Abort_IT(), HAL_UART_AbortReceive(), HAL_UART_AbortReceive_IT(), HAL_UART_AbortTransmit(), HAL_UART_AbortTransmit_IT(), UART_DMARxAbortCallback(), UART_DMARxOnlyAbortCallback(), UART_DMATxAbortCallback(), UART_DMATxOnlyAbortCallback(), UART_RxISR_16BIT(), and UART_RxISR_8BIT().