aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-03-26 15:21:25 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-04-11 16:56:55 -0400
commit6632789976b804889494dc1e7aea51181d4ca754 (patch)
treee715e819604bdb5a1dd32b673b08abcd7cbc5e85 /libmaple
parent382da37cda44204331d57939c596d768cbd0e188 (diff)
downloadlibrambutan-6632789976b804889494dc1e7aea51181d4ca754.tar.gz
librambutan-6632789976b804889494dc1e7aea51181d4ca754.zip
rcc_reconfigure_pll(): Assert that the PLL is disabled.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple')
-rw-r--r--libmaple/stm32f1/rcc.c3
-rw-r--r--libmaple/stm32f2/rcc.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/libmaple/stm32f1/rcc.c b/libmaple/stm32f1/rcc.c
index a9c9c3a..0752b82 100644
--- a/libmaple/stm32f1/rcc.c
+++ b/libmaple/stm32f1/rcc.c
@@ -139,6 +139,9 @@ void rcc_configure_pll(rcc_pll_cfg *pll_cfg) {
rcc_pll_multiplier pll_mul = data->pll_mul;
uint32 cfgr;
+ /* Check that the PLL is disabled. */
+ ASSERT_FAULT(!rcc_is_clk_on(RCC_CLK_PLL));
+
cfgr = RCC_BASE->CFGR;
cfgr &= ~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL);
cfgr |= pll_cfg->pllsrc | pll_mul;
diff --git a/libmaple/stm32f2/rcc.c b/libmaple/stm32f2/rcc.c
index b94f2e6..46e6565 100644
--- a/libmaple/stm32f2/rcc.c
+++ b/libmaple/stm32f2/rcc.c
@@ -173,6 +173,9 @@ void rcc_configure_pll(rcc_pll_cfg *pll_cfg) {
stm32f2_rcc_pll_data *data = pll_cfg->data;
uint32 pllcfgr;
+ /* Check that the PLL is disabled. */
+ ASSERT_FAULT(!rcc_is_clk_on(RCC_CLK_PLL));
+
/* Sanity-check all the parameters */
ASSERT_FAULT((data->pllq >= 4) && (data->pllq <= 15));
ASSERT_FAULT((data->pllp >= 2) && (data->pllp <= 8));