Functions
Peripheral Control functions
Peripheral Driver » HAL Driver » RNG » Functions

Peripheral Control functions. More...

Collaboration diagram for Peripheral Control functions:

## Functions
hal_status_t | hal_rng_generate_random_number (rng_handle_t *p_rng, uint16_t *p_seed, uint32_t *p_random32bit)
| Generate a 32-bit random number. More...
hal_status_t | hal_rng_generate_random_number_it (rng_handle_t *p_rng, uint16_t *p_seed)
| Generate a 32-bit random number in interrupt mode. More...
uint32_t | hal_rng_read_last_random_number (rng_handle_t *p_rng)
| Read the latest generated random number. More...

## Detailed Description

Peripheral Control functions.

      ==============================================================================
                          ##### Peripheral Control functions #####
      ==============================================================================
      [..]
        This section provides functions allowing to:
        (+) Generate Random Number.
        (+) Handle RNG interrupt request and associated function callback.

## Function Documentation

## ◆ hal_rng_generate_random_number()

hal_status_t hal_rng_generate_random_number | ( | rng_handle_t * | p_rng,
|  | uint16_t * | p_seed,
|  | uint32_t * | p_random32bit
| ) |  |

Generate a 32-bit random number.

Parameters

  [in] | p_rng | Pointer to a RNG handle which contains the configuration information for the specified RNG module.
  [in] | p_seed | user configured seeds. the seed is valid when seed_mode member of rng_init_t is configured as RNG_SEED_USER. If 59-bit random number is selected, the seed need to provide [0~58] bit spaces. If 128-bit random number is selected, the seed need to provide [0~127] bit spaces.
  [out] | p_random32bit | Pointer to generated random number variable if successful.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_rng_generate_random_number_it()

hal_status_t hal_rng_generate_random_number_it | ( | rng_handle_t * | p_rng,
|  | uint16_t * | p_seed
| ) |  |

Generate a 32-bit random number in interrupt mode.

Parameters

  [in] | p_rng | Pointer to a RNG handle which contains the configuration information for the specified RNG module.
  [in] | p_seed | user configured seeds. the seed is valid when seed_mode member of rng_init_t is configured as RNG_SEED_USER. If 59-bit random number is selected, the seed need to provide [0~58] bit spaces. If 128-bit random number is selected, the seed need to provide [0~127] bit spaces.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_rng_read_last_random_number()

uint32_t hal_rng_read_last_random_number | ( | rng_handle_t * | p_rng | ) |

Read the latest generated random number.

Parameters

  [in] | p_rng | Pointer to a RNG handle which contains the configuration information for the specified RNG module.

Return values

  random | value.