summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2020-08-12 15:33:26 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2020-08-12 15:33:26 +0200
commit531e1e0e57be542a63b6793611d33ca89a9ecab9 (patch)
treeebd030c30a2572909ee1cff1d4b4ab7b15829594
parent7b962b22a1702f0aeaf0b5cdb794d18e441a8b0f (diff)
stm32f446re: configurable clock speed
-rw-r--r--src/arch/stm32f446re-nucleo/Makefile.inc6
-rw-r--r--src/arch/stm32f446re-nucleo/arch.cc11
2 files changed, 16 insertions, 1 deletions
diff --git a/src/arch/stm32f446re-nucleo/Makefile.inc b/src/arch/stm32f446re-nucleo/Makefile.inc
index 8dfaecd..31d6015 100644
--- a/src/arch/stm32f446re-nucleo/Makefile.inc
+++ b/src/arch/stm32f446re-nucleo/Makefile.inc
@@ -55,6 +55,12 @@ ifneq ($(findstring counter,${arch_drivers}), )
CXX_TARGETS += src/arch/stm32f446re-nucleo/driver/counter.cc
endif
+ifneq (${cpu_freq}, )
+ COMMON_FLAGS += -DF_CPU=${cpu_freq}UL
+else
+ COMMON_FLAGS += -DF_CPU=168000000UL
+endif
+
OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o} ${ASM_TARGETS:.S=.o}
diff --git a/src/arch/stm32f446re-nucleo/arch.cc b/src/arch/stm32f446re-nucleo/arch.cc
index c0e2710..99e3e5f 100644
--- a/src/arch/stm32f446re-nucleo/arch.cc
+++ b/src/arch/stm32f446re-nucleo/arch.cc
@@ -10,8 +10,17 @@
void Arch::setup(void)
{
- // NUCLEO-F443RE uses 8MHz STLINK clock as input
+ // NUCLEO-F443RE uses 8MHz STLINK clock (MCO from STLINK MCU) as input
+ // (it is connected to OSC_IN -> HSE OSC)
+#if F_CPU == 180000000UL
+ rcc_clock_setup_pll(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_180MHZ]);
+#elif F_CPU == 168000000UL
rcc_clock_setup_pll(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_168MHZ]);
+#elif F_CPU == 84000000UL
+ rcc_clock_setup_pll(&rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_84MHZ]);
+#else
+#error Unsupported F_CPU
+#endif
// counter
rcc_periph_clock_enable(RCC_TIM2);