diff --git a/lib/stm32/common/rng_common_v1.c b/lib/stm32/common/rng_common_v1.c index d9955c20..bffb0c27 100644 --- a/lib/stm32/common/rng_common_v1.c +++ b/lib/stm32/common/rng_common_v1.c @@ -67,13 +67,13 @@ void rng_interrupt_disable(void) */ bool rng_get_random(uint32_t *rand_nr) { - /* data ready */ - if (!(RNG_SR & RNG_SR_DRDY)) { + /* Check for errors */ + if (RNG_SR & (RNG_SR_CECS | RNG_SR_SECS)) { return false; } - /* Check for errors */ - if (RNG_SR & (RNG_SR_CECS | RNG_SR_SECS)) { + /* data ready */ + if (!(RNG_SR & RNG_SR_DRDY)) { return false; }