summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio
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/coldfire/iaudio
parent81537d49dfa871bbdd4cd83fee292b290ff3c980 (diff)
downloadrockbox-c849219370fd65be2167a24a9f06f03bc1284ac1.tar.gz
rockbox-c849219370fd65be2167a24a9f06f03bc1284ac1.zip
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/coldfire/iaudio')
-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 0000000000..998522fe15
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/x5/button-target.h
@@ -0,0 +1,70 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Linus Nielsen Feltzing
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#ifndef _BUTTON_TARGET_H_
20#define _BUTTON_TARGET_H_
21
22#include <stdbool.h>
23#include "config.h"
24
25#define HAS_BUTTON_HOLD
26#define HAS_REMOTE_BUTTON_HOLD
27
28bool button_hold(void);
29bool remote_button_hold(void);
30void button_init_device(void);
31int button_read_device(void);
32
33/* iaudio X5 specific button codes */
34
35 /* Main unit's buttons */
36#define BUTTON_POWER 0x00000001
37#define BUTTON_REC 0x00000002
38
39#define BUTTON_LEFT 0x00000004
40#define BUTTON_RIGHT 0x00000008
41#define BUTTON_UP 0x00000010
42#define BUTTON_DOWN 0x00000020
43
44#define BUTTON_PLAY 0x00000040
45#define BUTTON_SELECT 0x00000080
46
47#define BUTTON_MAIN (BUTTON_POWER|BUTTON_PLAY|BUTTON_LEFT|BUTTON_RIGHT\
48 |BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_SELECT)
49
50 /* Remote control's buttons */
51#define BUTTON_RC_PLAY 0x00100000
52
53#define BUTTON_RC_REW 0x00080000
54#define BUTTON_RC_FF 0x00040000
55#define BUTTON_RC_VOL_UP 0x00020000
56#define BUTTON_RC_VOL_DOWN 0x00010000
57
58#define BUTTON_RC_REC 0x00008000
59#define BUTTON_RC_MENU 0x00004000
60
61#define BUTTON_RC_MODE 0x00002000
62
63#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN\
64 |BUTTON_RC_REW|BUTTON_RC_FF\
65 |BUTTON_RC_REC|BUTTON_RC_MENU|BUTTON_RC_MODE)
66
67#define POWEROFF_BUTTON BUTTON_POWER
68#define POWEROFF_COUNT 10
69
70#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 0000000000..07bc7bf3f7
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/x5/button-x5.c
@@ -0,0 +1,131 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Linus Nielsen Feltzing
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#include <stdlib.h>
21#include "config.h"
22#include "cpu.h"
23#include "system.h"
24#include "button.h"
25#include "kernel.h"
26#include "backlight.h"
27#include "adc.h"
28#include "system.h"
29
30void button_init_device(void)
31{
32 /* Power, Remote Play & Hold switch */
33 GPIO_FUNCTION |= 0x0e000000;
34 GPIO_ENABLE &= ~0x0e000000;
35}
36
37bool button_hold(void)
38{
39 return (GPIO_READ & 0x08000000)?false:true;
40}
41
42bool remote_button_hold(void)
43{
44 return false; /* TODO X5 */
45}
46
47int button_read_device(void)
48{
49 int data;
50 int btn = BUTTON_NONE;
51 static bool hold_button = false;
52 static bool remote_hold_button = false;
53
54 /* backlight handling */
55 if (hold_button && !button_hold())
56 {
57 backlight_on();
58 }
59 /* TODO: add light handling for the remote */
60
61 hold_button = button_hold();
62 remote_hold_button = remote_button_hold();
63
64 /* normal buttons */
65 if (!hold_button)
66 {
67 data = adc_scan(ADC_BUTTONS);
68 if (data < 0xf0)
69 {
70 if(data < 0x7c)
71 if(data < 0x42)
72 btn = BUTTON_LEFT;
73 else
74 if(data < 0x62)
75 btn = BUTTON_RIGHT;
76 else
77 btn = BUTTON_SELECT;
78 else
79 if(data < 0xb6)
80 if(data < 0x98)
81 btn = BUTTON_REC;
82 else
83 btn = BUTTON_PLAY;
84 else
85 if(data < 0xd3)
86 btn = BUTTON_DOWN;
87 else
88 btn = BUTTON_UP;
89 }
90 }
91
92 /* remote buttons */
93 data = adc_scan(ADC_REMOTE);
94 if(data < 0x17)
95 remote_hold_button = true;
96
97 if(!remote_hold_button)
98 {
99 if (data < 0xee)
100 {
101 if(data < 0x7a)
102 if(data < 0x41)
103 btn |= BUTTON_RC_REW;
104 else
105 if(data < 0x61)
106 btn |= BUTTON_RC_FF;
107 else
108 btn |= BUTTON_RC_MODE;
109 else
110 if(data < 0xb4)
111 if(data < 0x96)
112 btn |= BUTTON_RC_REC;
113 else
114 btn |= BUTTON_RC_MENU;
115 else
116 if(data < 0xd1)
117 btn |= BUTTON_RC_VOL_UP;
118 else
119 btn |= BUTTON_RC_VOL_DOWN;
120 }
121 }
122
123 data = GPIO_READ;
124 if (!(data & 0x04000000))
125 btn |= BUTTON_POWER;
126
127 if (!(data & 0x02000000))
128 btn |= BUTTON_RC_PLAY;
129
130 return btn;
131}