summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc77x/m200
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tcc77x/m200')
-rw-r--r--firmware/target/arm/tcc77x/m200/adc-target.h26
-rw-r--r--firmware/target/arm/tcc77x/m200/backlight-target.h42
-rw-r--r--firmware/target/arm/tcc77x/m200/button-m200.c97
-rw-r--r--firmware/target/arm/tcc77x/m200/button-target.h52
-rw-r--r--firmware/target/arm/tcc77x/m200/power-m200.c66
5 files changed, 283 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/m200/adc-target.h b/firmware/target/arm/tcc77x/m200/adc-target.h
new file mode 100644
index 0000000000..96fb1e44aa
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/adc-target.h
@@ -0,0 +1,26 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
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 _ADC_TARGET_H_
20#define _ADC_TARGET_H_
21
22#define NUM_ADC_CHANNELS 8
23
24#define ADC_BUTTONS 1
25
26#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/m200/backlight-target.h b/firmware/target/arm/tcc77x/m200/backlight-target.h
new file mode 100644
index 0000000000..a54aa4686d
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/backlight-target.h
@@ -0,0 +1,42 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Dave Chapman
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 BACKLIGHT_TARGET_H
20#define BACKLIGHT_TARGET_H
21
22#include "tcc77x.h"
23
24static inline bool _backlight_init(void)
25{
26 GPIOA_DIR |= 0x40;
27 return true;
28}
29
30static inline void _backlight_on(void)
31{
32 /* Enable backlight */
33 GPIOA |= 0x40;
34}
35
36static inline void _backlight_off(void)
37{
38 /* Disable backlight */
39 GPIOA &= ~0x40;
40}
41
42#endif
diff --git a/firmware/target/arm/tcc77x/m200/button-m200.c b/firmware/target/arm/tcc77x/m200/button-m200.c
new file mode 100644
index 0000000000..fec745ae99
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/button-m200.c
@@ -0,0 +1,97 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Dave Chapman
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 "cpu.h"
22#include "button.h"
23#include "adc.h"
24
25/*
26
27Results of button testing (viewing ADC values whilst pressing buttons):
28
29HOLD: GPIOB & 0x0200 (0=hold active, 0x0200 = hold inactive)
30
31ADC[1]: (approx values)
32
33Idle - 0x3ff
34MENU - unknown
35
36REPEAT/AB - 0x03?
37LEFT - 0x07?-0x08?
38SELECT - 0x0c?
39RIGHT - 0x11?
40
41PLAY/PAUSE - 0x17?-0x018?
42VOL UP - 0x1e?-0x01f?
43VOL DOWN - 0x26?
44
45*/
46
47void button_init_device(void)
48{
49 /* Nothing to do */
50}
51
52int button_read_device(void)
53{
54 int btn = BUTTON_NONE;
55 int adc;
56
57 /* TODO - determine how to detect BUTTON_MENU - it doesn't appear to
58 be connected to a GPIO or to an ADC
59 */
60
61 adc = adc_read(ADC_BUTTONS);
62
63 if (adc < 0x384) {
64 if (adc < 0x140) {
65 if (adc < 0x96) {
66 if (adc < 0x50) {
67 btn |= BUTTON_REPEATAB; /* 0x00..0x4f */
68 } else {
69 btn |= BUTTON_LEFT; /* 0x50..0x95 */
70 }
71 } else {
72 if (adc < 0xe0) {
73 btn |= BUTTON_SELECT; /* 0x96..0xdf */
74 } else {
75 btn |= BUTTON_RIGHT; /* 0xe0..0x13f */
76 }
77 }
78 } else {
79 if (adc < 0x208) {
80 if (adc < 0x1b0) {
81 btn |= BUTTON_PLAYPAUSE; /* 0x140..0x1af */
82 } else {
83 btn |= BUTTON_VOLUP; /* 0x1b0..0x207 */
84 }
85 } else {
86 btn |= BUTTON_VOLDOWN; /* 0x209..0x383 */
87 }
88 }
89 }
90
91 return btn;
92}
93
94bool button_hold(void)
95{
96 return (GPIOB & 0x200)?false:true;
97}
diff --git a/firmware/target/arm/tcc77x/m200/button-target.h b/firmware/target/arm/tcc77x/m200/button-target.h
new file mode 100644
index 0000000000..da7c82e6b2
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/button-target.h
@@ -0,0 +1,52 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Dave Chapman
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#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26#define HAS_BUTTON_HOLD
27
28void button_init_device(void);
29int button_read_device(void);
30bool button_hold(void);
31
32/* Main unit's buttons */
33#define BUTTON_MENU 0x00000001
34#define BUTTON_VOLUP 0x00000002
35#define BUTTON_VOLDOWN 0x00000004
36#define BUTTON_PLAYPAUSE 0x00000008
37#define BUTTON_REPEATAB 0x00000010
38#define BUTTON_LEFT 0x00000020
39#define BUTTON_RIGHT 0x00000040
40#define BUTTON_SELECT 0x00000080
41
42#define BUTTON_MAIN (BUTTON_MENU|BUTTON_VOLUP|BUTTON_VOLDOWN\
43 |BUTTON_PLAYPAUSE|BUTTON_REPEATAB|BUTTON_LEFT\
44 |BUTTON_RIGHT|BUTTON_SELECT)
45
46#define BUTTON_REMOTE 0
47
48/* Software power-off */
49#define POWEROFF_BUTTON BUTTON_MENU
50#define POWEROFF_COUNT 40
51
52#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/m200/power-m200.c b/firmware/target/arm/tcc77x/m200/power-m200.c
new file mode 100644
index 0000000000..df2ee10d6b
--- /dev/null
+++ b/firmware/target/arm/tcc77x/m200/power-m200.c
@@ -0,0 +1,66 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
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 "cpu.h"
21#include <stdbool.h>
22#include "kernel.h"
23#include "system.h"
24#include "power.h"
25
26#ifndef SIMULATOR
27
28void power_init(void)
29{
30}
31
32void ide_power_enable(bool on)
33{
34}
35
36bool ide_powered(void)
37{
38 return true;
39}
40
41void power_off(void)
42{
43}
44
45#else /* SIMULATOR */
46
47bool charger_inserted(void)
48{
49 return false;
50}
51
52void charger_enable(bool on)
53{
54 (void)on;
55}
56
57void power_off(void)
58{
59}
60
61void ide_power_enable(bool on)
62{
63 (void)on;
64}
65
66#endif /* SIMULATOR */