STM32L4: correct RNG clock source

pull/9035/head
jeromecoutant 2018-12-10 14:04:25 +01:00
parent 9d28c3f767
commit 503777d850
1 changed files with 15 additions and 0 deletions

View File

@ -37,6 +37,21 @@ void trng_init(trng_t *obj)
error("Only 1 RNG instance supported\r\n");
}
#if defined(RCC_PERIPHCLK_RNG)
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
/*Select PLLQ output as RNG clock source */
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RNG;
#if ((CLOCK_SOURCE) & USE_PLL_MSI)
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_MSI;
#else
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_PLL;
#endif
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
error("RNG clock configuration error\n");
}
#endif
/* RNG Peripheral clock enable */
__HAL_RCC_RNG_CLK_ENABLE();