summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-07-27 13:27:31 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-07-27 13:27:31 +0000
commitc849219370fd65be2167a24a9f06f03bc1284ac1 (patch)
treef86aecea35281ccd42a180c2a92a4b17fecfbcfc /firmware/target
parent81537d49dfa871bbdd4cd83fee292b290ff3c980 (diff)
downloadrockbox-c849219370fd65be2167a24a9f06f03bc1284ac1.zip
rockbox-c849219370fd65be2167a24a9f06f03bc1284ac1.tar.gz
rockbox-c849219370fd65be2167a24a9f06f03bc1284ac1.tar.bz2
rockbox-c849219370fd65be2167a24a9f06f03bc1284ac1.tar.xz
Moved the X5 button driver to the target tree
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10339 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/button-target.h70
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/button-x5.c131
2 files changed, 201 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/button-target.h b/firmware/target/coldfire/iaudio/x5/button-target.h
new file mode 100755
index 0000000..998522f
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/x5/button-target.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Linus Nielsen Feltzing
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _BUTTON_TARGET_H_
+#define _BUTTON_TARGET_H_
+
+#include <stdbool.h>
+#include "config.h"
+
+#define HAS_BUTTON_HOLD
+#define HAS_REMOTE_BUTTON_HOLD
+
+bool button_hold(void);
+bool remote_button_hold(void);
+void button_init_device(void);
+int button_read_device(void);
+
+/* iaudio X5 specific button codes */
+
+ /* Main unit's buttons */
+#define BUTTON_POWER 0x00000001
+#define BUTTON_REC 0x00000002
+
+#define BUTTON_LEFT 0x00000004
+#define BUTTON_RIGHT 0x00000008
+#define BUTTON_UP 0x00000010
+#define BUTTON_DOWN 0x00000020
+
+#define BUTTON_PLAY 0x00000040
+#define BUTTON_SELECT 0x00000080
+
+#define BUTTON_MAIN (BUTTON_POWER|BUTTON_PLAY|BUTTON_LEFT|BUTTON_RIGHT\
+ |BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_SELECT)
+
+ /* Remote control's buttons */
+#define BUTTON_RC_PLAY 0x00100000
+
+#define BUTTON_RC_REW 0x00080000
+#define BUTTON_RC_FF 0x00040000
+#define BUTTON_RC_VOL_UP 0x00020000
+#define BUTTON_RC_VOL_DOWN 0x00010000
+
+#define BUTTON_RC_REC 0x00008000
+#define BUTTON_RC_MENU 0x00004000
+
+#define BUTTON_RC_MODE 0x00002000
+
+#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN\
+ |BUTTON_RC_REW|BUTTON_RC_FF\
+ |BUTTON_RC_REC|BUTTON_RC_MENU|BUTTON_RC_MODE)
+
+#define POWEROFF_BUTTON BUTTON_POWER
+#define POWEROFF_COUNT 10
+
+#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/coldfire/iaudio/x5/button-x5.c b/firmware/target/coldfire/iaudio/x5/button-x5.c
new file mode 100755
index 0000000..07bc7bf
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/x5/button-x5.c
@@ -0,0 +1,131 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Linus Nielsen Feltzing
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include "config.h"
+#include "cpu.h"
+#include "system.h"
+#include "button.h"
+#include "kernel.h"
+#include "backlight.h"
+#include "adc.h"
+#include "system.h"
+
+void button_init_device(void)
+{
+ /* Power, Remote Play & Hold switch */
+ GPIO_FUNCTION |= 0x0e000000;
+ GPIO_ENABLE &= ~0x0e000000;
+}
+
+bool button_hold(void)
+{
+ return (GPIO_READ & 0x08000000)?false:true;
+}
+
+bool remote_button_hold(void)
+{
+ return false; /* TODO X5 */
+}
+
+int button_read_device(void)
+{
+ int data;
+ int btn = BUTTON_NONE;
+ static bool hold_button = false;
+ static bool remote_hold_button = false;
+
+ /* backlight handling */
+ if (hold_button && !button_hold())
+ {
+ backlight_on();
+ }
+ /* TODO: add light handling for the remote */
+
+ hold_button = button_hold();
+ remote_hold_button = remote_button_hold();
+
+ /* normal buttons */
+ if (!hold_button)
+ {
+ data = adc_scan(ADC_BUTTONS);
+ if (data < 0xf0)
+ {
+ if(data < 0x7c)
+ if(data < 0x42)
+ btn = BUTTON_LEFT;
+ else
+ if(data < 0x62)
+ btn = BUTTON_RIGHT;
+ else
+ btn = BUTTON_SELECT;
+ else
+ if(data < 0xb6)
+ if(data < 0x98)
+ btn = BUTTON_REC;
+ else
+ btn = BUTTON_PLAY;
+ else
+ if(data < 0xd3)
+ btn = BUTTON_DOWN;
+ else
+ btn = BUTTON_UP;
+ }
+ }
+
+ /* remote buttons */
+ data = adc_scan(ADC_REMOTE);
+ if(data < 0x17)
+ remote_hold_button = true;
+
+ if(!remote_hold_button)
+ {
+ if (data < 0xee)
+ {
+ if(data < 0x7a)
+ if(data < 0x41)
+ btn |= BUTTON_RC_REW;
+ else
+ if(data < 0x61)
+ btn |= BUTTON_RC_FF;
+ else
+ btn |= BUTTON_RC_MODE;
+ else
+ if(data < 0xb4)
+ if(data < 0x96)
+ btn |= BUTTON_RC_REC;
+ else
+ btn |= BUTTON_RC_MENU;
+ else
+ if(data < 0xd1)
+ btn |= BUTTON_RC_VOL_UP;
+ else
+ btn |= BUTTON_RC_VOL_DOWN;
+ }
+ }
+
+ data = GPIO_READ;
+ if (!(data & 0x04000000))
+ btn |= BUTTON_POWER;
+
+ if (!(data & 0x02000000))
+ btn |= BUTTON_RC_PLAY;
+
+ return btn;
+}