2 parents 0871899 + 34e2bab commit 64bf0f8Copy full SHA for 64bf0f8
1 file changed
ports/nrf/common-hal/microcontroller/__init__.c
@@ -37,6 +37,7 @@
37
#include "shared-bindings/microcontroller/Processor.h"
38
39
#include "supervisor/filesystem.h"
40
+#include "supervisor/shared/safe_mode.h"
41
#include "nrfx_glue.h"
42
43
// This routine should work even when interrupts are disabled. Used by OneWire
@@ -52,7 +53,13 @@ void common_hal_mcu_enable_interrupts() {
52
53
}
54
55
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
- // TODO: see atmel-samd for functionality
56
+ enum { DFU_MAGIC_UF2_RESET = 0x57 };
57
+ if(runmode == RUNMODE_BOOTLOADER)
58
+ NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET;
59
+ else
60
+ NRF_POWER->GPREGRET = 0;
61
+ if(runmode == RUNMODE_SAFE_MODE)
62
+ safe_mode_on_next_reset(PROGRAMMATIC_SAFE_MODE);
63
64
65
void common_hal_mcu_reset(void) {
0 commit comments