Merge pull request #9035 from jeromecoutant/PR_L4TRNG

STM32L4: correct RNG clock source
pull/9073/head
Martin Kojtal 2018-12-12 14:45:40 +01:00 committed by GitHub
commit 7cd01266a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();