aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/stm32f4.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-10-24 11:35:18 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-10-24 11:35:18 -0400
commit9a11286327b877971367676616347ba767e96ba1 (patch)
tree9011b0d9768e60b7f90e1504f780b18182ee9742 /src/stm32/stm32f4.c
parentfaeaa54925e0a6fa197c48faf6317a86824f64d7 (diff)
downloadkutter-9a11286327b877971367676616347ba767e96ba1.tar.gz
kutter-9a11286327b877971367676616347ba767e96ba1.tar.xz
kutter-9a11286327b877971367676616347ba767e96ba1.zip
stm32: Implement armcm_main() in arch specific code
Move armcm_main() to stm32f0.c, stm32f1.c, and stm32f4.c. This gives the arch specific code more control on the early boot setup. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/stm32f4.c')
-rw-r--r--src/stm32/stm32f4.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/stm32/stm32f4.c b/src/stm32/stm32f4.c
index 6dfa2f68..e1f22b2f 100644
--- a/src/stm32/stm32f4.c
+++ b/src/stm32/stm32f4.c
@@ -9,6 +9,7 @@
#include "board/usb_cdc.h" // usb_request_bootloader
#include "command.h" // DECL_CONSTANT_STR
#include "internal.h" // enable_pclock
+#include "sched.h" // sched_main
#define FREQ_PERIPH (CONFIG_CLOCK_FREQ / 4)
@@ -174,12 +175,9 @@ enable_clock_stm32f446(void)
}
// Main clock setup called at chip startup
-void
+static void
clock_setup(void)
{
- // The SystemInit() code alters VTOR - restore it
- SCB->VTOR = (uint32_t)VectorTable;
-
// Configure and enable PLL
if (CONFIG_MACH_STM32F405 || CONFIG_MACH_STM32F407)
enable_clock_stm32f40x();
@@ -199,3 +197,16 @@ clock_setup(void)
while ((RCC->CFGR & RCC_CFGR_SWS_Msk) != RCC_CFGR_SWS_PLL)
;
}
+
+// Main entry point - called from armcm_boot.c:ResetHandler()
+void
+armcm_main(void)
+{
+ // Run SystemInit() and then restore VTOR
+ SystemInit();
+ SCB->VTOR = (uint32_t)VectorTable;
+
+ clock_setup();
+
+ sched_main();
+}