File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,21 @@ safe_mode_t port_init(void) {
131
131
analogin_init ();
132
132
#endif
133
133
134
+ // If the board was reset by the WatchDogTimer, we may
135
+ // need to boot into safe mode. Reset the RESETREAS bit
136
+ // for the WatchDogTimer so we don't encounter this the
137
+ // next time we reboot.
138
+ if (NRF_POWER -> RESETREAS & POWER_RESETREAS_DOG_Msk ) {
139
+ NRF_POWER -> RESETREAS = POWER_RESETREAS_DOG_Msk ;
140
+ uint32_t usb_reg = NRF_POWER -> USBREGSTATUS ;
141
+
142
+ // If USB is connected, then the user might be editing `code.py`,
143
+ // in which case we should reboot into Safe Mode.
144
+ if (usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk ) {
145
+ return WATCHDOG_RESET ;
146
+ }
147
+ }
148
+
134
149
return NO_SAFE_MODE ;
135
150
}
136
151
You can’t perform that action at this time.
0 commit comments