mirror of
https://github.com/oltaco/Adafruit_nRF52_Bootloader_OTAFIX.git
synced 2026-10-22 15:23:13 +00:00
Reset into app, if no USB connection in 3s
(only applies in SINGLE_TAP_RESET mode (MakeCode))
This commit is contained in:
1 parent
d6b28e6605
commit
6b4cf21ba2
3 files changed
+22
-4
No files matched your search
@@ -50,6 +50,8 @@ typedef enum
|
||||
static pstorage_handle_t m_bootsettings_handle; /**< Pstorage handle to use for registration and identifying the bootloader module on subsequent calls to the pstorage module for load and store of bootloader setting in flash. */
|
||||
static bootloader_status_t m_update_status; /**< Current update status for the bootloader module to ensure correct behaviour when updating settings and when update completes. */
|
||||
|
||||
static bool m_cancel_timeout_on_usb;
|
||||
|
||||
APP_TIMER_DEF( _dfu_startup_timer );
|
||||
volatile bool dfu_startup_packet_received = false;
|
||||
|
||||
@@ -79,6 +81,13 @@ static void pstorage_callback_handler(pstorage_handle_t * p_handle,
|
||||
*/
|
||||
static void dfu_startup_timer_handler(void * p_context)
|
||||
{
|
||||
#ifdef NRF_USBD
|
||||
if (m_cancel_timeout_on_usb && tud_mounted())
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// No packets are received within timeout, terminal and DFU mode
|
||||
// dfu_startup_packet_received is set by process_dfu_packet() in dfu_transport_serial.c
|
||||
if (!dfu_startup_packet_received)
|
||||
@@ -313,10 +322,12 @@ uint32_t bootloader_init(void)
|
||||
}
|
||||
|
||||
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms)
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout_on_usb)
|
||||
{
|
||||
uint32_t err_code;
|
||||
|
||||
m_cancel_timeout_on_usb = cancel_timeout_on_usb;
|
||||
|
||||
// Clear swap if banked update is used.
|
||||
err_code = dfu_init();
|
||||
VERIFY_SUCCESS(err_code);
|
||||
|
||||
@@ -42,7 +42,7 @@ bool bootloader_app_is_valid(void);
|
||||
*
|
||||
* @retval NRF_SUCCESS If new application image was successfully transferred.
|
||||
*/
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms);
|
||||
uint32_t bootloader_dfu_start(bool ota, uint32_t timeout_ms, bool cancel_timeout_on_usb);
|
||||
|
||||
/**@brief Function for exiting bootloader and booting into application.
|
||||
*
|
||||
|
||||
+9
-2
@@ -223,7 +223,7 @@ int main(void)
|
||||
* Note: Supposedly during this time if RST is press, it will count as double reset.
|
||||
* However Double Reset WONT work with nrf52832 since its SRAM got cleared anyway.
|
||||
*/
|
||||
bootloader_dfu_start(false, DFU_SERIAL_STARTUP_INTERVAL);
|
||||
bootloader_dfu_start(false, DFU_SERIAL_STARTUP_INTERVAL, false);
|
||||
#else
|
||||
// if RST is pressed during this delay --> if will enter dfu
|
||||
NRFX_DELAY_MS(DFU_DBL_RESET_DELAY);
|
||||
@@ -250,7 +250,14 @@ int main(void)
|
||||
}
|
||||
|
||||
// Initiate an update of the firmware.
|
||||
APP_ERROR_CHECK( bootloader_dfu_start(_ota_dfu, 0) );
|
||||
if (APP_ASKS_FOR_SINGLE_TAP_RESET())
|
||||
{
|
||||
APP_ERROR_CHECK( bootloader_dfu_start(_ota_dfu, 3000, true) );
|
||||
}
|
||||
else
|
||||
{
|
||||
APP_ERROR_CHECK( bootloader_dfu_start(_ota_dfu, 0, false) );
|
||||
}
|
||||
|
||||
if ( _ota_dfu )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user