summaryrefslogtreecommitdiff
path: root/hal/rcc.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-11-19 17:21:31 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-11-19 19:23:33 +0100
commit025a38a1f743fd9e89cbd477abe3f79a8d098097 (patch)
treea1f20c1b6a7f6c418bee641da923ab3d0d7208fe /hal/rcc.cpp
parent9e5875f2908c1ce506e7c5712ccabc379f911360 (diff)
Moved os and hal related files into subdirectories.
Diffstat (limited to 'hal/rcc.cpp')
-rw-r--r--hal/rcc.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/hal/rcc.cpp b/hal/rcc.cpp
new file mode 100644
index 0000000..e3ae38d
--- /dev/null
+++ b/hal/rcc.cpp
@@ -0,0 +1,26 @@
+#include "rcc.h"
+#include "stm32.h"
+
+void rcc_init() {
+ // Set flash latency.
+ FLASH.ACR = 0x12;
+
+ // Enable HSE.
+ RCC.CR |= 0x10000;
+ while(RCC.CR & 0x20000);
+
+ // Configure and enable PLL.
+ RCC.CFGR = 0x1d0000;
+ RCC.CR |= 0x1000000;
+ while(RCC.CR & 0x2000000);
+
+ // Switch to PLL.
+ RCC.CFGR |= 0x2;
+ while(!(RCC.CFGR & 0x8));
+
+ // Set APB1 prescaler to /2.
+ RCC.CFGR |= 0x400;
+
+ // Set ADCCLK prescaler to /6.
+ RCC.CFGR |= 0x8000;
+}