From b89f9d43b96cd135a35624bc4a4f662ea1d8adba Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Tue, 28 Jan 2020 21:14:32 +0000 Subject: [PATCH] boards: Improve the boot button behaviour --- src/boards.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/boards.c b/src/boards.c index acc75c8..6256757 100644 --- a/src/boards.c +++ b/src/boards.c @@ -161,14 +161,18 @@ void SysTick_Handler(void) * way that makes it impossible for us to reboot using the button test * code below. This is OK to feed it from a periodic interrupt. */ - nrf_wdt_reload_request_set(NRF_WDT, 0); + if (!button_pressed(BUTTON_DFU)) + nrf_wdt_reload_request_set(NRF_WDT, 0); /* - * Detect a long press of the DFU button. When found try to launch the - * application regardless of the DFU button state. + * Detect and (trivially) debounce a press of the DFU button. When + * found try to launch the application regardless of the DFU button + * state. We ignore the button press for our first few seconds of life + * because makes it harder to accidentally start the application when + * recovering from a flat battery. */ if (button_pressed(BUTTON_DFU)) { - if (_long_press_count++ > (2 * 1000)) { + if (_systick_count > 4750 && _long_press_count++ > 250) { NRF_POWER->GPREGRET = BOARD_MAGIC_FORCE_APP_BOOT; NVIC_SystemReset(); }