Class library for using the true Random Number Generator on STM32F4xxx devices.
Dependents: MCU-Benchmark-Sute Doom_Flame-F429ZI_v02 Wether_Meter
STM32F4_RNG.cpp
- Committer:
- grantphillips
- Date:
- 2016-02-08
- Revision:
- 0:1c605984e361
File content as of revision 0:1c605984e361:
#include "STM32F4_RNG.h" #include "mbed.h" STM32F4_RNG::STM32F4_RNG() { RCC->AHB2ENR |= RCC_AHB2ENR_RNGEN; /* Enable RNG clock source */ RNG->CR |= RNG_CR_RNGEN; /* RNG Peripheral enable */ } unsigned long STM32F4_RNG::Get() { while (!(RNG->SR & (RNG_SR_DRDY))); /* Wait until one RNG number is ready */ return RNG->DR; /* Get a 32-bit Random number */ }