diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c b/firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c new file mode 100644 index 0000000000..c5d6c4941d --- /dev/null +++ b/firmware/target/arm/as3525/sansa-m200v4/button-m200v4.c | |||
@@ -0,0 +1,93 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by ?? | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "cpu.h" | ||
24 | #include "button.h" | ||
25 | #include "adc.h" | ||
26 | |||
27 | void button_init_device(void) | ||
28 | { | ||
29 | GPIOA_DIR &= ~((1<<3) | (1<<2) | (1<<1) | (1<<0)); /* A3-A0 is input */ | ||
30 | GPIOA_DIR |= ((1<<6) | (1<<5) | (1<<4)); /* A4-A6 row outputs */ | ||
31 | } | ||
32 | |||
33 | int button_read_device(void) | ||
34 | { | ||
35 | int result = BUTTON_NONE; | ||
36 | |||
37 | /* direct GPIO connections */ | ||
38 | if (GPIOA_PIN(3)) | ||
39 | result |= BUTTON_MENU; | ||
40 | |||
41 | /* This is a keypad using A4-A6 as columns and A0-A2 as rows */ | ||
42 | GPIOA_PIN(4) = (1<<4); | ||
43 | |||
44 | /* A4A0 is unused */ | ||
45 | |||
46 | if (GPIOA_PIN(1)) | ||
47 | result |= BUTTON_VOLDOWN; | ||
48 | |||
49 | if (GPIOA_PIN(2)) | ||
50 | result |= BUTTON_PLAYPAUSE; | ||
51 | |||
52 | GPIOA_PIN(4) = 0x00; | ||
53 | |||
54 | GPIOA_PIN(5) = (1<<5); | ||
55 | |||
56 | if (GPIOA_PIN(0)) | ||
57 | result |= BUTTON_LEFT; | ||
58 | |||
59 | if (GPIOA_PIN(1)) | ||
60 | result |= BUTTON_SELECT; | ||
61 | |||
62 | if (GPIOA_PIN(2)) | ||
63 | result |= BUTTON_RIGHT; | ||
64 | |||
65 | GPIOA_PIN(5) = 0x00; | ||
66 | |||
67 | |||
68 | GPIOA_PIN(6) = (1<<6); | ||
69 | |||
70 | if (GPIOA_PIN(0)) | ||
71 | result |= BUTTON_REPEATAB; | ||
72 | |||
73 | if (GPIOA_PIN(1)) | ||
74 | result |= BUTTON_VOLUP; | ||
75 | |||
76 | if (GPIOA_PIN(2)) | ||
77 | result |= BUTTON_HOLD; | ||
78 | GPIOA_PIN(6) = 0x00; | ||
79 | |||
80 | return result; | ||
81 | } | ||
82 | |||
83 | bool button_hold(void) | ||
84 | { | ||
85 | bool ret = false; | ||
86 | |||
87 | GPIOA_PIN(6) = (1<<6); | ||
88 | if (GPIOA_PIN(2)) | ||
89 | ret = true; | ||
90 | GPIOA_PIN(6) = 0x00; | ||
91 | |||
92 | return ret; | ||
93 | } | ||