Module stm32f4xx_hal::rng
source · [−]Expand description
Hardware random number generator.
The build in random number generator (RNG) of an STM32F4 uses analog noise to provide random 32-bit values.
Notes:
- It takes 40 periods of
RNG_CLK
to generate a new random value. - The RNG requires the
PLL48_CLK
to be active (more details)
For more details, see reference manual chapter 24.
Minimal working example:
let dp = pac::Peripherals::take().unwrap();
let rcc = dp.RCC.constrain();
let clocks = rcc.cfgr.require_pll48clk().freeze();
let mut rand_source = dp.RNG.constrain(clocks);
let rand_val = rand_source.next_u32();
A full exaple can be found in the examples folder on github
Structs
Random number provider which provides access to all rand_core::RngCore functions.
Enums
Random number generator specific errors
Traits
Helper trait to implement the constrain
method for the
RNG peripheral which is how the Rng struct is
created.