Skip to content

Commit 0299cfe

Browse files
committed
Avoid entering into DFU mode upon wake up by BUTTON_DFU GPIO
1 parent cb916d3 commit 0299cfe

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void usb_teardown(void);
109109
#define DFU_MAGIC_OTA_RESET 0xA8
110110
#define DFU_MAGIC_SERIAL_ONLY_RESET 0x4e
111111
#define DFU_MAGIC_UF2_RESET 0x57
112+
#define DFU_MAGIC_SKIP 0x6d
112113

113114
#define DFU_DBL_RESET_MAGIC 0x5A1AD5 // SALADS
114115
#define DFU_DBL_RESET_APP 0x4ee5677e
@@ -176,8 +177,10 @@ int main(void)
176177
bool dfu_start = _ota_dfu || serial_only_dfu || uf2_dfu ||
177178
(((*dbl_reset_mem) == DFU_DBL_RESET_MAGIC) && (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk));
178179

180+
bool dfu_skip = (NRF_POWER->GPREGRET == DFU_MAGIC_SKIP);
181+
179182
// Clear GPREGRET if it is our values
180-
if (dfu_start) NRF_POWER->GPREGRET = 0;
183+
if (dfu_start || dfu_skip) NRF_POWER->GPREGRET = 0;
181184

182185
// Save bootloader version to pre-defined register, retrieved by application
183186
// TODO move to CF2
@@ -201,7 +204,7 @@ int main(void)
201204

202205
/*------------- Determine DFU mode (Serial, OTA, FRESET or normal) -------------*/
203206
// DFU button pressed
204-
dfu_start = dfu_start || button_pressed(BUTTON_DFU);
207+
dfu_start = dfu_start || (button_pressed(BUTTON_DFU) && !dfu_skip);
205208

206209
// DFU + FRESET are pressed --> OTA
207210
_ota_dfu = _ota_dfu || ( button_pressed(BUTTON_DFU) && button_pressed(BUTTON_FRESET) ) ;

0 commit comments

Comments
 (0)