diff options
Diffstat (limited to 'firmware/target/arm/iriver/h10/button-h10.c')
-rw-r--r-- | firmware/target/arm/iriver/h10/button-h10.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/firmware/target/arm/iriver/h10/button-h10.c b/firmware/target/arm/iriver/h10/button-h10.c new file mode 100644 index 0000000000..badcd594a1 --- /dev/null +++ b/firmware/target/arm/iriver/h10/button-h10.c | |||
@@ -0,0 +1,69 @@ | |||
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 H10 based on analysis of the GPIO data */ | ||
21 | |||
22 | |||
23 | #include <stdlib.h> | ||
24 | #include "config.h" | ||
25 | #include "cpu.h" | ||
26 | #include "system.h" | ||
27 | #include "button.h" | ||
28 | #include "kernel.h" | ||
29 | #include "backlight.h" | ||
30 | #include "adc.h" | ||
31 | #include "system.h" | ||
32 | |||
33 | |||
34 | void button_init_device(void) | ||
35 | { | ||
36 | /* No hardware initialisation required as it is done by the bootloader */ | ||
37 | } | ||
38 | |||
39 | bool button_hold(void) | ||
40 | { | ||
41 | return (GPIOA_INPUT_VAL & 0x40)?false:true; | ||
42 | } | ||
43 | |||
44 | /* | ||
45 | * Get button pressed from hardware | ||
46 | */ | ||
47 | int button_read_device(void) | ||
48 | { | ||
49 | int btn = BUTTON_NONE; | ||
50 | unsigned char state; | ||
51 | static bool hold_button = false; | ||
52 | #if 0 | ||
53 | /* light handling */ | ||
54 | if (hold_button && !button_hold()) | ||
55 | { | ||
56 | backlight_on(); | ||
57 | } | ||
58 | #endif | ||
59 | |||
60 | hold_button = button_hold(); | ||
61 | state = GPIOA_INPUT_VAL & 0xf8; | ||
62 | if ((state & 0x8) == 0) btn |= BUTTON_FF; | ||
63 | if ((state & 0x16) == 0) btn |= BUTTON_PLAY; | ||
64 | if ((state & 0x32) == 0) btn |= BUTTON_REW; | ||
65 | if ((state & 0x64) == 0) btn |= BUTTON_RIGHT; | ||
66 | if ((state & 0x128) == 0) btn |= BUTTON_LEFT; | ||
67 | |||
68 | return btn; | ||
69 | } | ||