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 21
21
#include "supervisor/shared/safe_mode.h"
22
22
#include "nrfx_glue.h"
23
23
#include "nrf_nvic.h"
24
+ #include "nrf_power.h"
24
25
25
26
// This routine should work even when interrupts are disabled. Used by OneWire
26
27
// for precise timing.
@@ -61,10 +62,14 @@ void common_hal_mcu_enable_interrupts() {
61
62
62
63
void common_hal_mcu_on_next_reset (mcu_runmode_t runmode ) {
63
64
enum { DFU_MAGIC_UF2_RESET = 0x57 };
65
+ uint8_t new_value = 0 ;
64
66
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 );
68
73
}
69
74
if (runmode == RUNMODE_SAFE_MODE ) {
70
75
safe_mode_on_next_reset (SAFE_MODE_PROGRAMMATIC );
You can’t perform that action at this time.
0 commit comments