summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-04-27 10:11:52 +0000
committerThomas Martitz <kugel@rockbox.org>2010-04-27 10:11:52 +0000
commit249aae587a1f35f5df55613c6765ae763db39107 (patch)
treedcc7f100fcdc7af8b09a7e3daa96b852a1986c74
parentee291a5e9b12651ffa658bef15e09902a82285f9 (diff)
downloadrockbox-249aae587a1f35f5df55613c6765ae763db39107.tar.gz
rockbox-249aae587a1f35f5df55613c6765ae763db39107.zip
FS#11172 - Fuzev2: Read the scrollwheel scrollwheel via IRQ
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25736 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/SOURCES6
-rw-r--r--firmware/export/config/sansafuzev2.h18
-rw-r--r--firmware/target/arm/as3525/kernel-as3525.c2
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c192
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-target.h6
-rw-r--r--firmware/target/arm/as3525/sd-as3525.c21
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c20
-rw-r--r--firmware/target/arm/as3525/system-as3525.c21
-rw-r--r--firmware/target/arm/as3525/system-target.h6
9 files changed, 238 insertions, 54 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 48360d7b45..0e95ba5880 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -407,11 +407,11 @@ target/arm/pnx0101/timer-pnx0101.c
407target/arm/as3525/system-as3525.c 407target/arm/as3525/system-as3525.c
408target/arm/as3525/kernel-as3525.c 408target/arm/as3525/kernel-as3525.c
409target/arm/as3525/timer-as3525.c 409target/arm/as3525/timer-as3525.c
410#ifdef HAVE_SCROLLWHEEL
411target/arm/as3525/scrollwheel-as3525.c
412#endif
413#if CONFIG_CPU == AS3525 410#if CONFIG_CPU == AS3525
414target/arm/as3525/sd-as3525.c 411target/arm/as3525/sd-as3525.c
412#ifdef HAVE_SCROLLWHEEL
413target/arm/as3525/scrollwheel-as3525.c
414#endif /* HAVE_SCROLLWHEEL */
415#else /* AS3535v2 */ 415#else /* AS3535v2 */
416target/arm/as3525/sd-as3525v2.c 416target/arm/as3525/sd-as3525v2.c
417#endif 417#endif
diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h
index 172434282d..4caab8464a 100644
--- a/firmware/export/config/sansafuzev2.h
+++ b/firmware/export/config/sansafuzev2.h
@@ -68,6 +68,15 @@
68/* There is no hardware tone control */ 68/* There is no hardware tone control */
69#define HAVE_SW_TONE_CONTROLS 69#define HAVE_SW_TONE_CONTROLS
70 70
71/* define this if the unit uses a scrollwheel for navigation */
72#define HAVE_SCROLLWHEEL
73/* define to activate advanced wheel acceleration code */
74#define HAVE_WHEEL_ACCELERATION
75/* define from which rotation speed [degree/sec] on the acceleration starts */
76#define WHEEL_ACCEL_START 540
77/* define type of acceleration (1 = ^2, 2 = ^3, 3 = ^4) */
78#define WHEEL_ACCELERATION 1
79
71#endif /* !BOOTLOADER */ 80#endif /* !BOOTLOADER */
72 81
73/* put the lcd frame buffer in IRAM */ 82/* put the lcd frame buffer in IRAM */
@@ -126,15 +135,6 @@
126/* Which backlight fading type? */ 135/* Which backlight fading type? */
127#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING 136#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
128 137
129/* define this if the unit uses a scrollwheel for navigation */
130#define HAVE_SCROLLWHEEL
131/* define to activate advanced wheel acceleration code */
132#define HAVE_WHEEL_ACCELERATION
133/* define from which rotation speed [degree/sec] on the acceleration starts */
134#define WHEEL_ACCEL_START 540
135/* define type of acceleration (1 = ^2, 2 = ^3, 3 = ^4) */
136#define WHEEL_ACCELERATION 1
137
138/* define this if you have a flash memory storage */ 138/* define this if you have a flash memory storage */
139#define HAVE_FLASH_STORAGE 139#define HAVE_FLASH_STORAGE
140 140
diff --git a/firmware/target/arm/as3525/kernel-as3525.c b/firmware/target/arm/as3525/kernel-as3525.c
index 4ae1a03809..ff489a86e8 100644
--- a/firmware/target/arm/as3525/kernel-as3525.c
+++ b/firmware/target/arm/as3525/kernel-as3525.c
@@ -24,7 +24,7 @@
24#include "panic.h" 24#include "panic.h"
25#include "timer.h" 25#include "timer.h"
26 26
27#ifdef HAVE_SCROLLWHEEL 27#if INCREASED_SCROLLWHEEL_POLLING
28#include "button-target.h" 28#include "button-target.h"
29/* The scrollwheel is polled every 5 ms (the tick tasks only every 10) */ 29/* The scrollwheel is polled every 5 ms (the tick tasks only every 10) */
30static int poll_scrollwheel = 0; 30static int poll_scrollwheel = 0;
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index db08414ae5..9421076cce 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -24,37 +24,198 @@
24#include "button.h" 24#include "button.h"
25#include "backlight.h" 25#include "backlight.h"
26 26
27extern void scrollwheel(unsigned wheel_value);
28
29#ifdef HAS_BUTTON_HOLD 27#ifdef HAS_BUTTON_HOLD
30static bool hold_button = false; 28static bool hold_button = false;
31#endif 29#endif
30
31#ifdef HAVE_SCROLLWHEEL
32#define SCROLLWHEEL_BITS (1<<7|1<<6)
33 /* TIMER units */
34#define TIMER_TICK (TIMER_FREQ/HZ) /* how long a tick lasts */
35#define TIMER_MS (TIMER_TICK/(1000/HZ))/* how long a ms lasts */
36
37#define WHEEL_REPEAT_INTERVAL (300*TIMER_MS) /* 300ms */
38#define WHEEL_FAST_ON_INTERVAL ( 20*TIMER_MS) /* 20ms */
39#define WHEEL_FAST_OFF_INTERVAL ( 60*TIMER_MS) /* 60ms */
40/* phsyical clicks per rotation * wheel value changes per phys click */
41#define WHEEL_CHANGES_PER_CLICK 4
42#define WHEELCLICKS_PER_ROTATION (12*WHEEL_CHANGES_PER_CLICK)
43
44/*
45 * based on button-e200.c, adjusted to the AMS timers and fuzev2's
46 * scrollwheel and cleaned up a little
47 */
48static void scrollwheel(unsigned int wheel_value)
49{
50 /* wheel values and times from the previous irq */
51 static unsigned int old_wheel_value = 0;
52 static unsigned int wheel_repeat = BUTTON_NONE;
53 static long last_wheel_post = 0;
54
55 /* We only post every 4th action, as this matches better with the physical
56 * clicks of the wheel */
57 static unsigned int wheel_click_count = 0;
58 /* number of items to skip in lists, 1 in slow mode */
59 static unsigned int wheel_delta = 0;
60 /* accumulated wheel rotations per second */
61 static unsigned long wheel_velocity = 0;
62 /* fast or slow mode? */
63 static int wheel_fast_mode = 0;
64
65 /* Read wheel
66 * Bits 6 and 7 of GPIOA change as follows (Gray Code):
67 * Clockwise rotation 00 -> 01 -> 11 -> 10 -> 00
68 * Counter-clockwise 00 -> 10 -> 11 -> 01 -> 00
69 *
70 * For easy look-up, actual wheel values act as indicies also,
71 * which is why the table seems to be not ordered correctly
72 */
73 static const unsigned char wheel_tbl[2][4] =
74 {
75 { 2, 0, 3, 1 }, /* Clockwise rotation */
76 { 1, 3, 0, 2 }, /* Counter-clockwise */
77 };
78
79 unsigned int btn = BUTTON_NONE;
80
81 if (old_wheel_value == wheel_tbl[0][wheel_value])
82 btn = BUTTON_SCROLL_FWD;
83 else if (old_wheel_value == wheel_tbl[1][wheel_value])
84 btn = BUTTON_SCROLL_BACK;
85
86 if (btn == BUTTON_NONE)
87 {
88 old_wheel_value = wheel_value;
89 return;
90 }
91
92 int repeat = 1; /* assume repeat */
93 long time = TIMER1_VALUE + current_tick*TIMER_TICK; /* to timer unit */
94 long v = (time - last_wheel_post);
95
96 /* interpolate velocity in timer_freq/timer_unit == 1/s */
97 if (v) v = TIMER_FREQ / v;
98
99 /* accumulate velocities over time with each v */
100 wheel_velocity = (7*wheel_velocity + v) / 8;
101
102 if (btn != wheel_repeat)
103 {
104 /* direction reversals nullify all fast mode states */
105 wheel_repeat = btn;
106 repeat =
107 wheel_velocity =
108 wheel_click_count = 0;
109 }
110
111 if (wheel_fast_mode != 0)
112 {
113 /* fast OFF happens immediately when velocity drops below
114 threshold */
115 if (TIME_AFTER(time,
116 last_wheel_post + WHEEL_FAST_OFF_INTERVAL))
117 {
118 /* moving out of fast mode */
119 wheel_fast_mode = 0;
120 /* reset velocity */
121 wheel_velocity = 0;
122 /* wheel_delta is always 1 in slow mode */
123 wheel_delta = 1;
124 }
125 }
126 else
127 {
128 /* fast ON gets filtered to avoid inadvertent jumps to fast mode */
129 if (repeat && wheel_velocity > TIMER_FREQ/WHEEL_FAST_ON_INTERVAL)
130 {
131 /* moving into fast mode */
132 wheel_fast_mode = 1 << 31;
133 wheel_click_count = 0;
134 wheel_velocity = TIMER_FREQ/WHEEL_FAST_OFF_INTERVAL;
135 }
136 else if (++wheel_click_count < WHEEL_CHANGES_PER_CLICK)
137 { /* skip some wheel changes, so that 1 post represents
138 * 1 item in lists */
139 btn = BUTTON_NONE;
140 }
141
142 /* wheel_delta is always 1 in slow mode */
143 wheel_delta = 1;
144 }
145
146 if (btn != BUTTON_NONE)
147 {
148 wheel_click_count = 0;
149
150 /* generate repeats if quick enough */
151 if (repeat && TIME_BEFORE(time,
152 last_wheel_post + WHEEL_REPEAT_INTERVAL))
153 btn |= BUTTON_REPEAT;
154
155 last_wheel_post = time;
156
157 if (queue_empty(&button_queue))
158 {
159 queue_post(&button_queue, btn, wheel_fast_mode |
160 (wheel_delta << 24) | wheel_velocity*360/WHEELCLICKS_PER_ROTATION);
161 /* message posted - reset delta and poke backlight on*/
162 wheel_delta = 1;
163 backlight_on();
164 buttonlight_on();
165 }
166 else
167 {
168 /* skipped post - increment delta */
169 if (++wheel_delta > 0x7f)
170 wheel_delta = 0x7f;
171 }
172 }
173
174 old_wheel_value = wheel_value;
175}
176#endif
177
32void button_init_device(void) 178void button_init_device(void)
33{ 179{
180#if defined(HAVE_SCROLLWHEEL)
34 GPIOA_DIR &= ~(1<<6|1<<7); 181 GPIOA_DIR &= ~(1<<6|1<<7);
35 GPIOC_DIR = 0; 182 GPIOC_DIR = 0;
36 GPIOB_DIR |= (1<<4)|(1<<0); 183 GPIOB_DIR |= (1<<4)|(1<<0);
37 184
38 GPIOB_PIN(4) = 1<<4; /* activate the wheel */ 185 GPIOB_PIN(4) = 1<<4; /* activate the wheel */
39}
40 186
41void get_scrollwheel(void) 187 /* setup scrollwheel isr */
42{ 188 /* clear previous irq if any */
43#if defined(HAVE_SCROLLWHEEL) && !defined(BOOTLOADER) 189 GPIOA_IC = SCROLLWHEEL_BITS;
44 /* scroll wheel handling */ 190 /* enable edge detecting */
191 GPIOA_IS &= ~SCROLLWHEEL_BITS;
192 /* detect both raising and falling edges */
193 GPIOA_IBE |= SCROLLWHEEL_BITS;
194 /* lastly, enable the interrupt */
195 GPIOA_IE |= SCROLLWHEEL_BITS;
196#endif
197}
45 198
199 /* read the 2 bits at the same time */
46#define GPIOA_PIN76_offset ((1<<(6+2)) | (1<<(7+2))) 200#define GPIOA_PIN76_offset ((1<<(6+2)) | (1<<(7+2)))
47#define GPIOA_PIN76 (*(volatile unsigned char*)(GPIOA_BASE+GPIOA_PIN76_offset)) 201#define GPIOA_PIN76 (*(volatile unsigned char*)(GPIOA_BASE+GPIOA_PIN76_offset))
48 scrollwheel(GPIOA_PIN76 >> 6);
49 202
203void button_gpioa_isr(void)
204{
205#if defined(HAVE_SCROLLWHEEL)
206 /* scroll wheel handling */
207 if (GPIOA_MIS & SCROLLWHEEL_BITS)
208 scrollwheel(GPIOA_PIN76 >> 6);
209
210 /* ack interrupt */
211 GPIOA_IC = SCROLLWHEEL_BITS;
50#endif 212#endif
51} 213}
52 214
215
53/* 216/*
54 * Get button pressed from hardware 217 * Get button pressed from hardware
55 */ 218 */
56
57
58int button_read_device(void) 219int button_read_device(void)
59{ 220{
60 int btn = 0; 221 int btn = 0;
@@ -62,12 +223,12 @@ int button_read_device(void)
62 static long power_counter = 0; 223 static long power_counter = 0;
63 unsigned gpiod6; 224 unsigned gpiod6;
64 225
65
66 /* if we don't wait for the fifo to empty, we'll see screen corruption 226 /* if we don't wait for the fifo to empty, we'll see screen corruption
67 * (the higher the CPU frequency the higher the corruption) */ 227 * (the higher the CPU frequency the higher the corruption) */
68 while ((DBOP_STAT & (1<<10)) == 0); 228 while ((DBOP_STAT & (1<<10)) == 0);
69 229
70 get_scrollwheel(); 230 int delay = 30;
231 while(delay--) nop;
71 232
72 CCU_IO &= ~(1<<12); 233 CCU_IO &= ~(1<<12);
73 234
@@ -77,6 +238,7 @@ int button_read_device(void)
77 gpiod6 = GPIOD_PIN(6); 238 gpiod6 = GPIOD_PIN(6);
78 239
79 GPIOB_PIN(0) = 0; 240 GPIOB_PIN(0) = 0;
241
80 udelay(1); 242 udelay(1);
81 243
82 if (GPIOC_PIN(1) & 1<<1) 244 if (GPIOC_PIN(1) & 1<<1)
@@ -114,6 +276,12 @@ int button_read_device(void)
114 { 276 {
115 hold_button_old = hold_button; 277 hold_button_old = hold_button;
116 backlight_hold_changed(hold_button); 278 backlight_hold_changed(hold_button);
279 /* mask scrollwheel irq so we don't need to check for
280 * the hold button in the isr */
281 if (hold_button)
282 GPIOA_IE &= ~SCROLLWHEEL_BITS;
283 else
284 GPIOA_IE |= SCROLLWHEEL_BITS;
117 } 285 }
118#else 286#else
119 (void)hold_button_old; 287 (void)hold_button_old;
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-target.h b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
index d7ef9623f9..c64c68f951 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-target.h
@@ -30,12 +30,6 @@
30void button_init_device(void); 30void button_init_device(void);
31bool button_hold(void); 31bool button_hold(void);
32int button_read_device(void); 32int button_read_device(void);
33void get_scrollwheel(void);
34
35#define WHEEL_REPEAT_INTERVAL (HZ/5)
36#define WHEEL_COUNTER_DIV 4
37#define ACCEL_INCREMENT 2
38#define ACCEL_SHIFT 2
39/* Sandisk Sansa Fuze button codes */ 33/* Sandisk Sansa Fuze button codes */
40 34
41/* Main unit's buttons */ 35/* Main unit's buttons */
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index 1cf7e51cf8..9c3ff0b5fe 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -131,6 +131,7 @@ bool sd_enabled = false;
131 131
132#if defined(HAVE_MULTIDRIVE) 132#if defined(HAVE_MULTIDRIVE)
133static bool hs_card = false; 133static bool hs_card = false;
134#define EXT_SD_BITS (1<<2)
134#endif 135#endif
135 136
136static struct wakeup transfer_completion_signal; 137static struct wakeup transfer_completion_signal;
@@ -172,12 +173,13 @@ static int sd1_oneshot_callback(struct timeout *tmo)
172 return 0; 173 return 0;
173} 174}
174 175
175void INT_GPIOA(void) 176void sd_gpioa_isr(void)
176{ 177{
177 static struct timeout sd1_oneshot; 178 static struct timeout sd1_oneshot;
179 if (GPIOA_MIS & EXT_SD_BITS)
180 timeout_register(&sd1_oneshot, sd1_oneshot_callback, (3*HZ/10), 0);
178 /* acknowledge interrupt */ 181 /* acknowledge interrupt */
179 GPIOA_IC = (1<<2); 182 GPIOA_IC = EXT_SD_BITS;
180 timeout_register(&sd1_oneshot, sd1_oneshot_callback, (3*HZ/10), 0);
181} 183}
182#endif /* HAVE_HOTSWAP */ 184#endif /* HAVE_HOTSWAP */
183 185
@@ -479,15 +481,12 @@ static void init_pl180_controller(const int drive)
479#ifdef HAVE_MULTIDRIVE 481#ifdef HAVE_MULTIDRIVE
480 VIC_INT_ENABLE = 482 VIC_INT_ENABLE =
481 (drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0; 483 (drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0;
482
483 /* setup isr for microsd monitoring */
484 VIC_INT_ENABLE = (INTERRUPT_GPIOA);
485 /* clear previous irq */ 484 /* clear previous irq */
486 GPIOA_IC = (1<<2); 485 GPIOA_IC = EXT_SD_BITS;
487 /* enable edge detecting */ 486 /* enable edge detecting */
488 GPIOA_IS &= ~(1<<2); 487 GPIOA_IS &= ~EXT_SD_BITS;
489 /* detect both raising and falling edges */ 488 /* detect both raising and falling edges */
490 GPIOA_IBE |= (1<<2); 489 GPIOA_IBE |= EXT_SD_BITS;
491 490
492#else 491#else
493 VIC_INT_ENABLE = INTERRUPT_NAND; 492 VIC_INT_ENABLE = INTERRUPT_NAND;
@@ -910,9 +909,9 @@ tCardInfo *card_get_info_target(int card_no)
910void card_enable_monitoring_target(bool on) 909void card_enable_monitoring_target(bool on)
911{ 910{
912 if (on) /* enable interrupt */ 911 if (on) /* enable interrupt */
913 GPIOA_IE |= (1<<2); 912 GPIOA_IE |= EXT_SD_BITS;
914 else /* disable interrupt */ 913 else /* disable interrupt */
915 GPIOA_IE &= ~(1<<2); 914 GPIOA_IE &= ~EXT_SD_BITS;
916} 915}
917#endif /* HAVE_HOTSWAP */ 916#endif /* HAVE_HOTSWAP */
918 917
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 2f263f7378..65fc13feae 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -342,6 +342,7 @@ static volatile bool retry;
342 342
343#if defined(HAVE_MULTIDRIVE) 343#if defined(HAVE_MULTIDRIVE)
344int active_card = 0; 344int active_card = 0;
345#define EXT_SD_BITS (1<<2)
345#endif 346#endif
346 347
347static inline void mci_delay(void) { udelay(1000); } 348static inline void mci_delay(void) { udelay(1000); }
@@ -687,14 +688,12 @@ int sd_init(void)
687 wakeup_init(&transfer_completion_signal); 688 wakeup_init(&transfer_completion_signal);
688 689
689#ifdef HAVE_MULTIDRIVE 690#ifdef HAVE_MULTIDRIVE
690 /* setup isr for microsd monitoring */
691 VIC_INT_ENABLE = (INTERRUPT_GPIOA);
692 /* clear previous irq */ 691 /* clear previous irq */
693 GPIOA_IC = (1<<2); 692 GPIOA_IC = EXT_SD_BITS;
694 /* enable edge detecting */ 693 /* enable edge detecting */
695 GPIOA_IS &= ~(1<<2); 694 GPIOA_IS &= ~EXT_SD_BITS;
696 /* detect both raising and falling edges */ 695 /* detect both raising and falling edges */
697 GPIOA_IBE |= (1<<2); 696 GPIOA_IBE |= EXT_SD_BITS;
698 /* Configure XPD for SD-MCI interface */ 697 /* Configure XPD for SD-MCI interface */
699 CCU_IO |= (1<<2); 698 CCU_IO |= (1<<2);
700#endif 699#endif
@@ -961,20 +960,21 @@ static int sd1_oneshot_callback(struct timeout *tmo)
961 return 0; 960 return 0;
962} 961}
963 962
964void INT_GPIOA(void) 963void sd_gpioa_isr(void)
965{ 964{
966 static struct timeout sd1_oneshot; 965 static struct timeout sd1_oneshot;
966 if (GPIOA_MIS & EXT_SD_BITS)
967 timeout_register(&sd1_oneshot, sd1_oneshot_callback, (3*HZ/10), 0);
967 /* acknowledge interrupt */ 968 /* acknowledge interrupt */
968 GPIOA_IC = (1<<2); 969 GPIOA_IC = EXT_SD_BITS;
969 timeout_register(&sd1_oneshot, sd1_oneshot_callback, (3*HZ/10), 0);
970} 970}
971 971
972void card_enable_monitoring_target(bool on) 972void card_enable_monitoring_target(bool on)
973{ 973{
974 if (on) /* enable interrupt */ 974 if (on) /* enable interrupt */
975 GPIOA_IE |= (1<<2); 975 GPIOA_IE |= EXT_SD_BITS;
976 else /* disable interrupt */ 976 else /* disable interrupt */
977 GPIOA_IE &= ~(1<<2); 977 GPIOA_IE &= ~EXT_SD_BITS;
978} 978}
979#endif /* HAVE_HOTSWAP */ 979#endif /* HAVE_HOTSWAP */
980 980
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c
index 0b1884aa16..e3e41998ce 100644
--- a/firmware/target/arm/as3525/system-as3525.c
+++ b/firmware/target/arm/as3525/system-as3525.c
@@ -70,7 +70,8 @@ default_interrupt(RESERVED6); /* Interrupt 25 : unused */
70default_interrupt(RESERVED7); /* Interrupt 26 : unused */ 70default_interrupt(RESERVED7); /* Interrupt 26 : unused */
71default_interrupt(RESERVED8); /* Interrupt 27 : unused */ 71default_interrupt(RESERVED8); /* Interrupt 27 : unused */
72default_interrupt(RESERVED9); /* Interrupt 28 : unused */ 72default_interrupt(RESERVED9); /* Interrupt 28 : unused */
73default_interrupt(INT_GPIOA); 73/* INT_GPIOA is declared in this file */
74void INT_GPIOA(void);
74default_interrupt(INT_GPIOB); 75default_interrupt(INT_GPIOB);
75default_interrupt(INT_GPIOC); 76default_interrupt(INT_GPIOC);
76 77
@@ -144,6 +145,18 @@ static void setup_vic(void)
144 } 145 }
145} 146}
146 147
148void INT_GPIOA(void)
149{
150#ifdef HAVE_MULTIDRIVE
151 void sd_gpioa_isr(void);
152 sd_gpioa_isr();
153#endif
154#if (defined(HAVE_SCROLLWHEEL) && CONFIG_CPU != AS3525)
155 void button_gpioa_isr(void);
156 button_gpioa_isr();
157#endif
158}
159
147void irq_handler(void) 160void irq_handler(void)
148{ 161{
149 asm volatile( "stmfd sp!, {r0-r5,ip,lr} \n" /* Store context */ 162 asm volatile( "stmfd sp!, {r0-r5,ip,lr} \n" /* Store context */
@@ -348,6 +361,12 @@ void system_init(void)
348 ascodec_init(); 361 ascodec_init();
349 362
350#ifndef BOOTLOADER 363#ifndef BOOTLOADER
364 /* setup isr for microsd monitoring and for scrollwheel irq */
365#if defined(HAVE_MULTIDRIVE) || (defined(HAVE_SCROLLWHEEL) && CONFIG_CPU != AS3525)
366 VIC_INT_ENABLE = (INTERRUPT_GPIOA);
367 /* pin selection for irq happens in the drivers */
368#endif
369
351 /* Initialize power management settings */ 370 /* Initialize power management settings */
352 ascodec_write(AS3514_CVDD_DCDC3, AS314_CP_DCDC3_SETTING); 371 ascodec_write(AS3514_CVDD_DCDC3, AS314_CP_DCDC3_SETTING);
353#if CONFIG_TUNER 372#if CONFIG_TUNER
diff --git a/firmware/target/arm/as3525/system-target.h b/firmware/target/arm/as3525/system-target.h
index 1ccd3282db..d2cf99499d 100644
--- a/firmware/target/arm/as3525/system-target.h
+++ b/firmware/target/arm/as3525/system-target.h
@@ -27,7 +27,11 @@
27 27
28#include "clock-target.h" /* CPUFREQ_* are defined here */ 28#include "clock-target.h" /* CPUFREQ_* are defined here */
29 29
30#ifdef HAVE_SCROLLWHEEL 30/* We can use a interrupt-based mechanism on the fuzev2 */
31#define INCREASED_SCROLLWHEEL_POLLING \
32 (defined(HAVE_SCROLLWHEEL) && (CONFIG_CPU == AS3525))
33
34#if INCREASED_SCROLLWHEEL_POLLING
31/* let the timer interrupt twice as often for the scrollwheel polling */ 35/* let the timer interrupt twice as often for the scrollwheel polling */
32#define KERNEL_TIMER_FREQ (TIMER_FREQ/2) 36#define KERNEL_TIMER_FREQ (TIMER_FREQ/2)
33#else 37#else