diff options
author | Dave Chapman <dave@dchapman.com> | 2007-11-01 23:38:57 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2007-11-01 23:38:57 +0000 |
commit | a4d48d0c0dabb3e78e6b1dc31c023627ce924ce1 (patch) | |
tree | 23210360f876d7c962368a85f81c909824e2a7e1 /firmware/target/arm/tcc77x/logikdax/button-logikdax.c | |
parent | 80e4d671d2271c8a6a3ec463c277fcf7b3fa3ab9 (diff) | |
download | rockbox-a4d48d0c0dabb3e78e6b1dc31c023627ce924ce1.tar.gz rockbox-a4d48d0c0dabb3e78e6b1dc31c023627ce924ce1.zip |
Button driver for Logik DAX, plus some changes to the debug info displayed in the bootloader build.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15396 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tcc77x/logikdax/button-logikdax.c')
-rw-r--r-- | firmware/target/arm/tcc77x/logikdax/button-logikdax.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/logikdax/button-logikdax.c b/firmware/target/arm/tcc77x/logikdax/button-logikdax.c new file mode 100644 index 0000000000..8e4279b699 --- /dev/null +++ b/firmware/target/arm/tcc77x/logikdax/button-logikdax.c | |||
@@ -0,0 +1,98 @@ | |||
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 | |||
27 | Results of button testing: | ||
28 | |||
29 | HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released) | ||
30 | POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released) | ||
31 | |||
32 | ADC[0]: (approx values) | ||
33 | |||
34 | RIGHT - 0x37 | ||
35 | LEFT - 0x7f | ||
36 | JOYSTICK PRESS - 0xc7 | ||
37 | UP - 0x11e | ||
38 | DOWN - 0x184 | ||
39 | MODE - 0x1f0/0x1ff | ||
40 | PRESET - 0x268/0x269 | ||
41 | REC - 0x2dd | ||
42 | |||
43 | Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384 | ||
44 | |||
45 | */ | ||
46 | |||
47 | void button_init_device(void) | ||
48 | { | ||
49 | /* Nothing to do */ | ||
50 | } | ||
51 | |||
52 | int button_read_device(void) | ||
53 | { | ||
54 | int btn = BUTTON_NONE; | ||
55 | int adc; | ||
56 | |||
57 | adc = adc_read(ADC_BUTTONS); | ||
58 | |||
59 | if (adc < 0x384) { | ||
60 | if (adc < 0x140) { | ||
61 | if (adc < 0x96) { | ||
62 | if (adc < 0x50) { | ||
63 | btn |= BUTTON_RIGHT; /* 0x00..0x4f */ | ||
64 | } else { | ||
65 | btn |= BUTTON_LEFT; /* 0x50..0x95 */ | ||
66 | } | ||
67 | } else { | ||
68 | if (adc < 0xe0) { | ||
69 | btn |= BUTTON_SELECT; /* 0x96..0xdf */ | ||
70 | } else { | ||
71 | btn |= BUTTON_UP; /* 0xe0..0x13f */ | ||
72 | } | ||
73 | } | ||
74 | } else { | ||
75 | if (adc < 0x208) { | ||
76 | if (adc < 0x1b0) { | ||
77 | btn |= BUTTON_DOWN; /* 0x140..0x1af */ | ||
78 | } else { | ||
79 | btn |= BUTTON_MODE; /* 0x1b0..0x207 */ | ||
80 | } | ||
81 | } else { | ||
82 | if (adc < 0x290) { | ||
83 | btn |= BUTTON_PRESET; /* 0x208..0x28f */ | ||
84 | } else { | ||
85 | btn |= BUTTON_REC; /* 0x290..0x383 */ | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | if (!(GPIOA & 0x2)) | ||
92 | btn |= BUTTON_HOLD; | ||
93 | |||
94 | if (!(GPIOA & 0x8000)) | ||
95 | btn |= BUTTON_POWERPLAY; | ||
96 | |||
97 | return btn; | ||
98 | } | ||