aboutsummaryrefslogtreecommitdiff
path: root/lib/stm32/l1/pwr_chipset.c
diff options
context:
space:
mode:
authorKarl Palsson2012-11-14 00:10:03 +0000
committerKarl Palsson2012-11-14 00:16:56 +0000
commitdf1808e2dca719a18067e8f4d9ef7b74fd7e84da (patch)
tree83784332285f54625fcea68434f9fdb7a4fe04cd /lib/stm32/l1/pwr_chipset.c
parent40f3ac58fb00ef4899638b6a42c4d7d1eaa643ce (diff)
[l1] Add rcc clock setup helper routines
Despite the L1 being a low power device, my initial focus is on making it basically compatible with existing devices. To that end, provide clock setup helper routines that configure it for maximum performance, allowing some similar clock speeds to F1 devices to help with testing. This requires adding the power chipset routines to set the voltage range. Clock setup style is similar to the F4 code, which seems nicer than the overflow of different routines used on the F1 code. NOTE: Both the F4 existing pwr code, and this code don't actually include the f1 core power code, even though it should be compatible
Diffstat (limited to 'lib/stm32/l1/pwr_chipset.c')
-rw-r--r--lib/stm32/l1/pwr_chipset.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/stm32/l1/pwr_chipset.c b/lib/stm32/l1/pwr_chipset.c
new file mode 100644
index 0000000..9f4f599
--- /dev/null
+++ b/lib/stm32/l1/pwr_chipset.c
@@ -0,0 +1,37 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopencm3/stm32/l1/pwr.h>
+
+void pwr_set_vos_scale(vos_scale_t scale)
+{
+ PWR_CR &= ~(PWR_CR_VOS_MASK);
+ switch (scale) {
+ case RANGE1:
+ PWR_CR |= PWR_CR_VOS_RANGE1;
+ break;
+ case RANGE2:
+ PWR_CR |= PWR_CR_VOS_RANGE2;
+ break;
+ case RANGE3:
+ PWR_CR |= PWR_CR_VOS_RANGE3;
+ break;
+ }
+}
+