File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
ports/nordic/common-hal/microcontroller Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 2121#include "supervisor/shared/safe_mode.h"
2222#include "nrfx_glue.h"
2323#include "nrf_nvic.h"
24+ #include "nrf_power.h"
2425
2526// This routine should work even when interrupts are disabled. Used by OneWire
2627// for precise timing.
@@ -61,10 +62,14 @@ void common_hal_mcu_enable_interrupts() {
6162
6263void common_hal_mcu_on_next_reset (mcu_runmode_t runmode ) {
6364 enum { DFU_MAGIC_UF2_RESET = 0x57 };
65+ uint8_t new_value = 0 ;
6466 if (runmode == RUNMODE_BOOTLOADER || runmode == RUNMODE_UF2 ) {
65- sd_power_gpregret_set (0 , DFU_MAGIC_UF2_RESET );
66- } else {
67- sd_power_gpregret_set (0 , 0 );
67+ new_value = DFU_MAGIC_UF2_RESET ;
68+ }
69+ int err_code = sd_power_gpregret_set (0 , DFU_MAGIC_UF2_RESET );
70+ if (err_code != NRF_SUCCESS ) {
71+ // Set it without the soft device if the SD failed. (It may be off.)
72+ nrf_power_gpregret_set (NRF_POWER , new_value );
6873 }
6974 if (runmode == RUNMODE_SAFE_MODE ) {
7075 safe_mode_on_next_reset (SAFE_MODE_PROGRAMMATIC );
You can’t perform that action at this time.
0 commit comments