|
STM32G474xx HAL用户手册
|
初始化和配置函数。 更多...
函数 | |
| 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 | ) |
根据UART_InitTypeDef中指定的参数初始化半双工模式,并创建关联的句柄。
| huart | UART句柄。 |
| HAL | 状态 |
定义于382行,文件stm32g4xx_hal_uart.c。
引用__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、__UART_HandleTypeDef::Lock、__UART_HandleTypeDef::MspInitCallback、UART_ADVFEATURE_NO_INIT、UART_AdvFeatureConfig()、UART_CheckIdleState()、UART_InitCallbacksToDefault()和UART_SetConfig()。
| HAL_StatusTypeDef HAL_LIN_Init | ( | UART_HandleTypeDef * | huart, |
| uint32_t | BreakDetectLength | ||
| ) |
根据UART_InitTypeDef中指定的参数初始化LIN模式,并创建关联的句柄。
| huart | UART句柄。 |
| BreakDetectLength | 指定LIN断点检测长度。该参数可以是以下值之一:
|
| HAL | 状态 |
定义于457行,文件stm32g4xx_hal_uart.c。
引用__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::Init、__UART_HandleTypeDef::Instance、IS_UART_LIN_BREAK_DETECT_LENGTH、__UART_HandleTypeDef::Lock、__UART_HandleTypeDef::MspInitCallback、UART_InitTypeDef::OverSampling、UART_ADVFEATURE_NO_INIT、UART_AdvFeatureConfig()、UART_CheckIdleState()、UART_InitCallbacksToDefault()、UART_OVERSAMPLING_8、UART_SetConfig()、UART_WORDLENGTH_8B和UART_InitTypeDef::WordLength。
| HAL_StatusTypeDef HAL_MultiProcessor_Init | ( | UART_HandleTypeDef * | huart, |
| uint8_t | Address, | ||
| uint32_t | WakeUpMethod | ||
| ) |
根据UART_InitTypeDef中指定的参数初始化多处理器模式,并初始化关联的句柄。
| huart | UART句柄。 |
| Address | UART节点地址(4、6、7或8位长)。 |
| WakeUpMethod | 指定UART唤醒方法。该参数可以是以下值之一:
|
| HAL | 状态 |