From bd10245e8940c05e9c4bfe13744571daf43a164a Mon Sep 17 00:00:00 2001 From: Marcin Bukat Date: Fri, 11 Apr 2014 11:04:06 +0200 Subject: MPIO HD300: Fix occasional scrollstrip hang Scrollstrip works as quadrature encoder. We set pin change interrupt for both edges of signal both lines and sample the state in ISR. From time to time the sequence is out-of-sync which was properly detected but erroneously handled leaving scrollstip interrupts disabled. Change-Id: I08e4f99c6c27df0f8180aa16e6e1d9e4203bafa7 Reviewed-on: http://gerrit.rockbox.org/782 Reviewed-by: Marcin Bukat Tested: Marcin Bukat --- firmware/target/coldfire/mpio/hd300/button-hd300.c | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/firmware/target/coldfire/mpio/hd300/button-hd300.c b/firmware/target/coldfire/mpio/hd300/button-hd300.c index f59c046cdb..fda26dd0df 100644 --- a/firmware/target/coldfire/mpio/hd300/button-hd300.c +++ b/firmware/target/coldfire/mpio/hd300/button-hd300.c @@ -90,20 +90,20 @@ void scrollstrip_isr(void) /* read GPIO6 and GPIO7 state*/ new_scroll_lines = (GPIO_READ >> 6) & 0x03; + /* was it initialized? */ if ( prev_scroll_lines == -1 ) { prev_scroll_lines = new_scroll_lines; - ack_scrollstrip_interrupt(); - enable_scrollstrip_interrupts(); - return; + goto end; } + /* calculate the direction according to the sequence order */ scroll_dir = scroll_state[prev_scroll_lines][new_scroll_lines]; prev_scroll_lines = new_scroll_lines; /* catch sequence error */ if (scroll_dir == BUTTON_NONE) - return; + goto end; /* direction reversal */ if (direction != scroll_dir) @@ -116,9 +116,7 @@ void scrollstrip_isr(void) direction = scroll_dir; count = 0; - ack_scrollstrip_interrupt(); - enable_scrollstrip_interrupts(); - return; + goto end; } /* poke backlight */ @@ -129,12 +127,9 @@ void scrollstrip_isr(void) next_backlight_on = current_tick + HZ/4; } + /* apply sensitivity filter */ if (++count < SLIDER_BASE_SENSITIVITY) - { - ack_scrollstrip_interrupt(); - enable_scrollstrip_interrupts(); - return; - } + goto end; count = 0; @@ -146,6 +141,10 @@ void scrollstrip_isr(void) scroll.timeout = current_tick + SLIDER_REL_TIMEOUT; scroll.rel = false; +end: + /* acknowledge the interrupt + * and reenable scrollstrip interrupts + */ ack_scrollstrip_interrupt(); enable_scrollstrip_interrupts(); } -- cgit v1.2.3