From cfb9c991cb025445091bfc0bb9ef23d15cc0a4b2 Mon Sep 17 00:00:00 2001 From: Nikolay Marchuk Date: Sun, 6 Oct 2024 22:56:35 +0700 Subject: [PATCH] furi_hal_random: Wait for ready state and no errors before sampling (#3933) When random output is not ready, but error state flags are not set, sampling of random generator samples zero until next value is ready. --- targets/f7/furi_hal/furi_hal_random.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/f7/furi_hal/furi_hal_random.c b/targets/f7/furi_hal/furi_hal_random.c index 8b75a05c5b4..6269a90e1b8 100644 --- a/targets/f7/furi_hal/furi_hal_random.c +++ b/targets/f7/furi_hal/furi_hal_random.c @@ -11,7 +11,7 @@ #define TAG "FuriHalRandom" static uint32_t furi_hal_random_read_rng(void) { - while(LL_RNG_IsActiveFlag_CECS(RNG) && LL_RNG_IsActiveFlag_SECS(RNG) && + while(LL_RNG_IsActiveFlag_CECS(RNG) || LL_RNG_IsActiveFlag_SECS(RNG) || !LL_RNG_IsActiveFlag_DRDY(RNG)) { /* Error handling as described in RM0434, pg. 582-583 */ if(LL_RNG_IsActiveFlag_CECS(RNG)) {