summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-09-30 08:57:49 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-09-30 08:57:49 +0000
commit80f1688423eaad7a2ad9e4809331e192bcd0047d (patch)
tree716c8e3160daaa7f462cfe6cf6f848c41b61b2e6 /firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
parenta5e788fe8533f6172b3d6b52d2430fe163f7a6fd (diff)
downloadrockbox-80f1688423eaad7a2ad9e4809331e192bcd0047d.tar.gz
rockbox-80f1688423eaad7a2ad9e4809331e192bcd0047d.zip
I got bullied in IRC by linuxstb and markun...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14909 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c')
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
new file mode 100644
index 0000000000..1d0d2714a8
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
@@ -0,0 +1,96 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "system.h"
23#include "button.h"
24#include "kernel.h"
25#include "backlight.h"
26#include "adc.h"
27#include "system.h"
28#include "backlight-target.h"
29#include "uart-target.h"
30
31#define BUTTON_TIMEOUT 50
32
33#define BUTTON_START_BYTE 0xF0
34#define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */
35 /* but always the same one for the session? */
36
37void button_init_device(void)
38{
39 /* GIO is the power button, set as input */
40 IO_GIO_DIR0 |= 0x01;
41}
42
43inline bool button_hold(void)
44{
45 return false;
46}
47
48int button_read_device(void)
49{
50 char data[5], c;
51 int i = 0;
52 int btn = BUTTON_NONE;
53
54 if ((IO_GIO_BITSET0&0x01) == 0)
55 btn |= BUTTON_POWER;
56
57 uart1_heartbeat();
58 while (uartAvailable())
59 {
60 if (uart1_getch(&c))
61 {
62 if (i && (data[0] == BUTTON_START_BYTE || data[0] == BUTTON_START_BYTE2))
63 {
64 data[i++] = c;
65 }
66 else if (c == BUTTON_START_BYTE ||
67 c == BUTTON_START_BYTE2)
68 {
69 data[0] = c;
70 i = 1;
71 }
72
73 if (i == 5)
74 {
75 if (data[1]& (1<<7))
76 btn |= BUTTON_RC_HEART;
77 if (data[1]& (1<<6))
78 btn |= BUTTON_RC_MODE;
79 if (data[1]& (1<<5))
80 btn |= BUTTON_RC_VOL_DOWN;
81 if (data[1]& (1<<4))
82 btn |= BUTTON_RC_VOL_UP;
83 if (data[1]& (1<<3))
84 btn |= BUTTON_RC_REW;
85 if (data[1]& (1<<2))
86 btn |= BUTTON_RC_FF;
87 if (data[1]& (1<<1))
88 btn |= BUTTON_RC_DOWN;
89 if (data[1]& (1<<0))
90 btn |= BUTTON_RC_PLAY;
91 break;
92 }
93 }
94 }
95 return btn;
96}