blob: 79bbc696137fd3bf7e3b0cbfaf8c1d9a6f33ee7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
}
|