1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-29 19:08:12 +00:00
trezor-firmware/micropython/trezorhal/rng.c

16 lines
264 B
C
Raw Normal View History

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