diff options
Diffstat (limited to 'firmware/target/arm/sandisk/sansa-c200/button-c200.c')
-rw-r--r-- | firmware/target/arm/sandisk/sansa-c200/button-c200.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/firmware/target/arm/sandisk/sansa-c200/button-c200.c b/firmware/target/arm/sandisk/sansa-c200/button-c200.c new file mode 100644 index 0000000000..eedd937699 --- /dev/null +++ b/firmware/target/arm/sandisk/sansa-c200/button-c200.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id:$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Mark Arigo | ||
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 "system.h" | ||
21 | #include "button.h" | ||
22 | #include "backlight.h" | ||
23 | |||
24 | void button_init_device(void) | ||
25 | { | ||
26 | /* TODO...for now, hardware initialisation is done by the c200 bootloader */ | ||
27 | } | ||
28 | |||
29 | bool button_hold(void) | ||
30 | { | ||
31 | return !(GPIOI_INPUT_VAL & 0x80); | ||
32 | } | ||
33 | |||
34 | /* | ||
35 | * Get button pressed from hardware | ||
36 | */ | ||
37 | int button_read_device(void) | ||
38 | { | ||
39 | int btn = BUTTON_NONE; | ||
40 | static bool hold_button = false; | ||
41 | bool hold_button_old; | ||
42 | |||
43 | /* Hold */ | ||
44 | hold_button_old = hold_button; | ||
45 | hold_button = button_hold(); | ||
46 | |||
47 | /* device buttons */ | ||
48 | if (!hold_button) | ||
49 | { | ||
50 | if ( (GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_POWER; | ||
51 | if (!(GPIOG_INPUT_VAL & 0x10)) btn |= BUTTON_UP; | ||
52 | if (!(GPIOH_INPUT_VAL & 0x01)) btn |= BUTTON_DOWN; | ||
53 | if (!(GPIOI_INPUT_VAL & 0x04)) btn |= BUTTON_LEFT; | ||
54 | if (!(GPIOG_INPUT_VAL & 0x02)) btn |= BUTTON_RIGHT; | ||
55 | if (!(GPIOL_INPUT_VAL & 0x04)) btn |= BUTTON_SELECT; | ||
56 | if (!(GPIOG_INPUT_VAL & 0x01)) btn |= BUTTON_REC; | ||
57 | if (!(GPIOL_INPUT_VAL & 0x10)) btn |= BUTTON_VOL_UP; | ||
58 | if (!(GPIOL_INPUT_VAL & 0x20)) btn |= BUTTON_VOL_DOWN; | ||
59 | } | ||
60 | |||
61 | return btn; | ||
62 | } | ||