瀏覽代碼

Add an `mcu_reset` impl for the kiibohd bootloader. (#25963)

* Fixes resetting and split watchdog on the Ergodox Infinity.
Dominic Clifton 4 月之前
父節點
當前提交
3d0ccbb1d5
共有 1 個文件被更改,包括 18 次插入1 次删除
  1. 18 1
      platforms/chibios/bootloaders/kiibohd.c

+ 18 - 1
platforms/chibios/bootloaders/kiibohd.c

@@ -30,4 +30,21 @@ __attribute__((weak)) void bootloader_jump(void) {
     // request reset
     SCB->AIRCR = SCB_AIRCR_VECTKEY_WRITEMAGIC | SCB_AIRCR_SYSRESETREQ_Msk;
 }
-__attribute__((weak)) void mcu_reset(void) {}
+
+__attribute__((weak)) void mcu_reset(void) {
+    /* Ensure all outstanding memory operations complete */
+    __DSB();
+    __ISB();
+
+    /* Request system reset (preserve PRIGROUP) */
+    uint32_t aircr = SCB->AIRCR;
+    aircr &= ~SCB_AIRCR_VECTKEY_Msk;
+    aircr |= SCB_AIRCR_VECTKEY_WRITEMAGIC;
+    aircr |= SCB_AIRCR_SYSRESETREQ_Msk;
+    SCB->AIRCR = aircr;
+
+    /* Wait for reset to occur */
+    while (true) {
+        __NOP();
+    }
+}