summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio/m3/button-m3.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/iaudio/m3/button-m3.c')
-rw-r--r--firmware/target/coldfire/iaudio/m3/button-m3.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iaudio/m3/button-m3.c b/firmware/target/coldfire/iaudio/m3/button-m3.c
new file mode 100644
index 0000000000..1a27af93f5
--- /dev/null
+++ b/firmware/target/coldfire/iaudio/m3/button-m3.c
@@ -0,0 +1,101 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Jens Arnold
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 "config.h"
21#include "system.h"
22#include "button.h"
23#include "backlight.h"
24#include "adc.h"
25
26static bool hold_button = false;
27static bool remote_hold_button = false;
28
29void button_init_device(void)
30{
31 /* Remote Play */
32 GPIO_FUNCTION |= 0x80000000;
33 GPIO_ENABLE &= ~0x80000000;
34}
35
36bool button_hold(void)
37{
38 return (GPIO1_READ & 0x00000200) == 0;
39}
40
41bool remote_button_hold(void)
42{
43 return remote_hold_button;
44}
45
46int button_read_device(void)
47{
48 int btn = BUTTON_NONE;
49 bool hold_button_old;
50 bool remote_hold_button_old;
51 int data = 0xff; /* FIXME */
52
53 /* normal buttons */
54 hold_button_old = hold_button;
55 hold_button = button_hold();
56
57#ifndef BOOTLOADER
58 /* give BL notice if HB state chaged */
59 if (hold_button != hold_button_old)
60 backlight_hold_changed(hold_button);
61#endif
62
63 if (!hold_button)
64 {
65#if 0 /* TODO: implement ADC */
66 data = adc_scan(ADC_BUTTONS);
67
68 if (data < 0xf0)
69 {
70 }
71#endif
72 if (!(GPIO1_READ & 0x00000002))
73 btn |= BUTTON_PLAY;
74 }
75
76 /* remote buttons */
77#if 0 /* TODO: implement ADC */
78 data = remote_detect() ? adc_scan(ADC_REMOTE) : 0xff;
79#endif
80
81 remote_hold_button_old = remote_hold_button;
82 remote_hold_button = data < 0x17;
83
84#ifndef BOOTLOADER
85 if (remote_hold_button != remote_hold_button_old)
86 remote_backlight_hold_changed(remote_hold_button);
87#endif
88
89 if (!remote_hold_button)
90 {
91#if 0 /* TODO: implement ADC */
92 if (data < 0xee)
93 {
94 }
95#endif
96 if ((GPIO_READ & 0x80000000) == 0)
97 btn |= BUTTON_RC_PLAY;
98 }
99
100 return btn;
101}