From 99bf5064077ec8b3daef592cf076b72cb82b7693 Mon Sep 17 00:00:00 2001 From: Tomasz Moń Date: Wed, 7 Jul 2021 12:52:05 +0200 Subject: Sansa Connect: Prevent unresponsive interface AVR interrupt signal can remain active if the state has changed during state read. In such case, there won't be intterupt and the interface would appear unresponsive until AVR thread received event (e.g. USB connection/disconnect). Solve the issue by not waiting for event if AVR interrupt signal is active prior to event wait. Change-Id: I86e388c7cd6da76e3abe7bf7114940f331e4c308 --- .../arm/tms320dm320/sansa-connect/avr-sansaconnect.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c index ed7dab1572..01acc6905e 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c @@ -818,7 +818,19 @@ void avr_thread(void) while (1) { - queue_wait(&avr_queue, &ev); + if (avr_state_changed()) + { + /* We have to read AVR state, simply check if there's any event + * pending but do not block. It is possible that AVR interrupt + * line is held active even though we read the state (change + * occured during read). + */ + queue_wait_w_tmo(&avr_queue, &ev, 0); + } + else + { + queue_wait(&avr_queue, &ev); + } if (ev.id == SYS_USB_CONNECTED) { -- cgit v1.2.3