Skip to content

Commit 503777d

Browse files
committed
STM32L4: correct RNG clock source
1 parent 9d28c3f commit 503777d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

targets/TARGET_STM/trng_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ void trng_init(trng_t *obj)
3737
error("Only 1 RNG instance supported\r\n");
3838
}
3939

40+
#if defined(RCC_PERIPHCLK_RNG)
41+
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
42+
43+
/*Select PLLQ output as RNG clock source */
44+
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RNG;
45+
#if ((CLOCK_SOURCE) & USE_PLL_MSI)
46+
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_MSI;
47+
#else
48+
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_PLL;
49+
#endif
50+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
51+
error("RNG clock configuration error\n");
52+
}
53+
#endif
54+
4055
/* RNG Peripheral clock enable */
4156
__HAL_RCC_RNG_CLK_ENABLE();
4257

0 commit comments

Comments
 (0)