diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-05-28 16:15:15 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-05-28 16:15:15 +0200 |
commit | d2e75eee1d017a7632faf017f40780a5255897f5 (patch) | |
tree | 0bca544eb7ec4a8da4da6c3ed6faaf0d02411bca /rcc.cpp | |
parent | 422a7785c423d64b97f9ae06baf19921a859e380 (diff) |
Started rewrite from scratch.
Diffstat (limited to 'rcc.cpp')
-rw-r--r-- | rcc.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ +#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; +} |