Management functions.
More...
Management functions.
===============================================================================
##### Peripheral Control functions #####
===============================================================================
[..] This section provides functions allowing to:
(+) Get the 32 bit Random number
(+) Get the 32 bit Random number with interrupt enabled
(+) Handle RNG interrupt request
◆ HAL_RNG_ErrorCallback()
RNG error callback.
- Parameters
-
| hrng | pointer to a RNG_HandleTypeDef structure. |
- Return values
-
Definition at line 780 of file stm32l4xx_hal_rng.c.
◆ HAL_RNG_GenerateRandomNumber()
| HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber |
( |
RNG_HandleTypeDef * |
hrng, |
|
|
uint32_t * |
random32bit |
|
) |
| |
Generate a 32-bit random number.
- Note
- Each time the random number data is read the RNG_FLAG_DRDY flag is automatically cleared.
- Parameters
-
| hrng | pointer to a RNG_HandleTypeDef structure. |
| random32bit | pointer to generated random number variable if successful. |
- Return values
-
Definition at line 552 of file stm32l4xx_hal_rng.c.
554 uint32_t tickstart = 0;
555 HAL_StatusTypeDef status =
HAL_OK;
570 while(__HAL_RNG_GET_FLAG(hrng, RNG_FLAG_DRDY) == RESET)
572 if((
HAL_GetTick() - tickstart ) > RNG_TIMEOUT_VALUE)
__IO HAL_RNG_StateTypeDef State
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
◆ HAL_RNG_GenerateRandomNumber_IT()
Generate a 32-bit random number in interrupt mode.
- Parameters
-
| hrng | pointer to a RNG_HandleTypeDef structure. |
- Return values
-
Definition at line 605 of file stm32l4xx_hal_rng.c.
607 HAL_StatusTypeDef status =
HAL_OK;
622 __HAL_RNG_ENABLE_IT(hrng);
__IO HAL_RNG_StateTypeDef State
◆ HAL_RNG_GetRandomNumber()
Return generated random number in polling mode (Obsolete).
- Note
- Use HAL_RNG_GenerateRandomNumber() API instead.
- Parameters
-
| hrng | pointer to a RNG_HandleTypeDef structure that contains the configuration information for RNG. |
- Return values
-
Definition at line 707 of file stm32l4xx_hal_rng.c.
HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber(RNG_HandleTypeDef *hrng, uint32_t *random32bit)
Generate a 32-bit random number.
◆ HAL_RNG_GetRandomNumber_IT()
Return a 32-bit random number with interrupt enabled (Obsolete).
- Note
- Use HAL_RNG_GenerateRandomNumber_IT() API instead.
- Parameters
-
- Return values
-
Definition at line 726 of file stm32l4xx_hal_rng.c.
728 uint32_t random32bit = 0;
740 __HAL_RNG_ENABLE_IT(hrng);
__IO HAL_RNG_StateTypeDef State
◆ HAL_RNG_IRQHandler()
Handle RNG interrupt request.
- Note
- In the case of a clock error, the RNG is no more able to generate random numbers because the PLL48CLK clock is not correct. User has to check that the clock controller is correctly configured to provide the RNG clock and clear the CEIS bit using __HAL_RNG_CLEAR_IT(). The clock error has no impact on the previously generated random numbers, and the RNG_DR register contents can be used.
-
In the case of a seed error, the generation of random numbers is interrupted as long as the SECS bit is '1'. If a number is available in the RNG_DR register, it must not be used because it may not have enough entropy. In this case, it is recommended to clear the SEIS bit using __HAL_RNG_CLEAR_IT(), then disable and enable the RNG peripheral to reinitialize and restart the RNG.
-
RNG ErrorCallback() API is called once whether SEIS or CEIS are set.
- Parameters
-
| hrng | pointer to a RNG_HandleTypeDef structure. |
- Return values
-
Definition at line 654 of file stm32l4xx_hal_rng.c.
657 if((__HAL_RNG_GET_IT(hrng, RNG_IT_CEI) != RESET) || (__HAL_RNG_GET_IT(hrng, RNG_IT_SEI) != RESET))
662 #if (USE_HAL_RNG_REGISTER_CALLBACKS == 1) 671 __HAL_RNG_CLEAR_IT(hrng, RNG_IT_CEI|RNG_IT_SEI);
676 if(__HAL_RNG_GET_IT(hrng, RNG_IT_DRDY) != RESET)
679 __HAL_RNG_DISABLE_IT(hrng);
689 #if (USE_HAL_RNG_REGISTER_CALLBACKS == 1) void(* ErrorCallback)(struct __RNG_HandleTypeDef *hrng)
void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef *hrng, uint32_t random32bit)
Data Ready callback in non-blocking mode.
void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng)
RNG error callback.
__IO HAL_RNG_StateTypeDef State
void(* ReadyDataCallback)(struct __RNG_HandleTypeDef *hrng, uint32_t random32bit)
◆ HAL_RNG_ReadLastRandomNumber()
Read latest generated random number.
- Parameters
-
| hrng | pointer to a RNG_HandleTypeDef structure. |
- Return values
-
Definition at line 753 of file stm32l4xx_hal_rng.c.
◆ HAL_RNG_ReadyDataCallback()
| __weak void HAL_RNG_ReadyDataCallback |
( |
RNG_HandleTypeDef * |
hrng, |
|
|
uint32_t |
random32bit |
|
) |
| |
Data Ready callback in non-blocking mode.
- Parameters
-
| hrng | pointer to a RNG_HandleTypeDef structure. |
| random32bit | generated random value |
- Return values
-
Definition at line 764 of file stm32l4xx_hal_rng.c.