diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-09-21 02:05:02 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-09-21 02:05:02 +0000 |
commit | c5d22bce6e69c047157e7106404269c0c2be236b (patch) | |
tree | 2b69bd5da421d2e52f8eeaf08576f9035a3ab619 | |
parent | a576657011ec1f0268ad1b1902e27ac378cda3de (diff) | |
download | rockbox-c5d22bce6e69c047157e7106404269c0c2be236b.tar.gz rockbox-c5d22bce6e69c047157e7106404269c0c2be236b.zip |
minor fix for remote button code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14795 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/arm/olympus/mrobe-500/button-mr500.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/firmware/target/arm/olympus/mrobe-500/button-mr500.c b/firmware/target/arm/olympus/mrobe-500/button-mr500.c index f85eeca912..a25a71e1fc 100644 --- a/firmware/target/arm/olympus/mrobe-500/button-mr500.c +++ b/firmware/target/arm/olympus/mrobe-500/button-mr500.c | |||
@@ -29,6 +29,11 @@ | |||
29 | #include "uart-target.h" | 29 | #include "uart-target.h" |
30 | 30 | ||
31 | #define BUTTON_TIMEOUT 50 | 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 | |||
32 | void button_init_device(void) | 37 | void button_init_device(void) |
33 | { | 38 | { |
34 | /* GIO is the power button, set as input */ | 39 | /* GIO is the power button, set as input */ |
@@ -43,6 +48,7 @@ inline bool button_hold(void) | |||
43 | int button_read_device(void) | 48 | int button_read_device(void) |
44 | { | 49 | { |
45 | char data[5], c; | 50 | char data[5], c; |
51 | int val; | ||
46 | int i = 0; | 52 | int i = 0; |
47 | int btn = BUTTON_NONE, timeout = BUTTON_TIMEOUT; | 53 | int btn = BUTTON_NONE, timeout = BUTTON_TIMEOUT; |
48 | 54 | ||
@@ -52,14 +58,16 @@ int button_read_device(void) | |||
52 | uartHeartbeat(); | 58 | uartHeartbeat(); |
53 | while (timeout > 0) | 59 | while (timeout > 0) |
54 | { | 60 | { |
55 | c = uartPollch(BUTTON_TIMEOUT*100); | 61 | val = uartPollch(BUTTON_TIMEOUT*100); |
56 | if (c > -1) | 62 | if (val > -1) |
57 | { | 63 | { |
58 | if (i && data[0] == 0xf4) | 64 | c = val&0xff; |
65 | if (i && (data[0] == BUTTON_START_BYTE || data[0] == BUTTON_START_BYTE2)) | ||
59 | { | 66 | { |
60 | data[i++] = c; | 67 | data[i++] = c; |
61 | } | 68 | } |
62 | else if (c == 0xf4) | 69 | else if (c == BUTTON_START_BYTE || |
70 | c == BUTTON_START_BYTE2) | ||
63 | { | 71 | { |
64 | data[0] = c; | 72 | data[0] = c; |
65 | i = 1; | 73 | i = 1; |