STM32L486xx 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)
 Initialize the UART mode according to the specified parameters in the UART_InitTypeDef and initialize the associated handle.
HAL_StatusTypeDef HAL_HalfDuplex_Init (UART_HandleTypeDef *huart)
 Initialize the half-duplex mode according to the specified parameters in the UART_InitTypeDef and creates the associated handle.
HAL_StatusTypeDef HAL_LIN_Init (UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
 Initialize the LIN mode according to the specified parameters in the UART_InitTypeDef and creates the associated handle .
HAL_StatusTypeDef HAL_MultiProcessor_Init (UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
 Initialize the multiprocessor mode according to the specified parameters in the UART_InitTypeDef and initialize the associated handle.
HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart)
 DeInitialize the UART peripheral.
__weak void HAL_UART_MspInit (UART_HandleTypeDef *huart)
 Initialize the UART MSP.
__weak void HAL_UART_MspDeInit (UART_HandleTypeDef *huart)
 DeInitialize the UART MSP.
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.

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 the parameters below 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.
        (++) Hardware flow control
        (++) Receiver/transmitter modes
        (++) Over Sampling Method
        (++) One-Bit Sampling Method
      (+) For the asynchronous mode, the following advanced features can be configured as well:
        (++) TX and/or RX pin level inversion
        (++) data logical level inversion
        (++) RX and TX pins swap
        (++) RX overrun detection disabling
        (++) DMA disabling on RX error
        (++) MSB first on communication line
        (++) auto Baud rate detection
    [..]
    The HAL_UART_Init(), HAL_HalfDuplex_Init(), HAL_LIN_Init()and HAL_MultiProcessor_Init()API
    follow respectively the UART asynchronous, UART Half duplex, UART LIN mode
    and UART multiprocessor mode configuration procedures (details for the procedures
    are available in reference manual).

Depending on the frame length defined by the M1 and M0 bits (7-bit, 8-bit or 9-bit), the possible UART formats are listed in the following table.

Table 1. UART frame format. +-----------------------------------------------------------------------+ | M1 bit | M0 bit | PCE bit | UART frame | |---------|---------|-----------|---------------------------------------| | 0 | 0 | 0 | | SB | 8 bit data | STB | | |---------|---------|-----------|---------------------------------------| | 0 | 0 | 1 | | SB | 7 bit data | PB | STB | | |---------|---------|-----------|---------------------------------------| | 0 | 1 | 0 | | SB | 9 bit data | STB | | |---------|---------|-----------|---------------------------------------| | 0 | 1 | 1 | | SB | 8 bit data | PB | STB | | |---------|---------|-----------|---------------------------------------| | 1 | 0 | 0 | | SB | 7 bit data | STB | | |---------|---------|-----------|---------------------------------------| | 1 | 0 | 1 | | SB | 6 bit data | PB | STB | | +-----------------------------------------------------------------------+


Function Documentation

HAL_StatusTypeDef HAL_HalfDuplex_Init ( UART_HandleTypeDef huart)
HAL_StatusTypeDef HAL_LIN_Init ( UART_HandleTypeDef huart,
uint32_t  BreakDetectLength 
)
HAL_StatusTypeDef HAL_MultiProcessor_Init ( UART_HandleTypeDef huart,
uint8_t  Address,
uint32_t  WakeUpMethod 
)

Initialize the multiprocessor mode according to the specified parameters in the UART_InitTypeDef and initialize the associated handle.

Parameters:
huartUART handle.
AddressUART node address (4-, 6-, 7- or 8-bit long).
WakeUpMethodSpecifies the UART wakeup method. This parameter can be one of the following values:
Note:
If the user resorts to idle line detection wake up, the Address parameter is useless and ignored by the initialization function.
If the user resorts to address mark wake up, the address length detection is configured by default to 4 bits only. For the UART to be able to manage 6-, 7- or 8-bit long addresses detection, the API HAL_MultiProcessorEx_AddressLength_Set() must be called after HAL_MultiProcessor_Init().
Return values:
HALstatus

Definition at line 576 of file stm32l4xx_hal_uart.c.

References __HAL_UART_DISABLE, __HAL_UART_ENABLE, __UART_HandleTypeDef::AdvancedInit, UART_AdvFeatureInitTypeDef::AdvFeatureInit, assert_param, __UART_HandleTypeDef::gState, HAL_UART_MspInit(), HAL_UART_STATE_BUSY, HAL_UART_STATE_RESET, __UART_HandleTypeDef::Instance, IS_UART_WAKEUPMETHOD, __UART_HandleTypeDef::Lock, __UART_HandleTypeDef::MspInitCallback, UART_ADVFEATURE_NO_INIT, UART_AdvFeatureConfig(), UART_CheckIdleState(), UART_CR2_ADDRESS_LSB_POS, UART_InitCallbacksToDefault(), UART_SetConfig(), and UART_WAKEUPMETHOD_ADDRESSMARK.

HAL_StatusTypeDef HAL_UART_DeInit ( UART_HandleTypeDef huart)
HAL_StatusTypeDef HAL_UART_Init ( UART_HandleTypeDef huart)

DeInitialize the UART MSP.

Parameters:
huartUART handle.
Return values:
None

Definition at line 714 of file stm32l4xx_hal_uart.c.

Referenced by HAL_UART_DeInit(), and HAL_UART_UnRegisterCallback().

Initialize the UART MSP.

Parameters:
huartUART handle.
Return values:
None

Definition at line 699 of file stm32l4xx_hal_uart.c.

Referenced by HAL_HalfDuplex_Init(), HAL_LIN_Init(), HAL_MultiProcessor_Init(), HAL_RS485Ex_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 747 of file stm32l4xx_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, HAL_UART_WAKEUP_CB_ID, __UART_HandleTypeDef::MspDeInitCallback, __UART_HandleTypeDef::MspInitCallback, __UART_HandleTypeDef::RxCpltCallback, __UART_HandleTypeDef::RxHalfCpltCallback, __UART_HandleTypeDef::TxCpltCallback, __UART_HandleTypeDef::TxHalfCpltCallback, and __UART_HandleTypeDef::WakeupCallback.

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 885 of file stm32l4xx_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(), HAL_UART_WAKEUP_CB_ID, HAL_UARTEx_WakeupCallback(), __UART_HandleTypeDef::MspDeInitCallback, __UART_HandleTypeDef::MspInitCallback, __UART_HandleTypeDef::RxCpltCallback, __UART_HandleTypeDef::RxHalfCpltCallback, __UART_HandleTypeDef::TxCpltCallback, __UART_HandleTypeDef::TxHalfCpltCallback, and __UART_HandleTypeDef::WakeupCallback.