diff options
Diffstat (limited to 'firmware/target/arm/tcc77x/c100/button-c100.c')
-rw-r--r-- | firmware/target/arm/tcc77x/c100/button-c100.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/c100/button-c100.c b/firmware/target/arm/tcc77x/c100/button-c100.c new file mode 100644 index 0000000000..0183a833ae --- /dev/null +++ b/firmware/target/arm/tcc77x/c100/button-c100.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: button-logikdax.c 15396 2007-11-01 23:38:57Z dave $ | ||
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 | void button_init_device(void) | ||
26 | { | ||
27 | GPIOA_DIR |= 0xC; | ||
28 | } | ||
29 | |||
30 | int button_read_device(void) | ||
31 | { | ||
32 | int btn = BUTTON_NONE; | ||
33 | |||
34 | if (!button_hold()){ | ||
35 | GPIOA |= 0x4; | ||
36 | GPIOA &= ~0x8; | ||
37 | |||
38 | int i=20; while (i--); | ||
39 | |||
40 | if (GPIOA & 0x10) btn |= BUTTON_PLAYPAUSE; /* up */ | ||
41 | if (GPIOA & 0x20) btn |= BUTTON_RIGHT; | ||
42 | if (GPIOA & 0x40) btn |= BUTTON_LEFT; | ||
43 | |||
44 | GPIOA |= 0x8; | ||
45 | GPIOA &= ~0x4; | ||
46 | |||
47 | i=20; while (i--); | ||
48 | |||
49 | if (GPIOA & 0x10) btn |= BUTTON_VOLUP; | ||
50 | if (GPIOA & 0x20) btn |= BUTTON_VOLDOWN; | ||
51 | if (GPIOA & 0x40) btn |= BUTTON_REPEATAB; /* down */ | ||
52 | |||
53 | if (GPIOA & 0x80) btn |= BUTTON_SELECT; | ||
54 | if (GPIOA & 0x100) btn |= BUTTON_MENU; | ||
55 | } | ||
56 | return btn; | ||
57 | } | ||
58 | |||
59 | bool button_hold(void) | ||
60 | { | ||
61 | return (GPIOA & 0x2); | ||
62 | } | ||