Extended Peripheral Control functions.
More...
Extended Peripheral Control functions.
===============================================================================
##### Peripheral Control functions #####
===============================================================================
[..] This section provides the following functions:
(+) HAL_UARTEx_EnableClockStopMode() API enables the UART clock (HSI or LSE only) during stop mode
(+) HAL_UARTEx_DisableClockStopMode() API disables the above functionality
(+) HAL_MultiProcessorEx_AddressLength_Set() API optionally sets the UART node address
detection length to more than 4 bits for multiprocessor address mark wake up.
(+) HAL_UARTEx_StopModeWakeUpSourceConfig() API defines the wake-up from stop mode
trigger: address match, Start Bit detection or RXNE bit status.
(+) HAL_UARTEx_EnableStopMode() API enables the UART to wake up the MCU from stop mode
(+) HAL_UARTEx_DisableStopMode() API disables the above functionality
(+) HAL_UARTEx_EnableFifoMode() API enables the FIFO mode
(+) HAL_UARTEx_DisableFifoMode() API disables the FIFO mode
(+) HAL_UARTEx_SetTxFifoThreshold() API sets the TX FIFO threshold
(+) HAL_UARTEx_SetRxFifoThreshold() API sets the RX FIFO threshold
◆ HAL_MultiProcessorEx_AddressLength_Set()
| HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set |
( |
UART_HandleTypeDef * |
huart, |
|
|
uint32_t |
AddressLength |
|
) |
| |
By default in multiprocessor mode, when the wake up method is set to address mark, the UART handles only 4-bit long addresses detection; this API allows to enable longer addresses detection (6-, 7- or 8-bit long).
- Note
- Addresses detection lengths are: 6-bit address detection in 7-bit data mode, 7-bit address detection in 8-bit data mode, 8-bit address detection in 9-bit data mode.
- Parameters
-
| huart | UART handle. |
| AddressLength | This parameter can be one of the following values:
- UART_ADDRESS_DETECT_4B 4-bit long address
- UART_ADDRESS_DETECT_7B 6-, 7- or 8-bit long address
|
- Return values
-
Definition at line 406 of file stm32l4xx_hal_uart_ex.c.
415 assert_param(IS_UART_ADDRESSLENGTH_DETECT(AddressLength));
417 huart->
gState = HAL_UART_STATE_BUSY;
420 __HAL_UART_DISABLE(huart);
426 __HAL_UART_ENABLE(huart);
HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart)
Check the UART Idle State.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__IO HAL_UART_StateTypeDef gState
◆ HAL_UARTEx_DisableClockStopMode()
Disable UART Clock when in Stop Mode.
- Parameters
-
- Return values
-
Definition at line 378 of file stm32l4xx_hal_uart_ex.c.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
◆ HAL_UARTEx_DisableFifoMode()
Disable the FIFO mode.
- Parameters
-
- Return values
-
Definition at line 579 of file stm32l4xx_hal_uart_ex.c.
589 huart->
gState = HAL_UART_STATE_BUSY;
592 tmpcr1 = READ_REG(huart->
Instance->CR1);
595 __HAL_UART_DISABLE(huart);
599 huart->
FifoMode = UART_FIFOMODE_DISABLE;
602 WRITE_REG(huart->
Instance->CR1, tmpcr1);
604 huart->
gState = HAL_UART_STATE_READY;
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__IO HAL_UART_StateTypeDef gState
◆ HAL_UARTEx_DisableStopMode()
Disable UART Stop Mode.
- Parameters
-
- Return values
-
Definition at line 518 of file stm32l4xx_hal_uart_ex.c.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
◆ HAL_UARTEx_EnableClockStopMode()
Keep UART Clock enabled when in Stop Mode.
- Note
- When the USART clock source is configured to be LSE or HSI, it is possible to keep enabled this clock during STOP mode by setting the UCESM bit in USART_CR3 control register.
-
When LPUART is used to wakeup from stop with LSE is selected as LPUART clock source, and desired baud rate is 9600 baud, the bit UCESM bit in LPUART_CR3 control register must be set.
- Parameters
-
- Return values
-
Definition at line 359 of file stm32l4xx_hal_uart_ex.c.
365 SET_BIT(huart->
Instance->CR3, USART_CR3_UCESM);
◆ HAL_UARTEx_EnableFifoMode()
Enable the FIFO mode.
- Parameters
-
- Return values
-
Definition at line 538 of file stm32l4xx_hal_uart_ex.c.
548 huart->
gState = HAL_UART_STATE_BUSY;
551 tmpcr1 = READ_REG(huart->
Instance->CR1);
554 __HAL_UART_DISABLE(huart);
557 SET_BIT(tmpcr1, USART_CR1_FIFOEN);
558 huart->
FifoMode = UART_FIFOMODE_ENABLE;
561 WRITE_REG(huart->
Instance->CR1, tmpcr1);
566 huart->
gState = HAL_UART_STATE_READY;
static void UARTEx_SetNbDataToProcess(UART_HandleTypeDef *huart)
Calculate the number of data to process in RX/TX ISR.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__IO HAL_UART_StateTypeDef gState
◆ HAL_UARTEx_EnableStopMode()
Enable UART Stop Mode.
- Note
- The UART is able to wake up the MCU from Stop 1 mode as long as UART clock is HSI or LSE.
- Parameters
-
- Return values
-
Definition at line 499 of file stm32l4xx_hal_uart_ex.c.
505 SET_BIT(huart->
Instance->CR1, USART_CR1_UESM);
◆ HAL_UARTEx_SetRxFifoThreshold()
| HAL_StatusTypeDef HAL_UARTEx_SetRxFifoThreshold |
( |
UART_HandleTypeDef * |
huart, |
|
|
uint32_t |
Threshold |
|
) |
| |
Set the RXFIFO threshold.
- Parameters
-
| huart | UART handle. |
| Threshold | RX FIFO threshold value This parameter can be one of the following values:
- UART_RXFIFO_THRESHOLD_1_8
- UART_RXFIFO_THRESHOLD_1_4
- UART_RXFIFO_THRESHOLD_1_2
- UART_RXFIFO_THRESHOLD_3_4
- UART_RXFIFO_THRESHOLD_7_8
- UART_RXFIFO_THRESHOLD_8_8
|
- Return values
-
Definition at line 674 of file stm32l4xx_hal_uart_ex.c.
685 huart->
gState = HAL_UART_STATE_BUSY;
688 tmpcr1 = READ_REG(huart->
Instance->CR1);
691 __HAL_UART_DISABLE(huart);
700 WRITE_REG(huart->
Instance->CR1, tmpcr1);
702 huart->
gState = HAL_UART_STATE_READY;
static void UARTEx_SetNbDataToProcess(UART_HandleTypeDef *huart)
Calculate the number of data to process in RX/TX ISR.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__IO HAL_UART_StateTypeDef gState
◆ HAL_UARTEx_SetTxFifoThreshold()
| HAL_StatusTypeDef HAL_UARTEx_SetTxFifoThreshold |
( |
UART_HandleTypeDef * |
huart, |
|
|
uint32_t |
Threshold |
|
) |
| |
Set the TXFIFO threshold.
- Parameters
-
| huart | UART handle. |
| Threshold | TX FIFO threshold value This parameter can be one of the following values:
- UART_TXFIFO_THRESHOLD_1_8
- UART_TXFIFO_THRESHOLD_1_4
- UART_TXFIFO_THRESHOLD_1_2
- UART_TXFIFO_THRESHOLD_3_4
- UART_TXFIFO_THRESHOLD_7_8
- UART_TXFIFO_THRESHOLD_8_8
|
- Return values
-
Definition at line 625 of file stm32l4xx_hal_uart_ex.c.
636 huart->
gState = HAL_UART_STATE_BUSY;
639 tmpcr1 = READ_REG(huart->
Instance->CR1);
642 __HAL_UART_DISABLE(huart);
651 WRITE_REG(huart->
Instance->CR1, tmpcr1);
653 huart->
gState = HAL_UART_STATE_READY;
static void UARTEx_SetNbDataToProcess(UART_HandleTypeDef *huart)
Calculate the number of data to process in RX/TX ISR.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__IO HAL_UART_StateTypeDef gState
◆ HAL_UARTEx_StopModeWakeUpSourceConfig()
Set Wakeup from Stop mode interrupt flag selection.
- Note
- It is the application responsibility to enable the interrupt used as usart_wkup interrupt source before entering low-power mode.
- Parameters
-
| huart | UART handle. |
| WakeUpSelection | Address match, Start Bit detection or RXNE/RXFNE bit status. This parameter can be one of the following values:
- UART_WAKEUP_ON_ADDRESS
- UART_WAKEUP_ON_STARTBIT
- UART_WAKEUP_ON_READDATA_NONEMPTY
|
- Return values
-
Definition at line 444 of file stm32l4xx_hal_uart_ex.c.
446 HAL_StatusTypeDef status =
HAL_OK;
457 huart->
gState = HAL_UART_STATE_BUSY;
460 __HAL_UART_DISABLE(huart);
465 if (WakeUpSelection.
WakeUpEvent == UART_WAKEUP_ON_ADDRESS)
471 __HAL_UART_ENABLE(huart);
479 status = HAL_TIMEOUT;
484 huart->
gState = HAL_UART_STATE_READY;
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
static void UARTEx_Wakeup_AddressConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection)
Initialize the UART wake-up from stop mode parameters when triggered by address detection.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
Handle UART Communication Timeout.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__IO HAL_UART_StateTypeDef gState