summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/mpio/hd300/button-hd300.c
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2014-04-11 11:04:06 +0200
committerMarcin Bukat <marcin.bukat@gmail.com>2014-04-15 08:18:56 +0200
commitbd10245e8940c05e9c4bfe13744571daf43a164a (patch)
treeabb6a4e23f9d51ff7dafa93273990d34f7f8eca9 /firmware/target/coldfire/mpio/hd300/button-hd300.c
parenta18c33a498dd21b5cb083f1076987448fce259cc (diff)
downloadrockbox-bd10245e8940c05e9c4bfe13744571daf43a164a.tar.gz
rockbox-bd10245e8940c05e9c4bfe13744571daf43a164a.zip
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 <marcin.bukat@gmail.com> Tested: Marcin Bukat <marcin.bukat@gmail.com>
Diffstat (limited to 'firmware/target/coldfire/mpio/hd300/button-hd300.c')
-rw-r--r--firmware/target/coldfire/mpio/hd300/button-hd300.c23
1 files 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)
90 /* read GPIO6 and GPIO7 state*/ 90 /* read GPIO6 and GPIO7 state*/
91 new_scroll_lines = (GPIO_READ >> 6) & 0x03; 91 new_scroll_lines = (GPIO_READ >> 6) & 0x03;
92 92
93 /* was it initialized? */
93 if ( prev_scroll_lines == -1 ) 94 if ( prev_scroll_lines == -1 )
94 { 95 {
95 prev_scroll_lines = new_scroll_lines; 96 prev_scroll_lines = new_scroll_lines;
96 ack_scrollstrip_interrupt(); 97 goto end;
97 enable_scrollstrip_interrupts();
98 return;
99 } 98 }
100 99
100 /* calculate the direction according to the sequence order */
101 scroll_dir = scroll_state[prev_scroll_lines][new_scroll_lines]; 101 scroll_dir = scroll_state[prev_scroll_lines][new_scroll_lines];
102 prev_scroll_lines = new_scroll_lines; 102 prev_scroll_lines = new_scroll_lines;
103 103
104 /* catch sequence error */ 104 /* catch sequence error */
105 if (scroll_dir == BUTTON_NONE) 105 if (scroll_dir == BUTTON_NONE)
106 return; 106 goto end;
107 107
108 /* direction reversal */ 108 /* direction reversal */
109 if (direction != scroll_dir) 109 if (direction != scroll_dir)
@@ -116,9 +116,7 @@ void scrollstrip_isr(void)
116 116
117 direction = scroll_dir; 117 direction = scroll_dir;
118 count = 0; 118 count = 0;
119 ack_scrollstrip_interrupt(); 119 goto end;
120 enable_scrollstrip_interrupts();
121 return;
122 } 120 }
123 121
124 /* poke backlight */ 122 /* poke backlight */
@@ -129,12 +127,9 @@ void scrollstrip_isr(void)
129 next_backlight_on = current_tick + HZ/4; 127 next_backlight_on = current_tick + HZ/4;
130 } 128 }
131 129
130 /* apply sensitivity filter */
132 if (++count < SLIDER_BASE_SENSITIVITY) 131 if (++count < SLIDER_BASE_SENSITIVITY)
133 { 132 goto end;
134 ack_scrollstrip_interrupt();
135 enable_scrollstrip_interrupts();
136 return;
137 }
138 133
139 count = 0; 134 count = 0;
140 135
@@ -146,6 +141,10 @@ void scrollstrip_isr(void)
146 scroll.timeout = current_tick + SLIDER_REL_TIMEOUT; 141 scroll.timeout = current_tick + SLIDER_REL_TIMEOUT;
147 scroll.rel = false; 142 scroll.rel = false;
148 143
144end:
145 /* acknowledge the interrupt
146 * and reenable scrollstrip interrupts
147 */
149 ack_scrollstrip_interrupt(); 148 ack_scrollstrip_interrupt();
150 enable_scrollstrip_interrupts(); 149 enable_scrollstrip_interrupts();
151} 150}