summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2008-10-25 15:57:18 +0000
committerDominik Wenger <domonoky@googlemail.com>2008-10-25 15:57:18 +0000
commit3ae419d9557e7db0312407bcda29237d31e6b4be (patch)
treee21f4474d7e2b66ceab3357ab209955e0f7ed084 /firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c
parentb208000c3649526d0eeb73a328e4052759bc773c (diff)
downloadrockbox-3ae419d9557e7db0312407bcda29237d31e6b4be.tar.gz
rockbox-3ae419d9557e7db0312407bcda29237d31e6b4be.tar.bz2
rockbox-3ae419d9557e7db0312407bcda29237d31e6b4be.zip
fill in button and backlight functions for m200 "v2"
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18874 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c')
-rw-r--r--firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c60
1 files changed, 55 insertions, 5 deletions
diff --git a/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c b/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c
index cd31d06720..c5d6c4941d 100644
--- a/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c
+++ b/firmware/target/arm/as3525/sansa-m200v2/button-m200v2.c
@@ -26,18 +26,68 @@
void button_init_device(void)
{
-
+ GPIOA_DIR &= ~((1<<3) | (1<<2) | (1<<1) | (1<<0)); /* A3-A0 is input */
+ GPIOA_DIR |= ((1<<6) | (1<<5) | (1<<4)); /* A4-A6 row outputs */
}
int button_read_device(void)
{
- int btn = BUTTON_NONE;
+ int result = BUTTON_NONE;
+
+ /* direct GPIO connections */
+ if (GPIOA_PIN(3))
+ result |= BUTTON_MENU;
+
+ /* This is a keypad using A4-A6 as columns and A0-A2 as rows */
+ GPIOA_PIN(4) = (1<<4);
+
+ /* A4A0 is unused */
+
+ if (GPIOA_PIN(1))
+ result |= BUTTON_VOLDOWN;
+
+ if (GPIOA_PIN(2))
+ result |= BUTTON_PLAYPAUSE;
+
+ GPIOA_PIN(4) = 0x00;
+
+ GPIOA_PIN(5) = (1<<5);
+
+ if (GPIOA_PIN(0))
+ result |= BUTTON_LEFT;
+
+ if (GPIOA_PIN(1))
+ result |= BUTTON_SELECT;
+
+ if (GPIOA_PIN(2))
+ result |= BUTTON_RIGHT;
+
+ GPIOA_PIN(5) = 0x00;
+
+
+ GPIOA_PIN(6) = (1<<6);
+
+ if (GPIOA_PIN(0))
+ result |= BUTTON_REPEATAB;
+
+ if (GPIOA_PIN(1))
+ result |= BUTTON_VOLUP;
+
+ if (GPIOA_PIN(2))
+ result |= BUTTON_HOLD;
+ GPIOA_PIN(6) = 0x00;
- return btn;
+ return result;
}
bool button_hold(void)
{
- /* TODO */
- return false;
+ bool ret = false;
+
+ GPIOA_PIN(6) = (1<<6);
+ if (GPIOA_PIN(2))
+ ret = true;
+ GPIOA_PIN(6) = 0x00;
+
+ return ret;
}