summaryrefslogtreecommitdiff
path: root/rcc
diff options
context:
space:
mode:
Diffstat (limited to 'rcc')
-rw-r--r--rcc/crs.h2
-rw-r--r--rcc/flash.cpp2
-rw-r--r--rcc/flash.h4
-rw-r--r--rcc/rcc.cpp10
4 files changed, 14 insertions, 4 deletions
diff --git a/rcc/crs.h b/rcc/crs.h
index 8c1cf68..758aa12 100644
--- a/rcc/crs.h
+++ b/rcc/crs.h
@@ -21,7 +21,7 @@ class CRS_t {
}
};
-#if defined(STM32L0)
+#if defined(STM32F0) || defined(STM32L0)
static CRS_t CRS(0x40006c00);
#endif
diff --git a/rcc/flash.cpp b/rcc/flash.cpp
index 6469b1c..c20b618 100644
--- a/rcc/flash.cpp
+++ b/rcc/flash.cpp
@@ -13,7 +13,7 @@ void flash_init() {
while(FLASH.ACR != 0x105);
- #elif defined(STM32L0)
+ #elif defined(STM32F0) || defined(STM32L0)
// SET flash latency.
FLASH.ACR = 1 << 0;
diff --git a/rcc/flash.h b/rcc/flash.h
index c1f7c1c..789c090 100644
--- a/rcc/flash.h
+++ b/rcc/flash.h
@@ -4,7 +4,7 @@
#include <stdint.h>
struct FLASH_t {
- #if defined(STM32F1) || defined(STM32F3)
+ #if defined(STM32F0) || defined(STM32F1) || defined(STM32F3)
volatile uint32_t ACR;
volatile uint32_t KEYR;
volatile uint32_t OPTKEYR;
@@ -34,7 +34,7 @@ struct FLASH_t {
#endif
};
-#if defined(STM32F1) || defined(STM32F3)
+#if defined(STM32F0) || defined(STM32F1) || defined(STM32F3)
static FLASH_t& FLASH = *(FLASH_t*)0x40022000;
#elif defined(STM32F4)
static FLASH_t& FLASH = *(FLASH_t*)0x40023c00;
diff --git a/rcc/rcc.cpp b/rcc/rcc.cpp
index aa9147a..65faf33 100644
--- a/rcc/rcc.cpp
+++ b/rcc/rcc.cpp
@@ -48,6 +48,16 @@ void rcc_init() {
// Set APB2 prescaler to /2.
RCC.CFGR |= 4 << 13;
+ #elif defined(STM32F0)
+
+ // Enable HSI48.
+ RCC.CR2 |= 1 << 16; // HSI48ON
+ while(!(RCC.CR2 & (1 << 17))); // HSI48RDY
+
+ // Switch to HSI48.
+ RCC.CFGR |= 3 << 0; // SW = HSI48
+ while((RCC.CFGR & (3 << 2)) != (3 << 2)); // SWS = HSI48
+
#elif defined(STM32L0)
// Enable HSI16.