STM32G474xx HAL用户手册
函数
初始化和反初始化函数
UART导出函数

初始化和配置函数。 更多...

函数

HAL_StatusTypeDef HAL_UART_Init (UART_HandleTypeDef *huart)
 根据UART_InitTypeDef中指定的参数初始化UART模式,并初始化关联的句柄。
HAL_StatusTypeDef HAL_HalfDuplex_Init (UART_HandleTypeDef *huart)
 根据UART_InitTypeDef中指定的参数初始化半双工模式,并创建关联的句柄。
HAL_StatusTypeDef HAL_LIN_Init (UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
 根据UART_InitTypeDef中指定的参数初始化LIN模式,并创建关联的句柄。
HAL_StatusTypeDef HAL_MultiProcessor_Init (UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
 根据UART_InitTypeDef中指定的参数初始化多处理器模式,并初始化关联的句柄。
HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart)
 反初始化UART外设。
__weak void HAL_UART_MspInit (UART_HandleTypeDef *huart)
 初始化UART MSP。
__weak void HAL_UART_MspDeInit (UART_HandleTypeDef *huart)
 反初始化UART MSP。
HAL_StatusTypeDef HAL_UART_RegisterCallback (UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID, pUART_CallbackTypeDef pCallback)
 注册用户UART回调函数,用于覆盖弱预定义回调。
HAL_StatusTypeDef HAL_UART_UnRegisterCallback (UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID)
 取消注册UART回调,UART回调被重定向到弱预定义回调。
HAL_StatusTypeDef HAL_UART_RegisterRxEventCallback (UART_HandleTypeDef *huart, pUART_RxEventCallbackTypeDef pCallback)
 注册用户UART Rx事件回调函数,用于替代弱预定义回调。
HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback (UART_HandleTypeDef *huart)
 取消注册UART Rx事件回调,UART Rx事件回调被重定向到弱HAL_UARTEx_RxEventCallback()预定义回调。

详细说明

初始化和配置函数。

===============================================================================
            ##### 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).

根据M1和M0位(7位、8位或9位)定义的帧长度,下表列出了可能的UART格式。

表1. UART帧格式。 +-----------------------------------------------------------------------+ | 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 | | +-----------------------------------------------------------------------+


函数文档

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 
)

根据UART_InitTypeDef中指定的参数初始化多处理器模式,并初始化关联的句柄。

参数:
huartUART句柄。
AddressUART节点地址(4、6、7或8位长)。
WakeUpMethod指定UART唤醒方法。该参数可以是以下值之一:
注意:
如果用户采用空闲线检测唤醒,则Address参数无效,将被初始化函数忽略。
如果用户采用地址标记唤醒,则地址长度检测默认配置为4位。为了使UART能够管理6、7或8位长的地址检测,必须在调用HAL_MultiProcessor_Init()之后调用API HAL_MultiProcessorEx_AddressLength_Set()
返回值:
</
HAL状态