summaryrefslogtreecommitdiff
path: root/rcc/flash.cpp
blob: 988764f2d7f8ab884e6ecb15a39d5efbfd0e4467 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "flash.h"

/**
 * Configure the flash for maximum speed access.
 */
void flash_init() {
	#if defined(STM32F1) || defined(STM32F3)
	
	// Set flash latency.
	FLASH->ACR = 0x12;
	
	#elif defined(STM32F4)
	
	// Set flash latency.
	FLASH->ACR = 0x107;
	
	while(FLASH->ACR != 0x107);
	
	#elif defined(STM32F0) || defined(STM32L0)
	
	// SET flash latency.
	FLASH->ACR = 1 << 0;
	
	#elif defined(STM32WB)
	// Prefetch and both caches, plus 3WS for 64MHz
	FLASH->ACR = 0x700 | 3;
	
	#endif
}