Implement mcu_reset function for teensy_32/teensy_lc

This commit is contained in:
Joel Challis
2026-11-13 08:12:39 +00:00
committed by GitHub
parent 552db5253f
commit 62a439a012
+19 -1
View File
@@ -19,9 +19,27 @@
#include <ch.h>
#include "wait.h"
#define SCB_AIRCR_VECTKEY_WRITEMAGIC 0x05FA0000
__attribute__((weak)) void bootloader_jump(void) {
wait_ms(100);
__BKPT(0);
}
__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();
}
}