aboutsummaryrefslogtreecommitdiff
path: root/ports/stm32
diff options
context:
space:
mode:
authorDamien George2018-06-18 12:23:27 +1000
committerDamien George2018-06-18 12:23:27 +1000
commitceff433fccb3f12b9ae39a726e4893366481822a (patch)
treedcc855873c4f4866f93e0388f3bd4c1c9e776dca /ports/stm32
parent564abb01a5526bd2d981791401e28774c7dcfe4c (diff)
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.
Diffstat (limited to 'ports/stm32')
-rw-r--r--ports/stm32/mboot/main.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ports/stm32/mboot/main.c b/ports/stm32/mboot/main.c
index a87507fd5..92217a4be 100644
--- a/ports/stm32/mboot/main.c
+++ b/ports/stm32/mboot/main.c
@@ -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++) {