canboot_main: Make entry via double reset a config option

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2022-05-04 22:04:48 -04:00 committed by Eric Callahan
parent 807c1ef0bd
commit ce580fa8c6
2 changed files with 19 additions and 7 deletions

View File

@ -16,6 +16,10 @@ config CANBUS_FREQUENCY
int "CAN bus speed"
default 500000
config ENABLE_DOUBLE_RESET
bool "Support bootloader entry on rapid double click of reset button"
default y
config ENABLE_LED
bool "Enable Status LED"
default n

View File

@ -219,6 +219,20 @@ check_application_code(void)
return 0;
}
// Check for a bootloader request via double tap of reset button
static void
check_double_reset(void)
{
if (!CONFIG_ENABLE_DOUBLE_RESET)
return;
// set request signature and delay for two seconds. This enters the bootloader if
// the reset button is double clicked
set_bootup_code(REQUEST_SIG);
udelay(2000000);
set_bootup_code(0);
// No reset, read the key back out to clear it
}
/****************************************************************
* Startup
@ -255,13 +269,7 @@ canboot_main(void)
set_bootup_code(0);
enter_bootloader();
}
// set request signature and delay for two seconds. This enters the bootloader if
// the reset button is double clicked
set_bootup_code(REQUEST_SIG);
udelay(2000000);
set_bootup_code(0);
// No reset, read the key back out to clear it
check_double_reset();
// jump to app
jump_to_application();