summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Ankers <dan@weirdo.org.uk>2006-10-14 12:14:23 +0000
committerDaniel Ankers <dan@weirdo.org.uk>2006-10-14 12:14:23 +0000
commitd282e14d3328020679011983d6ad243a0295dda4 (patch)
treec17442c357925e9e7127215d54e6894c97782639
parent6aa12c11f741a4544d780d11fc583a25a5aef171 (diff)
downloadrockbox-d282e14d3328020679011983d6ad243a0295dda4.tar.gz
rockbox-d282e14d3328020679011983d6ad243a0295dda4.zip
Untested first attempt at a Sansa button driver. Based on work by MrH
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11219 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/button-e200.c82
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/button-target.h53
2 files changed, 132 insertions, 3 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/button-e200.c b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
new file mode 100644
index 0000000000..104c7517d8
--- /dev/null
+++ b/firmware/target/arm/sandisk/sansa-e200/button-e200.c
@@ -0,0 +1,82 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/* Taken from button-h10.c by Barry Wardell and reverse engineering by MrH. */
21
22#include <stdlib.h>
23#include "config.h"
24#include "cpu.h"
25#include "system.h"
26#include "button.h"
27#include "kernel.h"
28#include "backlight.h"
29#include "system.h"
30
31
32void button_init_device(void)
33{
34 /* Enable all buttons except the wheel */
35 GPIOF_ENABLE |= 0xff;
36}
37
38bool button_hold(void)
39{
40 return (GPIOF_INPUT_VAL & 0x80)?true:false;
41}
42
43/*
44 * Get button pressed from hardware
45 */
46int button_read_device(void)
47{
48 int btn = BUTTON_NONE;
49 unsigned char state;
50 static bool hold_button = false;
51 bool hold_button_old;
52
53 /* Hold */
54 hold_button_old = hold_button;
55 hold_button = button_hold();
56
57#if 0
58#ifndef BOOTLOADER
59 /* light handling */
60 if (hold_button != hold_button_old)
61 {
62 backlight_hold_changed(hold_button);
63 }
64#endif
65#endif
66
67 /* device buttons */
68 if (!hold_button)
69 {
70 /* Read normal buttons */
71 state = GPIOF_INPUT_VAL & 0xff;
72 if ((state & 0x1) == 0) btn |= BUTTON_REC;
73 if ((state & 0x2) == 0) btn |= BUTTON_DOWN;
74 if ((state & 0x4) == 0) btn |= BUTTON_RIGHT;
75 if ((state & 0x8) == 0) btn |= BUTTON_LEFT;
76 if ((state & 0x10) == 0) btn |= BUTTON_SELECT; /* The centre button */
77 if ((state & 0x20) == 0) btn |= BUTTON_UP; /* The "play" button */
78 if ((state & 0x40) == 1) btn |= BUTTON_POWER;
79 }
80
81 return btn;
82}
diff --git a/firmware/target/arm/sandisk/sansa-e200/button-target.h b/firmware/target/arm/sandisk/sansa-e200/button-target.h
index e78f91a154..6ddf466452 100644
--- a/firmware/target/arm/sandisk/sansa-e200/button-target.h
+++ b/firmware/target/arm/sandisk/sansa-e200/button-target.h
@@ -1,7 +1,54 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
1 19
2#define BUTTON_POWER 0x00000001 20#ifndef _BUTTON_TARGET_H_
3#define BUTTON_LEFT 0x00000002 21#define _BUTTON_TARGET_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26#define HAS_BUTTON_HOLD
27
28bool button_hold(void);
29void button_init_device(void);
30int button_read_device(void);
31
32/* Sandisk Sansa E200 button codes */
33
34/* Main unit's buttons */
35#define BUTTON_REC 0x00000001
36#define BUTTON_STOP 0x00000002
4#define BUTTON_RIGHT 0x00000004 37#define BUTTON_RIGHT 0x00000004
38#define BUTTON_LEFT 0x00000008
39#define BUTTON_SELECT 0x00000010
40#define BUTTON_PLAY 0x00000020
41#define BUTTON_POWER 0x00000040
42
43#define BUTTON_UP 0x00000080
44#define BUTTON_DOWN 0x00000100
45
46#define BUTTON_MAIN 0x00000fff
47
48/* No Remote control */
49#define BUTTON_REMOTE 0
5 50
6#define POWEROFF_BUTTON BUTTON_POWER 51#define POWEROFF_BUTTON BUTTON_POWER
7#define POWEROFF_COUNT 40 52#define POWEROFF_COUNT 10
53
54#endif /* _BUTTON_TARGET_H_ */