From c5d22bce6e69c047157e7106404269c0c2be236b Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Fri, 21 Sep 2007 02:05:02 +0000 Subject: minor fix for remote button code git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14795 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/olympus/mrobe-500/button-mr500.c | 16 ++++++++++++---- 1 file 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 @@ #include "uart-target.h" #define BUTTON_TIMEOUT 50 + +#define BUTTON_START_BYTE 0xF0 +#define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */ + /* but always the same one for the session? */ + void button_init_device(void) { /* GIO is the power button, set as input */ @@ -43,6 +48,7 @@ inline bool button_hold(void) int button_read_device(void) { char data[5], c; + int val; int i = 0; int btn = BUTTON_NONE, timeout = BUTTON_TIMEOUT; @@ -52,14 +58,16 @@ int button_read_device(void) uartHeartbeat(); while (timeout > 0) { - c = uartPollch(BUTTON_TIMEOUT*100); - if (c > -1) + val = uartPollch(BUTTON_TIMEOUT*100); + if (val > -1) { - if (i && data[0] == 0xf4) + c = val&0xff; + if (i && (data[0] == BUTTON_START_BYTE || data[0] == BUTTON_START_BYTE2)) { data[i++] = c; } - else if (c == 0xf4) + else if (c == BUTTON_START_BYTE || + c == BUTTON_START_BYTE2) { data[0] = c; i = 1; -- cgit v1.2.3