2017-03-07 05:50:09 -08:00
|
|
|
#include STM32_HAL_H
|
|
|
|
|
|
|
|
static RNG_HandleTypeDef rng_handle = {
|
|
|
|
.Instance = RNG,
|
|
|
|
};
|
|
|
|
|
2017-03-07 06:52:19 -08:00
|
|
|
int rng_init(void) {
|
2017-03-07 05:50:09 -08:00
|
|
|
__HAL_RCC_RNG_CLK_ENABLE();
|
2017-03-07 06:52:19 -08:00
|
|
|
HAL_RNG_Init(&rng_handle);
|
|
|
|
return 0;
|
2017-03-07 05:50:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t rng_get(void) {
|
|
|
|
return HAL_RNG_GetRandomNumber(&rng_handle);
|
|
|
|
}
|