Skip to content

STM32L4: correct RNG clock source #9035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions targets/TARGET_STM/trng_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down