6161#include "nrf_error.h"
6262
6363#include "boards.h"
64+ #include "uf2/uf2.h"
6465
6566#include "pstorage_platform.h"
6667#include "nrf_mbr.h"
@@ -112,6 +113,8 @@ void usb_teardown(void);
112113#define BOOTLOADER_VERSION_REGISTER NRF_TIMER2->CC[0]
113114#define DFU_SERIAL_STARTUP_INTERVAL 1000
114115
116+ #define APP_ASKS_FOR_SINGLE_TAP_RESET () (*((uint32_t*)(USER_FLASH_START + 0x200)) == 0x87eeb07c)
117+
115118// These value must be the same with one in dfu_transport_ble.c
116119#define BLEGAP_EVENT_LENGTH 6
117120#define BLEGATT_ATT_MTU_MAX 247
@@ -200,6 +203,9 @@ int main(void)
200203 bool const valid_app = bootloader_app_is_valid (DFU_BANK_0_REGION_START );
201204 bool const just_start_app = valid_app && !dfu_start && (* dbl_reset_mem ) == DFU_DBL_RESET_APP ;
202205
206+ if (!just_start_app && APP_ASKS_FOR_SINGLE_TAP_RESET ())
207+ dfu_start = 1 ;
208+
203209 // App mode: register 1st reset and DFU startup (nrf52832)
204210 if ( ! (just_start_app || dfu_start || !valid_app ) )
205211 {
@@ -220,7 +226,10 @@ int main(void)
220226#endif
221227 }
222228
223- (* dbl_reset_mem ) = 0 ;
229+ if (APP_ASKS_FOR_SINGLE_TAP_RESET ())
230+ (* dbl_reset_mem ) = DFU_DBL_RESET_APP ;
231+ else
232+ (* dbl_reset_mem ) = 0 ;
224233
225234 if ( dfu_start || !valid_app )
226235 {
@@ -263,6 +272,9 @@ int main(void)
263272 // MBR must be init before start application
264273 if ( !sd_inited ) softdev_mbr_init ();
265274
275+ // clear in case we kept DFU_DBL_RESET_APP there
276+ (* dbl_reset_mem ) = 0 ;
277+
266278 // Select a bank region to use as application region.
267279 // @note: Only applications running from DFU_BANK_0_REGION_START is supported.
268280 bootloader_app_start (DFU_BANK_0_REGION_START );
0 commit comments