From f636085dbf565ffee58fb90531e7cb8d2af06341 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 31 Mar 2023 00:40:37 +0200 Subject: [PATCH] Fix potential freeze. For unknown reason, button cannot be checked if USB is active, as it is stalled. Signed-off-by: Pol Henarejos --- src/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index aba7634..5f30a48 100644 --- a/src/main.c +++ b/src/main.c @@ -136,6 +136,10 @@ void timeout_start() { timeout = board_millis(); } +bool is_busy() { + return timeout > 0; +} + void execute_tasks(); static bool req_button_pending = false; @@ -310,7 +314,7 @@ int main(void) { neug_task(); do_flash(); #ifndef ENABLE_EMULATION - if (board_millis() > 1000) { // wait 1 second to boot up + if (board_millis() > 1000 && !is_busy()) { // wait 1 second to boot up bool current_button_state = board_button_read(); if (current_button_state != button_pressed_state) { if (current_button_state == false) { // unpressed