aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorUwe Hermann2010-01-19 19:57:38 +0100
committerUwe Hermann2010-01-19 19:57:38 +0100
commit3e29876d98973f03ee19911b688076cd81463d70 (patch)
treea180c3ef210365a8b4e74baf3e8ad1ae8cac788c /lib
parent92dc4c361e20794a733996ca2848a1851198b182 (diff)
rcc: Add a few functions to set prescalers.
Thanks Thomas Otto <tommi@viadmin.org> for the patch!
Diffstat (limited to 'lib')
-rw-r--r--lib/rcc.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/rcc.c b/lib/rcc.c
index 58ab8b5..2392084 100644
--- a/lib/rcc.c
+++ b/lib/rcc.c
@@ -3,6 +3,8 @@
*
* Copyright (C) 2009 Federico Ruiz-Ugalde <memeruiz at gmail dot com>
* Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ *
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -279,3 +281,45 @@ void rcc_set_pllxtpre(u32 pllxtpre)
reg32 &= ~(1 << 17);
RCC_CFGR = (reg32 | (pllxtpre << 17));
}
+
+void rcc_set_adcpre(u32 adcpre)
+{
+ u32 reg32;
+
+ reg32 = RCC_CFGR;
+ reg32 &= ((1 << 14) | (1 << 15));
+ RCC_CFGR = (reg32 | (adcpre << 14));
+}
+
+void rcc_set_ppre2(u32 ppre2)
+{
+ u32 reg32;
+
+ reg32 = RCC_CFGR;
+ reg32 &= ((1 << 11) | (1 << 12) | (1 << 13));
+ RCC_CFGR = (reg32 | (ppre2 << 11));
+}
+
+void rcc_set_ppre1(u32 ppre1)
+{
+ u32 reg32;
+
+ reg32 = RCC_CFGR;
+ reg32 &= ((1 << 8) | (1 << 9) | (1 << 10));
+ RCC_CFGR = (reg32 | (ppre1 << 8));
+}
+
+void rcc_set_hpre(u32 hpre)
+{
+ u32 reg32;
+
+ reg32 = RCC_CFGR;
+ reg32 &= ((1 << 4) | (1 << 5) | (1 << 6) | (1 << 7));
+ RCC_CFGR = (reg32 | (hpre << 4));
+}
+
+u32 rcc_system_clock_source(void)
+{
+ /* Return the clock source which is used as system clock. */
+ return ((RCC_CFGR & 0x000c) >> 2);
+}