STM32F103xB HAL User Manual
Functions
Initialization and de-initialization functions
UART Exported Functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_UART_Init (UART_HandleTypeDef *huart)
 Initializes the UART mode according to the specified parameters in the UART_InitTypeDef and create the associated handle.
HAL_StatusTypeDef HAL_HalfDuplex_Init (UART_HandleTypeDef *huart)
 Initializes the half-duplex mode according to the specified parameters in the UART_InitTypeDef and create the associated handle.
HAL_StatusTypeDef HAL_LIN_Init (UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
 Initializes the LIN mode according to the specified parameters in the UART_InitTypeDef and create the associated handle.
HAL_StatusTypeDef HAL_MultiProcessor_Init (UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
 Initializes the Multi-Processor mode according to the specified parameters in the UART_InitTypeDef and create the associated handle.
HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart)
 DeInitializes the UART peripheral.
__weak void HAL_UART_MspInit (UART_HandleTypeDef *huart)
 UART MSP Init.
__weak void HAL_UART_MspDeInit (UART_HandleTypeDef *huart)
 UART MSP DeInit.
HAL_StatusTypeDef HAL_UART_RegisterCallback (UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID, pUART_CallbackTypeDef pCallback)
 Register a User UART Callback To be used instead of the weak predefined callback.
HAL_StatusTypeDef HAL_UART_UnRegisterCallback (UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID)
 Unregister an UART Callback UART callaback is redirected to the weak predefined callback.
HAL_StatusTypeDef HAL_UART_RegisterRxEventCallback (UART_HandleTypeDef *huart, pUART_RxEventCallbackTypeDef pCallback)
 Register a User UART Rx Event Callback To be used instead of the weak predefined callback.
HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback (UART_HandleTypeDef *huart)
 UnRegister the UART Rx Event Callback UART Rx Event Callback is redirected to the weak HAL_UARTEx_RxEventCallback() predefined callback.

Detailed Description

Initialization and Configuration functions.

 ===============================================================================
            ##### Initialization and Configuration functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to initialize the USARTx or the UARTy
    in asynchronous mode.
      (+) For the asynchronous mode only these parameters can be configured:
        (++) Baud Rate
        (++) Word Length
        (++) Stop Bit
        (++) Parity: If the parity is enabled, then the MSB bit of the data written
             in the data register is transmitted but is changed by the parity bit.
             Depending on the frame length defined by the M bit (8-bits or 9-bits),
             please refer to Reference manual for possible UART frame formats.
        (++) Hardware flow control
        (++) Receiver/transmitter modes
        (++) Over Sampling Method
    [..]
    The HAL_UART_Init(), HAL_HalfDuplex_Init(), HAL_LIN_Init() and HAL_MultiProcessor_Init() APIs
    follow respectively the UART asynchronous, UART Half duplex, LIN and Multi-Processor configuration
    procedures (details for the procedures are available in reference manuals
    (RM0008 for STM32F10Xxx MCUs and RM0041 for STM32F100xx MCUs)).


Function Documentation

HAL_StatusTypeDef HAL_HalfDuplex_Init ( UART_HandleTypeDef huart)

Initializes the half-duplex mode according to the specified parameters in the UART_InitTypeDef and create the associated handle.

Parameters:
huartPointer to a UART_HandleTypeDef structure that contains the configuration information for the specified UART module.
Return values:
HALstatus

Definition at line 429 of file stm32f1xx_hal_uart.c.

References __HAL_UART_DISABLE, __HAL_UART_ENABLE, assert_param, __UART_HandleTypeDef::ErrorCode, __UART_HandleTypeDef::gState, HAL_UART_ERROR_NONE, HAL_UART_MspInit(), HAL_UART_STATE_BUSY, HAL_UART_STATE_READY, HAL_UART_STATE_RESET, __UART_HandleTypeDef::Init, __UART_HandleTypeDef::Instance, IS_UART_WORD_LENGTH, __UART_HandleTypeDef::Lock, __UART_HandleTypeDef::MspInitCallback, UART_InitTypeDef::OverSampling, __UART_HandleTypeDef::RxState, UART_InitCallbacksToDefault(), UART_SetConfig(), and UART_InitTypeDef::WordLength.

HAL_StatusTypeDef HAL_LIN_Init ( UART_HandleTypeDef huart,
uint32_t  BreakDetectLength 
)

Initializes the LIN mode according to the specified parameters in the UART_InitTypeDef and create the associated handle.

Parameters:
huartPointer to a UART_HandleTypeDef structure that contains the configuration information for the specified UART module.
BreakDetectLengthSpecifies the LIN break detection length. This parameter can be one of the following values:
  • UART_LINBREAKDETECTLENGTH_10B: 10-bit break detection
  • UART_LINBREAKDETECTLENGTH_11B: 11-bit break detection
Return values:
HALstatus

Definition at line 504 of file stm32f1xx_hal_uart.c.

References __HAL_UART_DISABLE, __HAL_UART_ENABLE, assert_param, __UART_HandleTypeDef::ErrorCode, __UART_HandleTypeDef::gState, HAL_UART_ERROR_NONE, HAL_UART_MspInit(), HAL_UART_STATE_BUSY, HAL_UART_STATE_READY, HAL_UART_STATE_RESET, __UART_HandleTypeDef::Init, __UART_HandleTypeDef::Instance, IS_UART_LIN_BREAK_DETECT_LENGTH, IS_UART_LIN_OVERSAMPLING, IS_UART_LIN_WORD_LENGTH, __UART_HandleTypeDef::Lock, __UART_HandleTypeDef::MspInitCallback, UART_InitTypeDef::OverSampling, __UART_HandleTypeDef::RxState, UART_InitCallbacksToDefault(), UART_SetConfig(), and UART_InitTypeDef::WordLength.

HAL_StatusTypeDef HAL_MultiProcessor_Init ( UART_HandleTypeDef huart,
uint8_t  Address,
uint32_t  WakeUpMethod 
)

Initializes the Multi-Processor mode according to the specified parameters in the UART_InitTypeDef and create the associated handle.

Parameters:
huartPointer to a UART_HandleTypeDef structure that contains the configuration information for the specified UART module.
AddressUSART address
WakeUpMethodspecifies the USART wake-up method. This parameter can be one of the following values:
  • UART_WAKEUPMETHOD_IDLELINE: Wake-up by an idle line detection
  • UART_WAKEUPMETHOD_ADDRESSMARK: Wake-up by an address mark
Return values:
HALstatus

Definition at line 587 of file stm32f1xx_hal_uart.c.

References __HAL_UART_DISABLE, __HAL_UART_ENABLE, assert_param, __UART_HandleTypeDef::ErrorCode, __UART_HandleTypeDef::gState, HAL_UART_ERROR_NONE, HAL_UART_MspInit(), HAL_UART_STATE_BUSY, HAL_UART_STATE_READY, HAL_UART_STATE_RESET, __UART_HandleTypeDef::Init, __UART_HandleTypeDef::Instance, IS_UART_ADDRESS, IS_UART_WAKEUPMETHOD, IS_UART_WORD_LENGTH, __UART_HandleTypeDef::Lock, __UART_HandleTypeDef::MspInitCallback, UART_InitTypeDef::OverSampling, __UART_HandleTypeDef::RxState, UART_InitCallbacksToDefault(), UART_SetConfig(), and UART_InitTypeDef::WordLength.

HAL_StatusTypeDef HAL_UART_DeInit ( UART_HandleTypeDef huart)

DeInitializes the UART peripheral.

Parameters:
huartPointer to a UART_HandleTypeDef structure that contains the configuration information for the specified UART module.
Return values:
HALstatus

Definition at line 666 of file stm32f1xx_hal_uart.c.

References __HAL_UART_DISABLE, assert_param, __UART_HandleTypeDef::ErrorCode, __UART_HandleTypeDef::gState, HAL_UART_ERROR_NONE, HAL_UART_MspDeInit(), HAL_UART_RECEPTION_STANDARD, HAL_UART_STATE_BUSY, HAL_UART_STATE_RESET, __UART_HandleTypeDef::Instance, __UART_HandleTypeDef::MspDeInitCallback, __UART_HandleTypeDef::ReceptionType, and __UART_HandleTypeDef::RxState.

HAL_StatusTypeDef HAL_UART_Init ( UART_HandleTypeDef huart)

UART MSP DeInit.

Parameters:
huartPointer to a UART_HandleTypeDef structure that contains the configuration information for the specified UART module.
Return values:
None

Definition at line 726 of file stm32f1xx_hal_uart.c.

Referenced by HAL_UART_DeInit(), and HAL_UART_UnRegisterCallback().

UART MSP Init.

Parameters:
huartPointer to a UART_HandleTypeDef structure that contains the configuration information for the specified UART module.
Return values:
None

Definition at line 711 of file stm32f1xx_hal_uart.c.

Referenced by HAL_HalfDuplex_Init(), HAL_LIN_Init(), HAL_MultiProcessor_Init(), HAL_UART_Init(), and HAL_UART_UnRegisterCallback().

HAL_StatusTypeDef HAL_UART_RegisterCallback ( UART_HandleTypeDef huart,
HAL_UART_CallbackIDTypeDef  CallbackID,
pUART_CallbackTypeDef  pCallback 
)

Register a User UART Callback To be used instead of the weak predefined callback.

Parameters:
huartuart handle
CallbackIDID of the callback to be registered This parameter can be one of the following values:
pCallbackpointer to the Callback function
Return values:
HALstatus

Definition at line 755 of file stm32f1xx_hal_uart.c.

References __UART_HandleTypeDef::AbortCpltCallback, __UART_HandleTypeDef::AbortReceiveCpltCallback, __UART_HandleTypeDef::AbortTransmitCpltCallback, __UART_HandleTypeDef::ErrorCallback, __UART_HandleTypeDef::ErrorCode, __UART_HandleTypeDef::gState, HAL_UART_ABORT_COMPLETE_CB_ID, HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID, HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID, HAL_UART_ERROR_CB_ID, HAL_UART_ERROR_INVALID_CALLBACK, HAL_UART_MSPDEINIT_CB_ID, HAL_UART_MSPINIT_CB_ID, HAL_UART_RX_COMPLETE_CB_ID, HAL_UART_RX_HALFCOMPLETE_CB_ID, HAL_UART_STATE_READY, HAL_UART_STATE_RESET, HAL_UART_TX_COMPLETE_CB_ID, HAL_UART_TX_HALFCOMPLETE_CB_ID, __UART_HandleTypeDef::MspDeInitCallback, __UART_HandleTypeDef::MspInitCallback, __UART_HandleTypeDef::RxCpltCallback, __UART_HandleTypeDef::RxHalfCpltCallback, __UART_HandleTypeDef::TxCpltCallback, and __UART_HandleTypeDef::TxHalfCpltCallback.

Register a User UART Rx Event Callback To be used instead of the weak predefined callback.

Parameters:
huartUart handle
pCallbackPointer to the Rx Event Callback function
Return values:
HALstatus

Definition at line 979 of file stm32f1xx_hal_uart.c.

References __UART_HandleTypeDef::ErrorCode, __UART_HandleTypeDef::gState, HAL_UART_ERROR_INVALID_CALLBACK, HAL_UART_STATE_READY, and __UART_HandleTypeDef::RxEventCallback.

HAL_StatusTypeDef HAL_UART_UnRegisterCallback ( UART_HandleTypeDef huart,
HAL_UART_CallbackIDTypeDef  CallbackID 
)

Unregister an UART Callback UART callaback is redirected to the weak predefined callback.

Parameters:
huartuart handle
CallbackIDID of the callback to be unregistered This parameter can be one of the following values:
Return values:
HALstatus

Definition at line 876 of file stm32f1xx_hal_uart.c.

References __UART_HandleTypeDef::AbortCpltCallback, __UART_HandleTypeDef::AbortReceiveCpltCallback, __UART_HandleTypeDef::AbortTransmitCpltCallback, __UART_HandleTypeDef::ErrorCallback, __UART_HandleTypeDef::ErrorCode, __UART_HandleTypeDef::gState, HAL_UART_ABORT_COMPLETE_CB_ID, HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID, HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID, HAL_UART_AbortCpltCallback(), HAL_UART_AbortReceiveCpltCallback(), HAL_UART_AbortTransmitCpltCallback(), HAL_UART_ERROR_CB_ID, HAL_UART_ERROR_INVALID_CALLBACK, HAL_UART_ErrorCallback(), HAL_UART_MspDeInit(), HAL_UART_MSPDEINIT_CB_ID, HAL_UART_MspInit(), HAL_UART_MSPINIT_CB_ID, HAL_UART_RX_COMPLETE_CB_ID, HAL_UART_RX_HALFCOMPLETE_CB_ID, HAL_UART_RxCpltCallback(), HAL_UART_RxHalfCpltCallback(), HAL_UART_STATE_READY, HAL_UART_STATE_RESET, HAL_UART_TX_COMPLETE_CB_ID, HAL_UART_TX_HALFCOMPLETE_CB_ID, HAL_UART_TxCpltCallback(), HAL_UART_TxHalfCpltCallback(), __UART_HandleTypeDef::MspDeInitCallback, __UART_HandleTypeDef::MspInitCallback, __UART_HandleTypeDef::RxCpltCallback, __UART_HandleTypeDef::RxHalfCpltCallback, __UART_HandleTypeDef::TxCpltCallback, and __UART_HandleTypeDef::TxHalfCpltCallback.

UnRegister the UART Rx Event Callback UART Rx Event Callback is redirected to the weak HAL_UARTEx_RxEventCallback() predefined callback.

Parameters:
huartUart handle
Return values:
HALstatus

Definition at line 1016 of file stm32f1xx_hal_uart.c.

References __UART_HandleTypeDef::ErrorCode, __UART_HandleTypeDef::gState, HAL_UART_ERROR_INVALID_CALLBACK, HAL_UART_STATE_READY, HAL_UARTEx_RxEventCallback(), and __UART_HandleTypeDef::RxEventCallback.