Skip to content

Commit

Permalink
platform/primehub: revert interrupt change
Browse files Browse the repository at this point in the history
This partially reverts commit b094823
to make dual boot work again.
  • Loading branch information
laurensvalk committed Jan 19, 2021
1 parent 23eb030 commit 463c9e9
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/pbio/platform/prime_hub/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,19 +689,14 @@ extern uint32_t *_fw_isr_vector_src;

// Called from assembly code in startup.s
void SystemInit(void) {
// enable 8-byte stack alignment for IRQ handlers, in accord with EABI
SCB->CCR |= SCB_CCR_STKALIGN_Msk;

// since the firmware starts at 0x08008000, we need to set the vector table offset
SCB->VTOR = (uint32_t)&_fw_isr_vector_src;

// bootloader disables interrupts
__enable_irq();
RCC_OscInitTypeDef osc_init;
RCC_ClkInitTypeDef clk_init;

// Using external 16Mhz oscillator
RCC_OscInitTypeDef osc_init = { 0 };
osc_init.OscillatorType = RCC_OSCILLATORTYPE_HSE;
osc_init.HSEState = RCC_HSE_ON;
osc_init.HSIState = RCC_HSI_OFF;
osc_init.PLL.PLLState = RCC_PLL_ON;
osc_init.PLL.PLLSource = RCC_PLLSOURCE_HSE;
osc_init.PLL.PLLM = 8; // VCO_IN 2MHz (16MHz / 8)
Expand All @@ -711,7 +706,6 @@ void SystemInit(void) {

HAL_RCC_OscConfig(&osc_init);

RCC_ClkInitTypeDef clk_init = { 0 };
clk_init.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
clk_init.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
clk_init.AHBCLKDivider = RCC_SYSCLK_DIV1; // HCLK 96MHz
Expand All @@ -720,6 +714,15 @@ void SystemInit(void) {

HAL_RCC_ClockConfig(&clk_init, FLASH_LATENCY_5);

// enable 8-byte stack alignment for IRQ handlers, in accord with EABI
SCB->CCR |= SCB_CCR_STKALIGN_Msk;

// since the firmware starts at 0x08008000, we need to set the vector table offset
SCB->VTOR = (uint32_t)&_fw_isr_vector_src;

// bootloader disables interrupts
__enable_irq();

// If we are running dual boot, jump to other firmware if no buttons are pressed
pbio_platform_dual_boot();

Expand Down

0 comments on commit 463c9e9

Please sign in to comment.