Skip to content

Commit 4c32e41

Browse files
committed
reset: clear systicks and interrupts
1 parent c22564d commit 4c32e41

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/driver/mcu/stm32/reset.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,22 @@ __attribute__((__used__)) void system_check_for_bootloader() {
4646
case RESET_BOOTLOADER_MAGIC: {
4747
backup_register_write(0);
4848

49-
#ifdef STM32G4
49+
__disable_irq();
50+
51+
SysTick->CTRL = 0;
52+
5053
HAL_RCC_DeInit();
54+
#ifdef STM32G4
5155
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
5256
#endif
5357

58+
for (uint8_t i = 0; i < sizeof(NVIC->ICER) / sizeof(NVIC->ICER[0]); i++)
59+
NVIC->ICER[i] = 0xFFFFFFFF;
60+
for (uint8_t i = 0; i < sizeof(NVIC->ICPR) / sizeof(NVIC->ICPR[0]); i++)
61+
NVIC->ICPR[i] = 0xFFFFFFFF;
62+
63+
__enable_irq();
64+
5465
void (*DfuBootJump)(void) = (void (*)(void))(*((uint32_t *)(BOOTLOADER_OFFSET + 4)));
5566
__set_MSP(*((uint32_t *)BOOTLOADER_OFFSET));
5667
DfuBootJump();

0 commit comments

Comments
 (0)