From 70a6a15f8c5f8fba9b9fd9b57502e2fd815c6e73 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sat, 14 Apr 2018 00:11:07 +0200 Subject: [PATCH] stm32/rng: Set RNG clock source for STM32H7. --- ports/stm32/rng.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ports/stm32/rng.c b/ports/stm32/rng.c index 85dcc14109..e70eafae71 100644 --- a/ports/stm32/rng.c +++ b/ports/stm32/rng.c @@ -33,6 +33,11 @@ uint32_t rng_get(void) { // Enable the RNG peripheral if it's not already enabled if (!(RNG->CR & RNG_CR_RNGEN)) { + #if defined(STM32H7) + // Set RNG Clock source + __HAL_RCC_PLLCLKOUT_ENABLE(RCC_PLL1_DIVQ); + __HAL_RCC_RNG_CONFIG(RCC_RNGCLKSOURCE_PLL); + #endif __HAL_RCC_RNG_CLK_ENABLE(); RNG->CR |= RNG_CR_RNGEN; }