stm32/mboot: Adjust user-reset-mode timeout so it ends with mode=1.

If the user button is held down indefinitely (eg unintenionally, or because
the GPIO signal of the user button is connected to some external device)
then it makes sense to end the reset mode cycle with the default mode of
1, which executes code as normal.
This commit is contained in:
Damien George 2018-06-18 12:23:27 +10:00
parent 564abb01a5
commit ceff433fcc
1 changed files with 4 additions and 3 deletions

View File

@ -1011,11 +1011,12 @@ static int get_reset_mode(void) {
int reset_mode = 1;
if (usrbtn_state()) {
// Cycle through reset modes while USR is held
// Timeout is roughly 20s, where reset_mode=1
systick_init();
led_init();
reset_mode = 0;
for (int i = 0; i < 1000; i++) {
if (i % 30 == 0) {
for (int i = 0; i < 1024; i++) {
if (i % 32 == 0) {
if (++reset_mode > 4) {
reset_mode = 1;
}
@ -1027,7 +1028,7 @@ static int get_reset_mode(void) {
if (!usrbtn_state()) {
break;
}
mp_hal_delay_ms(20);
mp_hal_delay_ms(19);
}
// Flash the selected reset mode
for (int i = 0; i < 6; i++) {