summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-03-29 23:03:06 +0000
committerThomas Martitz <kugel@rockbox.org>2010-03-29 23:03:06 +0000
commit71393c701c319e7b78ee81b6a8f0cc9830e88e2a (patch)
tree928f45da8e69436a5f74cd014f68b410e0a8d1fc
parenta4c68705593aa89752a8e913e83d17b7f5520f78 (diff)
downloadrockbox-71393c701c319e7b78ee81b6a8f0cc9830e88e2a.tar.gz
rockbox-71393c701c319e7b78ee81b6a8f0cc9830e88e2a.zip
Fuzev2: Preliminary button support. Scrollwheel does not work yet.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25392 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c94
1 files changed, 92 insertions, 2 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
index 287e159e53..5bd8afebc1 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -22,7 +22,15 @@
#include "config.h"
#include "system.h"
#include "button.h"
+#include "backlight.h"
+/*
+ * TODO: Scrollwheel!
+ */
+
+#ifdef HAS_BUTTON_HOLD
+static bool hold_button = false;
+#endif
void button_init_device(void)
{
}
@@ -30,12 +38,94 @@ void button_init_device(void)
/*
* Get button pressed from hardware
*/
+
int button_read_device(void)
{
- return 0;
+ int btn = 0;
+ volatile int delay;
+ static bool hold_button_old = false;
+ static long power_counter = 0;
+ unsigned gpiod = GPIOD_DATA;
+ unsigned gpioa_dir = GPIOA_DIR;
+ unsigned gpiod6;
+ for(delay = 500; delay; delay--) nop;
+ CCU_IO &= ~(1<<12);
+ for(delay=8;delay;delay--) nop;
+ GPIOB_DIR |= 1<<3;
+ GPIOB_PIN(3) = 1<<3;
+ GPIOC_DIR = 0;
+ GPIOB_DIR &= ~(1<<1);
+ GPIOB_DIR |= 1<<0;
+ GPIOB_PIN(0) = 1;
+ for(delay = 500; delay; delay--)
+ nop;
+ gpiod6 = GPIOD_PIN(6);
+ GPIOB_PIN(0) = 0;
+ for(delay = 240; delay; delay--)
+ nop;
+ GPIOD_DIR = 0xff;
+ GPIOA_DIR &= ~(1<<6|1<<7);
+ GPIOD_DATA = 0;
+ GPIOD_DIR = 0;
+ if (GPIOC_PIN(1) & 1<<1)
+ btn |= BUTTON_DOWN;
+ if (GPIOC_PIN(2) & 1<<2)
+ btn |= BUTTON_UP;
+ if (GPIOC_PIN(3) & 1<<3)
+ btn |= BUTTON_LEFT;
+ if (GPIOC_PIN(4) & 1<<4)
+ btn |= BUTTON_SELECT;
+ if (GPIOC_PIN(5) & 1<<5)
+ btn |= BUTTON_RIGHT;
+ if (GPIOB_PIN(1) & 1<<1)
+ btn |= BUTTON_HOME;
+ if (gpiod6 & 1<<6)
+ { /* power/hold is on the same pin. we know it's hold if the bit isn't
+ * set now anymore */
+ if (GPIOD_PIN(6) & 1<<6)
+ {
+ hold_button = false;
+ btn |= BUTTON_POWER;
+ }
+ else
+ {
+ hold_button = true;
+ }
+ }
+
+ GPIOD_DIR = 0xff;
+ GPIOD_DATA = gpiod;
+ GPIOA_DIR = gpioa_dir;
+ GPIOD_DIR = 0;
+ CCU_IO |= 1<<12;
+#ifdef HAS_BUTTON_HOLD
+ /* light handling */
+ if (hold_button != hold_button_old)
+ {
+ hold_button_old = hold_button;
+ backlight_hold_changed(hold_button);
+ }
+ if (hold_button)
+ {
+ power_counter = HZ;
+ return 0;
+ }
+ /* read power, but not if hold button was just released, since
+ * you basically always hit power due to the slider mechanism after releasing
+ * (fuze only)
+ */
+ else if (power_counter > 0)
+ {
+ power_counter--;
+ btn &= ~BUTTON_POWER;
+ }
+#endif
+ return btn;
}
+#ifdef HAS_BUTTON_HOLD
bool button_hold(void)
{
- return false;
+ return hold_button;
}
+#endif