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