Hopefully update the keywords. Thanks bluebrother.
[Rockbox.git] / firmware / target / arm / tcc77x / c100 / button-c100.c
blob7487c1160459920ef8761079bfa12d6acc694ae9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Dave Chapman
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
21 #include "cpu.h"
22 #include "button.h"
23 #include "adc.h"
25 void button_init_device(void)
27 GPIOA_DIR |= 0xC;
30 int button_read_device(void)
32 int btn = BUTTON_NONE;
34 if (!button_hold()){
35 GPIOA |= 0x4;
36 GPIOA &= ~0x8;
38 int i=20; while (i--);
40 if (GPIOA & 0x10) btn |= BUTTON_PLAYPAUSE; /* up */
41 if (GPIOA & 0x20) btn |= BUTTON_RIGHT;
42 if (GPIOA & 0x40) btn |= BUTTON_LEFT;
44 GPIOA |= 0x8;
45 GPIOA &= ~0x4;
47 i=20; while (i--);
49 if (GPIOA & 0x10) btn |= BUTTON_VOLUP;
50 if (GPIOA & 0x20) btn |= BUTTON_VOLDOWN;
51 if (GPIOA & 0x40) btn |= BUTTON_REPEATAB; /* down */
53 if (GPIOA & 0x80) btn |= BUTTON_SELECT;
54 if (GPIOA & 0x100) btn |= BUTTON_MENU;
56 return btn;
59 bool button_hold(void)
61 return (GPIOA & 0x2);