diff options
author | Jens Arnold <amiconn@rockbox.org> | 2007-03-05 00:04:00 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2007-03-05 00:04:00 +0000 |
commit | 8876018d25c6a56cce118482c1372bbff344cb23 (patch) | |
tree | a66dca10bf92674c655b9862fd366ecc77bba76a /firmware/target/coldfire/iaudio/m5/button-m5.c | |
parent | ee07215d506def8d3483f4adf6e1d4ae51c10c52 (diff) | |
download | rockbox-8876018d25c6a56cce118482c1372bbff344cb23.tar.gz rockbox-8876018d25c6a56cce118482c1372bbff344cb23.zip |
Bring up the M5 port to a working stage: Extended numerous explicit checks for IAUDIO_X5 to also check for IAUDIO_M5, moved code around the target tree, added preliminary background for the sim.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12610 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/iaudio/m5/button-m5.c')
-rw-r--r-- | firmware/target/coldfire/iaudio/m5/button-m5.c | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/m5/button-m5.c b/firmware/target/coldfire/iaudio/m5/button-m5.c new file mode 100644 index 0000000000..a5fdd79fde --- /dev/null +++ b/firmware/target/coldfire/iaudio/m5/button-m5.c | |||
@@ -0,0 +1,151 @@ | |||
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 | #include "config.h" | ||
20 | #include "system.h" | ||
21 | #include "button.h" | ||
22 | #include "backlight.h" | ||
23 | #include "adc.h" | ||
24 | #include "lcd-remote-target.h" | ||
25 | |||
26 | /* have buttons scan by default */ | ||
27 | static bool button_scan_on = true; | ||
28 | static bool hold_button = false; | ||
29 | static bool remote_hold_button = false; | ||
30 | |||
31 | void button_init_device(void) | ||
32 | { | ||
33 | /* Power, Remote Play & Hold switch */ | ||
34 | GPIO_FUNCTION |= 0x0e000000; | ||
35 | GPIO_ENABLE &= ~0x0e000000; | ||
36 | } | ||
37 | |||
38 | void button_enable_scan(bool enable) | ||
39 | { | ||
40 | button_scan_on = enable; | ||
41 | } | ||
42 | |||
43 | bool button_scan_enabled(void) | ||
44 | { | ||
45 | return button_scan_on; | ||
46 | } | ||
47 | |||
48 | bool button_hold(void) | ||
49 | { | ||
50 | return (GPIO_READ & 0x08000000) == 0; | ||
51 | } | ||
52 | |||
53 | bool remote_button_hold(void) | ||
54 | { | ||
55 | return remote_hold_button; | ||
56 | } | ||
57 | |||
58 | int button_read_device(void) | ||
59 | { | ||
60 | int btn = BUTTON_NONE; | ||
61 | bool hold_button_old; | ||
62 | bool remote_hold_button_old; | ||
63 | int data; | ||
64 | |||
65 | /* normal buttons */ | ||
66 | hold_button_old = hold_button; | ||
67 | hold_button = button_hold(); | ||
68 | |||
69 | #ifndef BOOTLOADER | ||
70 | /* give BL notice if HB state chaged */ | ||
71 | if (hold_button != hold_button_old) | ||
72 | backlight_hold_changed(hold_button); | ||
73 | #endif | ||
74 | |||
75 | if (button_scan_on && !hold_button) | ||
76 | { | ||
77 | data = adc_scan(ADC_BUTTONS); | ||
78 | |||
79 | if (data < 0xf0) | ||
80 | { | ||
81 | if(data < 0x7c) | ||
82 | if(data < 0x42) | ||
83 | btn = BUTTON_LEFT; | ||
84 | else | ||
85 | if(data < 0x62) | ||
86 | btn = BUTTON_RIGHT; | ||
87 | else | ||
88 | btn = BUTTON_SELECT; | ||
89 | else | ||
90 | if(data < 0xb6) | ||
91 | if(data < 0x98) | ||
92 | btn = BUTTON_PLAY; | ||
93 | else | ||
94 | btn = BUTTON_REC; | ||
95 | else | ||
96 | if(data < 0xd3) | ||
97 | btn = BUTTON_DOWN; | ||
98 | else | ||
99 | btn = BUTTON_UP; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | /* remote buttons */ | ||
104 | data = remote_detect() ? adc_scan(ADC_REMOTE) : 0xff; | ||
105 | |||
106 | remote_hold_button_old = remote_hold_button; | ||
107 | remote_hold_button = data < 0x17; | ||
108 | |||
109 | #ifndef BOOTLOADER | ||
110 | if (remote_hold_button != remote_hold_button_old) | ||
111 | remote_backlight_hold_changed(remote_hold_button); | ||
112 | #endif | ||
113 | |||
114 | if (!remote_hold_button) | ||
115 | { | ||
116 | if (data < 0xee) | ||
117 | { | ||
118 | if(data < 0x7a) | ||
119 | if(data < 0x41) | ||
120 | btn |= BUTTON_RC_FF; | ||
121 | else | ||
122 | if(data < 0x61) | ||
123 | btn |= BUTTON_RC_REW; | ||
124 | else | ||
125 | btn |= BUTTON_RC_MODE; | ||
126 | else | ||
127 | if(data < 0xb4) | ||
128 | if(data < 0x96) | ||
129 | btn |= BUTTON_RC_REC; | ||
130 | else | ||
131 | btn |= BUTTON_RC_MENU; | ||
132 | else | ||
133 | if(data < 0xd1) | ||
134 | btn |= BUTTON_RC_VOL_UP; | ||
135 | else | ||
136 | btn |= BUTTON_RC_VOL_DOWN; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | data = GPIO_READ; | ||
141 | |||
142 | /* hold and power are mutually exclusive */ | ||
143 | if (!(data & 0x04000000)) | ||
144 | btn |= BUTTON_POWER; | ||
145 | |||
146 | /* remote play button should be dead if hold */ | ||
147 | if (!remote_hold_button && !(data & 0x02000000)) | ||
148 | btn |= BUTTON_RC_PLAY; | ||
149 | |||
150 | return btn; | ||
151 | } | ||