Extended Peripheral Control functions.
More...
Extended Peripheral Control functions.
===============================================================================
##### Peripheral Control functions #####
===============================================================================
[..] This section provides the following functions:
(+) HAL_USARTEx_EnableSPISlaveMode() API enables the SPI slave mode
(+) HAL_USARTEx_DisableSPISlaveMode() API disables the SPI slave mode
(+) HAL_USARTEx_ConfigNSS API configures the Slave Select input pin (NSS)
(+) HAL_USARTEx_EnableFifoMode() API enables the FIFO mode
(+) HAL_USARTEx_DisableFifoMode() API disables the FIFO mode
(+) HAL_USARTEx_SetTxFifoThreshold() API sets the TX FIFO threshold
(+) HAL_USARTEx_SetRxFifoThreshold() API sets the RX FIFO threshold
◆ HAL_USARTEx_ConfigNSS()
Configure the Slave Select input pin (NSS).
- Note
- Software NSS management: SPI slave will always be selected and NSS input pin will be ignored.
-
Hardware NSS management: the SPI slave selection depends on NSS input pin. The slave is selected when NSS is low and deselected when NSS is high.
- Parameters
-
| husart | USART handle. |
| NSSConfig | NSS configuration. This parameter can be one of the following values:
- USART_NSS_HARD
- USART_NSS_SOFT
|
- Return values
-
Definition at line 271 of file stm32l4xx_hal_usart_ex.c.
285 tmpcr1 = READ_REG(husart->
Instance->CR1);
288 __HAL_USART_DISABLE(husart);
294 WRITE_REG(husart->
Instance->CR1, tmpcr1);
__IO HAL_USART_StateTypeDef State
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
◆ HAL_USARTEx_DisableFifoMode()
Disable the FIFO mode.
- Parameters
-
- Return values
-
Definition at line 352 of file stm32l4xx_hal_usart_ex.c.
365 tmpcr1 = READ_REG(husart->
Instance->CR1);
368 __HAL_USART_DISABLE(husart);
372 husart->
FifoMode = USART_FIFOMODE_DISABLE;
375 WRITE_REG(husart->
Instance->CR1, tmpcr1);
__IO HAL_USART_StateTypeDef State
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
◆ HAL_USARTEx_DisableSlaveMode()
Disable the SPI slave mode.
- Parameters
-
- Return values
-
Definition at line 223 of file stm32l4xx_hal_usart_ex.c.
236 tmpcr1 = READ_REG(husart->
Instance->CR1);
239 __HAL_USART_DISABLE(husart);
245 WRITE_REG(husart->
Instance->CR1, tmpcr1);
247 husart->
SlaveMode = USART_SLAVEMODE_ENABLE;
__IO HAL_USART_StateTypeDef State
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
◆ HAL_USARTEx_EnableFifoMode()
Enable the FIFO mode.
- Parameters
-
- Return values
-
Definition at line 311 of file stm32l4xx_hal_usart_ex.c.
324 tmpcr1 = READ_REG(husart->
Instance->CR1);
327 __HAL_USART_DISABLE(husart);
330 SET_BIT(tmpcr1, USART_CR1_FIFOEN);
331 husart->
FifoMode = USART_FIFOMODE_ENABLE;
334 WRITE_REG(husart->
Instance->CR1, tmpcr1);
__IO HAL_USART_StateTypeDef State
static void USARTEx_SetNbDataToProcess(USART_HandleTypeDef *husart)
Calculate the number of data to process in RX/TX ISR.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
◆ HAL_USARTEx_EnableSlaveMode()
Enable the SPI slave mode.
- Note
- When the USART operates in SPI slave mode, it handles data flow using the serial interface clock derived from the external SCLK signal provided by the external master SPI device.
-
In SPI slave mode, the USART must be enabled before starting the master communications (or between frames while the clock is stable). Otherwise, if the USART slave is enabled while the master is in the middle of a frame, it will become desynchronized with the master.
-
The data register of the slave needs to be ready before the first edge of the communication clock or before the end of the ongoing communication, otherwise the SPI slave will transmit zeros.
- Parameters
-
- Return values
-
Definition at line 175 of file stm32l4xx_hal_usart_ex.c.
188 tmpcr1 = READ_REG(husart->
Instance->CR1);
191 __HAL_USART_DISABLE(husart);
197 CLEAR_BIT(husart->
Instance->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
200 SET_BIT(husart->
Instance->CR2, USART_CR2_SLVEN);
203 WRITE_REG(husart->
Instance->CR1, tmpcr1);
205 husart->
SlaveMode = USART_SLAVEMODE_ENABLE;
210 __HAL_USART_ENABLE(husart);
__IO HAL_USART_StateTypeDef State
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
◆ HAL_USARTEx_SetRxFifoThreshold()
| HAL_StatusTypeDef HAL_USARTEx_SetRxFifoThreshold |
( |
USART_HandleTypeDef * |
husart, |
|
|
uint32_t |
Threshold |
|
) |
| |
Set the RXFIFO threshold.
- Parameters
-
| husart | USART handle. |
| Threshold | RX FIFO threshold value This parameter can be one of the following values:
- USART_RXFIFO_THRESHOLD_1_8
- USART_RXFIFO_THRESHOLD_1_4
- USART_RXFIFO_THRESHOLD_1_2
- USART_RXFIFO_THRESHOLD_3_4
- USART_RXFIFO_THRESHOLD_7_8
- USART_RXFIFO_THRESHOLD_8_8
|
- Return values
-
Definition at line 447 of file stm32l4xx_hal_usart_ex.c.
461 tmpcr1 = READ_REG(husart->
Instance->CR1);
464 __HAL_USART_DISABLE(husart);
473 WRITE_REG(husart->
Instance->CR1, tmpcr1);
__IO HAL_USART_StateTypeDef State
static void USARTEx_SetNbDataToProcess(USART_HandleTypeDef *husart)
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))
◆ HAL_USARTEx_SetTxFifoThreshold()
| HAL_StatusTypeDef HAL_USARTEx_SetTxFifoThreshold |
( |
USART_HandleTypeDef * |
husart, |
|
|
uint32_t |
Threshold |
|
) |
| |
Set the TXFIFO threshold.
- Parameters
-
| husart | USART handle. |
| Threshold | TX FIFO threshold value This parameter can be one of the following values:
- USART_TXFIFO_THRESHOLD_1_8
- USART_TXFIFO_THRESHOLD_1_4
- USART_TXFIFO_THRESHOLD_1_2
- USART_TXFIFO_THRESHOLD_3_4
- USART_TXFIFO_THRESHOLD_7_8
- USART_TXFIFO_THRESHOLD_8_8
|
- Return values
-
Definition at line 398 of file stm32l4xx_hal_usart_ex.c.
412 tmpcr1 = READ_REG(husart->
Instance->CR1);
415 __HAL_USART_DISABLE(husart);
424 WRITE_REG(husart->
Instance->CR1, tmpcr1);
__IO HAL_USART_StateTypeDef State
static void USARTEx_SetNbDataToProcess(USART_HandleTypeDef *husart)
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))