STM32F439xx HAL User Manual
Functions
Peripheral Control functions
RNG Exported Functions

Peripheral Control functions. More...

Functions

HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber (RNG_HandleTypeDef *hrng, uint32_t *random32bit)
 Generates a 32-bit random number.
HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT (RNG_HandleTypeDef *hrng)
 Generates a 32-bit random number in interrupt mode.
void HAL_RNG_IRQHandler (RNG_HandleTypeDef *hrng)
 Handles RNG interrupt request.
uint32_t HAL_RNG_GetRandomNumber (RNG_HandleTypeDef *hrng)
 Returns generated random number in polling mode (Obsolete) Use HAL_RNG_GenerateRandomNumber() API instead.
uint32_t HAL_RNG_GetRandomNumber_IT (RNG_HandleTypeDef *hrng)
 Returns a 32-bit random number with interrupt enabled (Obsolete), Use HAL_RNG_GenerateRandomNumber_IT() API instead.
uint32_t HAL_RNG_ReadLastRandomNumber (RNG_HandleTypeDef *hrng)
 Read latest generated random number.
__weak void HAL_RNG_ReadyDataCallback (RNG_HandleTypeDef *hrng, uint32_t random32bit)
 Data Ready callback in non-blocking mode.
__weak void HAL_RNG_ErrorCallback (RNG_HandleTypeDef *hrng)
 RNG error callbacks.

Detailed Description

Peripheral Control 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 


Function Documentation

RNG error callbacks.

Parameters:
hrngpointer to a RNG_HandleTypeDef structure that contains the configuration information for RNG.
Return values:
None

Definition at line 462 of file stm32f4xx_hal_rng.c.

Referenced by HAL_RNG_IRQHandler().

HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber ( RNG_HandleTypeDef hrng,
uint32_t *  random32bit 
)

Generates a 32-bit random number.

Note:
Each time the random number data is read the RNG_FLAG_DRDY flag is automatically cleared.
Parameters:
hrngpointer to a RNG_HandleTypeDef structure that contains the configuration information for RNG.
random32bitpointer to generated random number variable if successful.
Return values:
HALstatus

Definition at line 242 of file stm32f4xx_hal_rng.c.

References __HAL_RNG_GET_FLAG, HAL_GetTick(), HAL_RNG_STATE_BUSY, HAL_RNG_STATE_ERROR, HAL_RNG_STATE_READY, RNG_HandleTypeDef::Instance, RNG_HandleTypeDef::RandomNumber, RNG_FLAG_DRDY, RNG_TIMEOUT_VALUE, and RNG_HandleTypeDef::State.

Referenced by HAL_RNG_GetRandomNumber().

HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT ( RNG_HandleTypeDef hrng)

Generates a 32-bit random number in interrupt mode.

Parameters:
hrngpointer to a RNG_HandleTypeDef structure that contains the configuration information for RNG.
Return values:
HALstatus

Definition at line 296 of file stm32f4xx_hal_rng.c.

References __HAL_RNG_ENABLE_IT, HAL_RNG_STATE_BUSY, HAL_RNG_STATE_READY, and RNG_HandleTypeDef::State.

Returns generated random number in polling mode (Obsolete) Use HAL_RNG_GenerateRandomNumber() API instead.

Parameters:
hrngpointer to a RNG_HandleTypeDef structure that contains the configuration information for RNG.
Return values:
Randomvalue

Definition at line 389 of file stm32f4xx_hal_rng.c.

References HAL_RNG_GenerateRandomNumber(), and RNG_HandleTypeDef::RandomNumber.

Returns a 32-bit random number with interrupt enabled (Obsolete), Use HAL_RNG_GenerateRandomNumber_IT() API instead.

Parameters:
hrngpointer to a RNG_HandleTypeDef structure that contains the configuration information for RNG.
Return values:
32-bitrandom number

Definition at line 408 of file stm32f4xx_hal_rng.c.

References __HAL_RNG_ENABLE_IT, HAL_RNG_STATE_BUSY, RNG_HandleTypeDef::Instance, and RNG_HandleTypeDef::State.

Handles 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.
User-written HAL_RNG_ErrorCallback() API is called once whether SEIS or CEIS are set.
Parameters:
hrngpointer to a RNG_HandleTypeDef structure that contains the configuration information for RNG.
Return values:
None

Definition at line 347 of file stm32f4xx_hal_rng.c.

References __HAL_RNG_CLEAR_IT, __HAL_RNG_DISABLE_IT, __HAL_RNG_GET_IT, HAL_RNG_ErrorCallback(), HAL_RNG_ReadyDataCallback(), HAL_RNG_STATE_ERROR, HAL_RNG_STATE_READY, RNG_HandleTypeDef::Instance, RNG_HandleTypeDef::RandomNumber, RNG_IT_CEI, RNG_IT_DRDY, RNG_IT_SEI, and RNG_HandleTypeDef::State.

Read latest generated random number.

Parameters:
hrngpointer to a RNG_HandleTypeDef structure that contains the configuration information for RNG.
Return values:
randomvalue

Definition at line 434 of file stm32f4xx_hal_rng.c.

References RNG_HandleTypeDef::RandomNumber.

void HAL_RNG_ReadyDataCallback ( RNG_HandleTypeDef hrng,
uint32_t  random32bit 
)

Data Ready callback in non-blocking mode.

Parameters:
hrngpointer to a RNG_HandleTypeDef structure that contains the configuration information for RNG.
random32bitgenerated random number.
Return values:
None

Definition at line 446 of file stm32f4xx_hal_rng.c.

Referenced by HAL_RNG_IRQHandler().