From 7b29caed1a726b5cef4c269b6a6ef7a1f1dd105c Mon Sep 17 00:00:00 2001 From: FrancoisFinfe Date: Sat, 21 Jun 2014 20:17:12 +0200 Subject: [PATCH] stm32l1:rcc: allow pll source to be HSE. The existing rcc_clock_setup_pll only allowed HSI as the clock source, even though the existing clock structure contains pll source variables. Check this value, and switch to the corresponding clock source, rather than blindly assuming that we are tryign to operate from HSI. --- lib/stm32/l1/rcc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/stm32/l1/rcc.c b/lib/stm32/l1/rcc.c index 0bf0fa35..7a7d8ccb 100644 --- a/lib/stm32/l1/rcc.c +++ b/lib/stm32/l1/rcc.c @@ -498,9 +498,14 @@ void rcc_clock_setup_hsi(const clock_scale_t *clock) void rcc_clock_setup_pll(const clock_scale_t *clock) { - /* Enable internal high-speed oscillator. */ - rcc_osc_on(HSI); - rcc_wait_for_osc_ready(HSI); + /* Turn on the appropriate source for the PLL */ + if (clock->pll_source == RCC_CFGR_PLLSRC_HSE_CLK) { + rcc_osc_on(HSE); + rcc_wait_for_osc_ready(HSE); + } else { + rcc_osc_on(HSI); + rcc_wait_for_osc_ready(HSI); + } /* * Set prescalers for AHB, ADC, ABP1, ABP2.