aboutsummaryrefslogtreecommitdiff
path: root/lib/rcc.c
diff options
context:
space:
mode:
authorUwe Hermann2009-07-22 03:25:14 +0200
committerUwe Hermann2009-07-22 03:25:14 +0200
commit9fd3064cb298124517f2ed1517365175e2c0e6be (patch)
tree7da85fbf53847dc790eb99a3c8b39c9f2125a542 /lib/rcc.c
parent0f0ef60378c3e25a4db0628bb3686e63c10c120c (diff)
Add more RCC related API functions and their prototypes.
This includes: - rcc_set_sysclk_source() - rcc_set_pll_multiplication_factor() - rcc_set_pll_source() - rcc_set_pllxtpre()
Diffstat (limited to 'lib/rcc.c')
-rw-r--r--lib/rcc.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/rcc.c b/lib/rcc.c
index 30ad802..390c795 100644
--- a/lib/rcc.c
+++ b/lib/rcc.c
@@ -234,3 +234,38 @@ void rcc_disable_peripheral_clock(volatile u32 *reg, u32 peripheral_en)
*reg &= ~peripheral_en;
}
+void rcc_set_sysclk_source(u32 clk)
+{
+ u32 reg32;
+
+ reg32 = RCC_CFGR;
+ reg32 &= ~((1 << 1) | (1 << 0));
+ RCC_CFGR = (reg32 | clk);
+}
+
+void rcc_set_pll_multiplication_factor(u32 mul)
+{
+ u32 reg32;
+
+ reg32 = RCC_CFGR;
+ reg32 &= ~((1 << 21) | (1 << 20) | (1 << 19) | (1 << 18));
+ RCC_CFGR = (reg32 | (mul << 18));
+}
+
+void rcc_set_pll_source(u32 pllsrc)
+{
+ u32 reg32;
+
+ reg32 = RCC_CFGR;
+ reg32 &= ~(1 << 16);
+ RCC_CFGR = (reg32 | (pllsrc << 16));
+}
+
+void rcc_set_pllxtpre(u32 pllxtpre)
+{
+ u32 reg32;
+
+ reg32 = RCC_CFGR;
+ reg32 &= ~(1 << 17);
+ RCC_CFGR = (reg32 | (pllxtpre << 17));
+}