Skip to content

Commit

Permalink
MPIO HD300: Fix occasional scrollstrip hang
Browse files Browse the repository at this point in the history
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 <marcin.bukat@gmail.com>
Tested: Marcin Bukat <marcin.bukat@gmail.com>
  • Loading branch information
wodz committed Apr 15, 2014
1 parent a18c33a commit bd10245
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions firmware/target/coldfire/mpio/hd300/button-hd300.c
Expand Up @@ -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)
Expand All @@ -116,9 +116,7 @@ void scrollstrip_isr(void)

direction = scroll_dir;
count = 0;
ack_scrollstrip_interrupt();
enable_scrollstrip_interrupts();
return;
goto end;
}

/* poke backlight */
Expand All @@ -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;

Expand All @@ -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();
}
Expand Down

0 comments on commit bd10245

Please sign in to comment.