summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-09-06 17:50:59 +0000
committerDave Chapman <dave@dchapman.com>2008-09-06 17:50:59 +0000
commitd462a64a918117991e11dade2d7fa3a28196e07a (patch)
tree0a6f5ed8777b18bb1641fbb3608f10374901706c /firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
parentb87715f670f04c9adbe358c32a385c6771d99a81 (diff)
downloadrockbox-d462a64a918117991e11dade2d7fa3a28196e07a.tar.gz
rockbox-d462a64a918117991e11dade2d7fa3a28196e07a.zip
Initial commit of iaudio 7 port by Vitja Makarov (FS#9245). Port is at quite an advanced stage, but is troubled by the lack of a reliable NAND driver (similar to the Cowon D2 port) and is not yet suitable for non-developers.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18435 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c')
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
new file mode 100644
index 0000000000..3aad4f75a4
--- /dev/null
+++ b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c
@@ -0,0 +1,81 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Vitja Makarov
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#include "config.h"
22#include "cpu.h"
23#include "button.h"
24#include "adc.h"
25
26#include "button-target.h"
27#include "ata2501.h"
28
29void button_init_device(void)
30{
31 ata2501_init();
32}
33
34/*
35 touchpad:
36 0: stop
37 1-8: between next & prev
38 9: play
39 10: next
40 11: prev
41*/
42
43int button_read_device(void)
44{
45 int btn = BUTTON_NONE;
46 int adc;
47 int sensor;
48
49 if (button_hold())
50 return BUTTON_NONE;
51
52 adc = adc_read(0);
53 sensor = ata2501_read();
54
55 if (0 == (GPIOA & 4))
56 btn |= BUTTON_POWER;
57
58 /* seems they can't be hold together */
59 if (adc < 0x120)
60 btn |= BUTTON_VOLUP;
61 else if (adc < 0x270)
62 btn |= BUTTON_VOLDOWN;
63 else if (adc < 0x300)
64 btn |= BUTTON_MENU;
65
66 if (sensor & (1 << 0))
67 btn |= BUTTON_STOP;
68 if (sensor & (1 << 9))
69 btn |= BUTTON_PLAY;
70 if (sensor & ((1 << 10) | 0x1c0))
71 btn |= BUTTON_RIGHT;
72 if (sensor & ((1 << 11) | 0xe))
73 btn |= BUTTON_LEFT;
74
75 return btn;
76}
77
78bool button_hold(void)
79{
80 return !(GPIOA & 0x2);
81}