diff options
Diffstat (limited to 'firmware/target/arm/tatung/tpj1022/button-tpj1022.c')
-rw-r--r-- | firmware/target/arm/tatung/tpj1022/button-tpj1022.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/firmware/target/arm/tatung/tpj1022/button-tpj1022.c b/firmware/target/arm/tatung/tpj1022/button-tpj1022.c new file mode 100644 index 0000000000..f0b338c1c1 --- /dev/null +++ b/firmware/target/arm/tatung/tpj1022/button-tpj1022.c | |||
@@ -0,0 +1,83 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | /* Custom written for the TPJ-1022 based on analysis of the GPIO data */ | ||
21 | |||
22 | #include <stdlib.h> | ||
23 | #include "config.h" | ||
24 | #include "cpu.h" | ||
25 | #include "system.h" | ||
26 | #include "button.h" | ||
27 | #include "kernel.h" | ||
28 | #include "backlight.h" | ||
29 | #include "adc.h" | ||
30 | #include "system.h" | ||
31 | |||
32 | void button_init_device(void) | ||
33 | { | ||
34 | /* No hardware initialisation required as it is done by the bootloader */ | ||
35 | } | ||
36 | |||
37 | bool button_hold(void) | ||
38 | { | ||
39 | return false; | ||
40 | } | ||
41 | |||
42 | /* | ||
43 | * Get button pressed from hardware | ||
44 | */ | ||
45 | int button_read_device(void) | ||
46 | { | ||
47 | int btn = BUTTON_NONE; | ||
48 | unsigned char state; | ||
49 | static bool hold_button = false; | ||
50 | |||
51 | #if 0 | ||
52 | /* light handling */ | ||
53 | if (hold_button && !button_hold()) | ||
54 | { | ||
55 | backlight_on(); | ||
56 | } | ||
57 | #endif | ||
58 | |||
59 | hold_button = button_hold(); | ||
60 | if (!hold_button) | ||
61 | { | ||
62 | /* Read normal buttons */ | ||
63 | state = GPIOA_INPUT_VAL; | ||
64 | if ((state & 0x2) == 0) btn |= BUTTON_REW; | ||
65 | if ((state & 0x4) == 0) btn |= BUTTON_FF; | ||
66 | if ((state & 0x80) == 0) btn |= BUTTON_RIGHT; | ||
67 | |||
68 | /* Buttons left to figure out: | ||
69 | button_hold() | ||
70 | BUTTON_POWER | ||
71 | BUTTON_LEFT | ||
72 | BUTTON_UP | ||
73 | BUTTON_DOWN | ||
74 | BUTTON_MENU | ||
75 | BUTTON_REC | ||
76 | BUTTON_AB | ||
77 | BUTTON_PLUS | ||
78 | BUTTON_MINUS | ||
79 | */ | ||
80 | } | ||
81 | |||
82 | return btn; | ||
83 | } | ||