diff options
| author | jepler <jepler@de11.u> | 2019-07-14 13:02:01 -0500 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2019-08-01 18:53:07 -0500 |
| commit | 34e2bab96ace9e657877f25551f10b87d14c5772 (patch) | |
| tree | 076f2095c056b852fa2c75112c4b802648064bf7 /ports/nrf/common-hal/microcontroller | |
| parent | 95d2694bc33eddba991abcff1d9b2aba5675c622 (diff) | |
nrf: Implement RUNMODE_BOOTLOADER and RUNMODE_SAFE_MODE
Diffstat (limited to 'ports/nrf/common-hal/microcontroller')
| -rw-r--r-- | ports/nrf/common-hal/microcontroller/__init__.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c index ab7b5d5d6..a6b1c4ba3 100644 --- a/ports/nrf/common-hal/microcontroller/__init__.c +++ b/ports/nrf/common-hal/microcontroller/__init__.c @@ -37,6 +37,7 @@ #include "shared-bindings/microcontroller/Processor.h" #include "supervisor/filesystem.h" +#include "supervisor/shared/safe_mode.h" #include "nrfx_glue.h" // This routine should work even when interrupts are disabled. Used by OneWire @@ -52,7 +53,13 @@ void common_hal_mcu_enable_interrupts() { } void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { - // TODO: see atmel-samd for functionality + enum { DFU_MAGIC_UF2_RESET = 0x57 }; + if(runmode == RUNMODE_BOOTLOADER) + NRF_POWER->GPREGRET = DFU_MAGIC_UF2_RESET; + else + NRF_POWER->GPREGRET = 0; + if(runmode == RUNMODE_SAFE_MODE) + safe_mode_on_next_reset(PROGRAMMATIC_SAFE_MODE); } void common_hal_mcu_reset(void) { |
