stm32: Move VTOR fixup from main() to chip specific code

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-09-18 10:49:23 -04:00
parent 8cb3d09484
commit 80e17b1e53
3 changed files with 10 additions and 3 deletions

View File

@ -5,7 +5,6 @@
// This file may be distributed under the terms of the GNU GPLv3 license. // This file may be distributed under the terms of the GNU GPLv3 license.
#include "autoconf.h" // CONFIG_MCU #include "autoconf.h" // CONFIG_MCU
#include "board/armcm_boot.h" // VectorTable
#include "command.h" // DECL_CONSTANT_STR #include "command.h" // DECL_CONSTANT_STR
#include "internal.h" // clock_setup #include "internal.h" // clock_setup
#include "sched.h" // sched_main #include "sched.h" // sched_main
@ -23,8 +22,6 @@ DECL_COMMAND_FLAGS(command_reset, HF_IN_SHUTDOWN, "reset");
int int
main(void) main(void)
{ {
SCB->VTOR = (uint32_t)VectorTable;
clock_setup(); clock_setup();
sched_main(); sched_main();

View File

@ -5,6 +5,7 @@
// This file may be distributed under the terms of the GNU GPLv3 license. // This file may be distributed under the terms of the GNU GPLv3 license.
#include "autoconf.h" // CONFIG_CLOCK_REF_8M #include "autoconf.h" // CONFIG_CLOCK_REF_8M
#include "board/armcm_boot.h" // VectorTable
#include "board/irq.h" // irq_disable #include "board/irq.h" // irq_disable
#include "board/usb_cdc.h" // usb_request_bootloader #include "board/usb_cdc.h" // usb_request_bootloader
#include "internal.h" // enable_pclock #include "internal.h" // enable_pclock
@ -125,6 +126,10 @@ usb_request_bootloader(void)
void void
clock_setup(void) clock_setup(void)
{ {
// The SystemInit() code alters VTOR - restore it
SCB->VTOR = (uint32_t)VectorTable;
// Configure and enable PLL
uint32_t cfgr; uint32_t cfgr;
if (CONFIG_CLOCK_REF_8M) { if (CONFIG_CLOCK_REF_8M) {
// Configure 72Mhz PLL from external 8Mhz crystal (HSE) // Configure 72Mhz PLL from external 8Mhz crystal (HSE)

View File

@ -5,6 +5,7 @@
// This file may be distributed under the terms of the GNU GPLv3 license. // This file may be distributed under the terms of the GNU GPLv3 license.
#include "autoconf.h" // CONFIG_CLOCK_REF_8M #include "autoconf.h" // CONFIG_CLOCK_REF_8M
#include "board/armcm_boot.h" // VectorTable
#include "board/usb_cdc.h" // usb_request_bootloader #include "board/usb_cdc.h" // usb_request_bootloader
#include "command.h" // DECL_CONSTANT_STR #include "command.h" // DECL_CONSTANT_STR
#include "internal.h" // enable_pclock #include "internal.h" // enable_pclock
@ -176,6 +177,10 @@ enable_clock_stm32f446(void)
void void
clock_setup(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) if (CONFIG_MACH_STM32F405 || CONFIG_MACH_STM32F407)
enable_clock_stm32f40x(); enable_clock_stm32f40x();
else else