diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2006-10-29 10:26:41 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2006-10-29 10:26:41 +0000 |
commit | cad563b00f1013ad0c56746140ff3b30e8402b70 (patch) | |
tree | faf32a85a37e86ebaf0a0ccd2791d7a76d97cfb6 | |
parent | 3b54ab32242c3cbde346ab5a0693a9eabb4ab4f3 (diff) |
move the iriver h1x0/h3x0 button driver to target tree
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11380 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/button.c | 253 | ||||
-rw-r--r-- | firmware/export/button.h | 46 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/button-target.h | 81 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/h100/button-h100.c | 240 | ||||
-rw-r--r-- | firmware/target/coldfire/iriver/h300/button-h300.c | 246 | ||||
-rwxr-xr-x | tools/configure | 9 |
6 files changed, 590 insertions, 285 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index cc9f0fa18d..c4e013afdc 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -46,6 +46,9 @@ #ifdef TARGET_TREE #include "button-target.h" +#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) \ + || (CONFIG_KEYPAD == IRIVER_H300_PAD) +#include "button-target.h" #endif struct event_queue button_queue; @@ -82,10 +85,6 @@ static bool remote_filter_first_keypress; static int button_read(void); -#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) -static bool remote_button_hold_only(void); -#endif - #ifdef HAVE_HEADPHONE_DETECTION bool phones_present = false; #endif @@ -309,17 +308,9 @@ void button_init(void) #ifdef TARGET_TREE button_init_device(); -#elif CONFIG_KEYPAD == IRIVER_H100_PAD - /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ - GPIO1_FUNCTION |= 0x00100062; - GPIO1_ENABLE &= ~0x00100060; -#elif CONFIG_KEYPAD == IRIVER_H300_PAD - /* Set GPIO9 and GPIO15 as general purpose inputs */ - GPIO_ENABLE &= ~0x00008200; - GPIO_FUNCTION |= 0x00008200; - /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ - GPIO1_ENABLE &= ~0x00100060; - GPIO1_FUNCTION |= 0x00100062; +#elif CONFIG_KEYPAD == IRIVER_H100_PAD \ + || CONFIG_KEYPAD == IRIVER_H300_PAD + button_init_device(); /* temp untill TARGET_TREE is defined */ #elif CONFIG_KEYPAD == RECORDER_PAD /* Set PB4 and PB8 as input pins */ PBCR1 &= 0xfffc; /* PB8MD = 00 */ @@ -505,214 +496,19 @@ static int button_read(void) int btn = BUTTON_NONE; int retval; #ifndef TARGET_TREE +#if (CONFIG_KEYPAD != IRIVER_H100_PAD) \ + && (CONFIG_KEYPAD != IRIVER_H300_PAD) int data; #endif +#endif #ifdef TARGET_TREE btn = button_read_device(); -#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) - static bool hold_button = false; - static bool remote_hold_button = false; - static int prev_data = 0xff; - static int last_valid = 0xff; - bool hold_button_old; - bool remote_hold_button_old; - - /* normal buttons */ - hold_button_old = hold_button; - hold_button = button_hold(); - -#ifndef BOOTLOADER - if (hold_button != hold_button_old) - backlight_hold_changed(hold_button); -#endif - - if (!hold_button) - { - data = adc_scan(ADC_BUTTONS); - - /* ADC debouncing: Only accept new reading if it's - * stable (+/-1). Use latest stable value otherwise. */ - if ((unsigned)(data - prev_data + 1) <= 2) - last_valid = data; - prev_data = data; - data = last_valid; - -#if CONFIG_KEYPAD == IRIVER_H100_PAD - if (data < 0xf0) - { - if (data < 0x80) - if (data < 0x30) - if (data < 0x18) - btn = BUTTON_SELECT; - else - btn = BUTTON_UP; - else - if (data < 0x50) - btn = BUTTON_LEFT; - else - btn = BUTTON_DOWN; - else - if (data < 0xb0) - if (data < 0xa0) - btn = BUTTON_RIGHT; - else - btn = BUTTON_OFF; - else - if (data < 0xd0) - btn = BUTTON_MODE; - else - btn = BUTTON_REC; - } -#else /* H300 */ - if (data < 0xba) - { - if (data < 0x54) - if (data < 0x30) - if (data < 0x10) - btn = BUTTON_SELECT; - else - btn = BUTTON_UP; - else - btn = BUTTON_LEFT; - else - if (data < 0x98) - if (data < 0x76) - btn = BUTTON_DOWN; - else - btn = BUTTON_RIGHT; - else - btn = BUTTON_OFF; - } -#endif - } - - /* remote buttons */ - remote_hold_button_old = remote_hold_button; - remote_hold_button = remote_button_hold_only(); - -#ifndef BOOTLOADER - if (remote_hold_button != remote_hold_button_old) - remote_backlight_hold_changed(remote_hold_button); -#endif +#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) \ + || (CONFIG_KEYPAD == IRIVER_H300_PAD) + btn = button_read_device(); /* temp untill TARGET_TREE is defined */ - if (!remote_hold_button) - { - data = adc_scan(ADC_REMOTE); - switch (remote_type()) - { - case REMOTETYPE_H100_LCD: - if (data < 0xf5) - { - if (data < 0x73) - if (data < 0x3f) - if (data < 0x25) - if(data < 0x0c) - btn |= BUTTON_RC_STOP; - else - btn |= BUTTON_RC_VOL_DOWN; - else - btn |= BUTTON_RC_MODE; - else - if (data < 0x5a) - btn |= BUTTON_RC_VOL_UP; - else - btn |= BUTTON_RC_BITRATE; - else - if (data < 0xa8) - if (data < 0x8c) - btn |= BUTTON_RC_REC; - else - btn |= BUTTON_RC_SOURCE; - else - if (data < 0xdf) - if(data < 0xc5) - btn |= BUTTON_RC_FF; - else - btn |= BUTTON_RC_MENU; - else - btn |= BUTTON_RC_REW; - } - break; - case REMOTETYPE_H300_LCD: - if (data < 0xf5) - { - if (data < 0x73) - if (data < 0x42) - if (data < 0x27) - if(data < 0x0c) - btn |= BUTTON_RC_VOL_DOWN; - else - btn |= BUTTON_RC_FF; - else - btn |= BUTTON_RC_STOP; - else - if (data < 0x5b) - btn |= BUTTON_RC_MODE; - else - btn |= BUTTON_RC_REC; - else - if (data < 0xab) - if (data < 0x8e) - btn |= BUTTON_RC_ON; - else - btn |= BUTTON_RC_BITRATE; - else - if (data < 0xde) - if(data < 0xc5) - btn |= BUTTON_RC_SOURCE; - else - btn |= BUTTON_RC_VOL_UP; - else - btn |= BUTTON_RC_REW; - } - break; - case REMOTETYPE_H300_NONLCD: - if (data < 0xf1) - { - if (data < 0x7d) - if (data < 0x25) - btn |= BUTTON_RC_FF; - else - btn |= BUTTON_RC_REW; - else - if (data < 0xd5) - btn |= BUTTON_RC_VOL_DOWN; - else - btn |= BUTTON_RC_VOL_UP; - } - break; - } - } - - /* special buttons */ -#if CONFIG_KEYPAD == IRIVER_H300_PAD - if (!hold_button) - { - data = GPIO_READ; - if ((data & 0x0200) == 0) - btn |= BUTTON_MODE; - if ((data & 0x8000) == 0) - btn |= BUTTON_REC; - } -#endif - - data = GPIO1_READ; - if (!hold_button && ((data & 0x20) == 0)) - btn |= BUTTON_ON; - if (!remote_hold_button && ((data & 0x40) == 0)) - switch(remote_type()) - { - case REMOTETYPE_H100_LCD: - case REMOTETYPE_H300_NONLCD: - btn |= BUTTON_RC_ON; - break; - case REMOTETYPE_H300_LCD: - btn |= BUTTON_RC_MENU; - break; - } - #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD static bool hold_button = false; bool hold_button_old; @@ -910,31 +706,6 @@ static int button_read(void) return retval; } -#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) -bool button_hold(void) -{ - return (GPIO1_READ & 0x00000002)?true:false; -} - -static bool remote_button_hold_only(void) -{ - if(remote_type() == REMOTETYPE_H300_NONLCD) - return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */ - else - return (GPIO1_READ & 0x00100000)?true:false; -} - -/* returns true only if there is remote present */ -bool remote_button_hold(void) -{ - /* H300's NON-LCD remote doesn't set the "remote present" bit */ - if(remote_type() == REMOTETYPE_H300_NONLCD) - return remote_button_hold_only(); - else - return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false; -} -#endif - #if CONFIG_KEYPAD == IRIVER_IFP7XX_PAD bool button_hold(void) { diff --git a/firmware/export/button.h b/firmware/export/button.h index 686fe79937..18da59e13a 100644 --- a/firmware/export/button.h +++ b/firmware/export/button.h @@ -72,51 +72,9 @@ void wheel_send_events(bool send); #else /* Target specific button codes */ - -#if (CONFIG_KEYPAD == IRIVER_H100_PAD)\ +#if (CONFIG_KEYPAD == IRIVER_H100_PAD) \ || (CONFIG_KEYPAD == IRIVER_H300_PAD) - -/* iRiver H100/H300 specific button codes */ - - /* Main unit's buttons */ -#define BUTTON_ON 0x00000001 -#define BUTTON_OFF 0x00000002 - -#define BUTTON_LEFT 0x00000004 -#define BUTTON_RIGHT 0x00000008 -#define BUTTON_UP 0x00000010 -#define BUTTON_DOWN 0x00000020 - -#define BUTTON_REC 0x00000040 -#define BUTTON_MODE 0x00000080 - -#define BUTTON_SELECT 0x00000100 - -#define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT|\ - BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_MODE|BUTTON_SELECT) - - /* Remote control's buttons */ -#define BUTTON_RC_ON 0x00100000 -#define BUTTON_RC_STOP 0x00080000 - -#define BUTTON_RC_REW 0x00040000 -#define BUTTON_RC_FF 0x00020000 -#define BUTTON_RC_VOL_UP 0x00010000 -#define BUTTON_RC_VOL_DOWN 0x00008000 - -#define BUTTON_RC_REC 0x00004000 -#define BUTTON_RC_MODE 0x00002000 - -#define BUTTON_RC_MENU 0x00001000 - -#define BUTTON_RC_BITRATE 0x00000800 -#define BUTTON_RC_SOURCE 0x00000400 - -#define BUTTON_REMOTE (BUTTON_RC_ON|BUTTON_RC_STOP|BUTTON_RC_REW|BUTTON_RC_FF\ - |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN|BUTTON_RC_REC\ - |BUTTON_RC_MODE|BUTTON_RC_MENU|BUTTON_RC_BITRATE\ - |BUTTON_RC_SOURCE) - +#include "button-target.h" #elif CONFIG_KEYPAD == RECORDER_PAD /* Recorder specific button codes */ diff --git a/firmware/target/coldfire/iriver/button-target.h b/firmware/target/coldfire/iriver/button-target.h new file mode 100644 index 0000000000..b89761b317 --- /dev/null +++ b/firmware/target/coldfire/iriver/button-target.h @@ -0,0 +1,81 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Jonathan Gordon + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* Custom written for the Hxxx */ + +#ifndef _BUTTON_TARGET_H_ +#define _BUTTON_TARGET_H_ + +#include <stdbool.h> +#include "config.h" + +#define HAS_BUTTON_HOLD +#define HAS_REMOTE_BUTTON_HOLD + +bool button_hold(void); +bool remote_button_hold(void); +bool remote_button_hold_only(void); +void button_init_device(void); +int button_read_device(void); + +/* iRiver H100/H300 specific button codes */ + + /* Main unit's buttons */ +#define BUTTON_ON 0x00000001 +#define BUTTON_OFF 0x00000002 + +#define BUTTON_LEFT 0x00000004 +#define BUTTON_RIGHT 0x00000008 +#define BUTTON_UP 0x00000010 +#define BUTTON_DOWN 0x00000020 + +#define BUTTON_REC 0x00000040 +#define BUTTON_MODE 0x00000080 + +#define BUTTON_SELECT 0x00000100 + +#define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT|\ + BUTTON_UP|BUTTON_DOWN|BUTTON_REC|BUTTON_MODE|BUTTON_SELECT) + + /* Remote control's buttons */ +#define BUTTON_RC_ON 0x00100000 +#define BUTTON_RC_STOP 0x00080000 + +#define BUTTON_RC_REW 0x00040000 +#define BUTTON_RC_FF 0x00020000 +#define BUTTON_RC_VOL_UP 0x00010000 +#define BUTTON_RC_VOL_DOWN 0x00008000 + +#define BUTTON_RC_REC 0x00004000 +#define BUTTON_RC_MODE 0x00002000 + +#define BUTTON_RC_MENU 0x00001000 + +#define BUTTON_RC_BITRATE 0x00000800 +#define BUTTON_RC_SOURCE 0x00000400 + +#define BUTTON_REMOTE (BUTTON_RC_ON|BUTTON_RC_STOP|BUTTON_RC_REW|BUTTON_RC_FF\ + |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN|BUTTON_RC_REC\ + |BUTTON_RC_MODE|BUTTON_RC_MENU|BUTTON_RC_BITRATE\ + |BUTTON_RC_SOURCE) + +#define POWEROFF_BUTTON BUTTON_OFF +#define POWEROFF_COUNT 10 + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/coldfire/iriver/h100/button-h100.c b/firmware/target/coldfire/iriver/h100/button-h100.c new file mode 100644 index 0000000000..caf7cfdaca --- /dev/null +++ b/firmware/target/coldfire/iriver/h100/button-h100.c @@ -0,0 +1,240 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Jonathan Gordon + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + +#include <stdlib.h> +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "button.h" +#include "kernel.h" +#include "backlight.h" +#include "adc.h" +#include "system.h" +#ifdef HAVE_REMOTE_LCD +#include "lcd-remote.h" +#endif + +void button_init_device(void) +{ + /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ + GPIO1_FUNCTION |= 0x00100062; + GPIO1_ENABLE &= ~0x00100060; +} + +bool button_hold(void) +{ + return (GPIO1_READ & 0x00000002)?true:false; +} + +bool remote_button_hold_only(void) +{ + if(remote_type() == REMOTETYPE_H300_NONLCD) + return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */ + else + return (GPIO1_READ & 0x00100000)?true:false; +} + +/* returns true only if there is remote present */ +bool remote_button_hold(void) +{ + /* H300's NON-LCD remote doesn't set the "remote present" bit */ + if(remote_type() == REMOTETYPE_H300_NONLCD) + return remote_button_hold_only(); + else + return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false; +} + +/* + * Get button pressed from hardware + */ +int button_read_device(void) +{ + int btn = BUTTON_NONE; + int data; + static bool hold_button = false; + static bool remote_hold_button = false; + static int prev_data = 0xff; + static int last_valid = 0xff; + bool hold_button_old; + bool remote_hold_button_old; + + /* normal buttons */ + hold_button_old = hold_button; + hold_button = button_hold(); + + +#ifndef BOOTLOADER + if (hold_button != hold_button_old) + backlight_hold_changed(hold_button); +#endif + + if (!hold_button) + { + data = adc_scan(ADC_BUTTONS); + + /* ADC debouncing: Only accept new reading if it's + * stable (+/-1). Use latest stable value otherwise. */ + if ((unsigned)(data - prev_data + 1) <= 2) + last_valid = data; + prev_data = data; + data = last_valid; + + if (data < 0xf0) + { + if (data < 0x80) + if (data < 0x30) + if (data < 0x18) + btn = BUTTON_SELECT; + else + btn = BUTTON_UP; + else + if (data < 0x50) + btn = BUTTON_LEFT; + else + btn = BUTTON_DOWN; + else + if (data < 0xb0) + if (data < 0xa0) + btn = BUTTON_RIGHT; + else + btn = BUTTON_OFF; + else + if (data < 0xd0) + btn = BUTTON_MODE; + else + btn = BUTTON_REC; + } + } + + /* remote buttons */ + remote_hold_button_old = remote_hold_button; + remote_hold_button = remote_button_hold_only(); + +#ifndef BOOTLOADER + if (remote_hold_button != remote_hold_button_old) + remote_backlight_hold_changed(remote_hold_button); +#endif + + if (!remote_hold_button) + { + data = adc_scan(ADC_REMOTE); + switch (remote_type()) + { + case REMOTETYPE_H100_LCD: + if (data < 0xf5) + { + if (data < 0x73) + if (data < 0x3f) + if (data < 0x25) + if(data < 0x0c) + btn |= BUTTON_RC_STOP; + else + btn |= BUTTON_RC_VOL_DOWN; + else + btn |= BUTTON_RC_MODE; + else + if (data < 0x5a) + btn |= BUTTON_RC_VOL_UP; + else + btn |= BUTTON_RC_BITRATE; + else + if (data < 0xa8) + if (data < 0x8c) + btn |= BUTTON_RC_REC; + else + btn |= BUTTON_RC_SOURCE; + else + if (data < 0xdf) + if(data < 0xc5) + btn |= BUTTON_RC_FF; + else + btn |= BUTTON_RC_MENU; + else + btn |= BUTTON_RC_REW; + } + break; + case REMOTETYPE_H300_LCD: + if (data < 0xf5) + { + if (data < 0x73) + if (data < 0x42) + if (data < 0x27) + if(data < 0x0c) + btn |= BUTTON_RC_VOL_DOWN; + else + btn |= BUTTON_RC_FF; + else + btn |= BUTTON_RC_STOP; + else + if (data < 0x5b) + btn |= BUTTON_RC_MODE; + else + btn |= BUTTON_RC_REC; + else + if (data < 0xab) + if (data < 0x8e) + btn |= BUTTON_RC_ON; + else + btn |= BUTTON_RC_BITRATE; + else + if (data < 0xde) + if(data < 0xc5) + btn |= BUTTON_RC_SOURCE; + else + btn |= BUTTON_RC_VOL_UP; + else + btn |= BUTTON_RC_REW; + } + break; + case REMOTETYPE_H300_NONLCD: + if (data < 0xf1) + { + if (data < 0x7d) + if (data < 0x25) + btn |= BUTTON_RC_FF; + else + btn |= BUTTON_RC_REW; + else + if (data < 0xd5) + btn |= BUTTON_RC_VOL_DOWN; + else + btn |= BUTTON_RC_VOL_UP; + } + break; + } + } + + data = GPIO1_READ; + if (!hold_button && ((data & 0x20) == 0)) + btn |= BUTTON_ON; + if (!remote_hold_button && ((data & 0x40) == 0)) + switch(remote_type()) + { + case REMOTETYPE_H100_LCD: + case REMOTETYPE_H300_NONLCD: + btn |= BUTTON_RC_ON; + break; + case REMOTETYPE_H300_LCD: + btn |= BUTTON_RC_MENU; + break; + } + + return btn; +} diff --git a/firmware/target/coldfire/iriver/h300/button-h300.c b/firmware/target/coldfire/iriver/h300/button-h300.c new file mode 100644 index 0000000000..80210b6c19 --- /dev/null +++ b/firmware/target/coldfire/iriver/h300/button-h300.c @@ -0,0 +1,246 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2006 by Jonathan Gordon + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + +#include <stdlib.h> +#include "config.h" +#include "cpu.h" +#include "system.h" +#include "button.h" +#include "kernel.h" +#include "backlight.h" +#include "adc.h" +#include "system.h" +#ifdef HAVE_REMOTE_LCD +#include "lcd-remote.h" +#endif + +void button_init_device(void) +{ + /* Set GPIO9 and GPIO15 as general purpose inputs */ + GPIO_ENABLE &= ~0x00008200; + GPIO_FUNCTION |= 0x00008200; + /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ + GPIO1_ENABLE &= ~0x00100060; + GPIO1_FUNCTION |= 0x00100062; +} + +bool button_hold(void) +{ + return (GPIO1_READ & 0x00000002)?true:false; +} + +bool remote_button_hold_only(void) +{ + if(remote_type() == REMOTETYPE_H300_NONLCD) + return adc_scan(ADC_REMOTE)<0x0d; /* hold should be 0x00 */ + else + return (GPIO1_READ & 0x00100000)?true:false; +} + +/* returns true only if there is remote present */ +bool remote_button_hold(void) +{ + /* H300's NON-LCD remote doesn't set the "remote present" bit */ + if(remote_type() == REMOTETYPE_H300_NONLCD) + return remote_button_hold_only(); + else + return ((GPIO_READ & 0x40000000) == 0)?remote_button_hold_only():false; +} + +/* + * Get button pressed from hardware + */ +int button_read_device(void) +{ + int btn = BUTTON_NONE; + int data; + static bool hold_button = false; + static bool remote_hold_button = false; + static int prev_data = 0xff; + static int last_valid = 0xff; + bool hold_button_old; + bool remote_hold_button_old; + + /* normal buttons */ + hold_button_old = hold_button; + hold_button = button_hold(); + + +#ifndef BOOTLOADER + if (hold_button != hold_button_old) + backlight_hold_changed(hold_button); +#endif + + if (!hold_button) + { + data = adc_scan(ADC_BUTTONS); + + /* ADC debouncing: Only accept new reading if it's + * stable (+/-1). Use latest stable value otherwise. */ + if ((unsigned)(data - prev_data + 1) <= 2) + last_valid = data; + prev_data = data; + data = last_valid; + + if (data < 0xba) + { + if (data < 0x54) + if (data < 0x30) + if (data < 0x10) + btn = BUTTON_SELECT; + else + btn = BUTTON_UP; + else + btn = BUTTON_LEFT; + else + if (data < 0x98) + if (data < 0x76) + btn = BUTTON_DOWN; + else + btn = BUTTON_RIGHT; + else + btn = BUTTON_OFF; + } + } + + /* remote buttons */ + remote_hold_button_old = remote_hold_button; + remote_hold_button = remote_button_hold_only(); + +#ifndef BOOTLOADER + if (remote_hold_button != remote_hold_button_old) + remote_backlight_hold_changed(remote_hold_button); +#endif + + if (!remote_hold_button) + { + data = adc_scan(ADC_REMOTE); + switch (remote_type()) + { + case REMOTETYPE_H100_LCD: + if (data < 0xf5) + { + if (data < 0x73) + if (data < 0x3f) + if (data < 0x25) + if(data < 0x0c) + btn |= BUTTON_RC_STOP; + else + btn |= BUTTON_RC_VOL_DOWN; + else + btn |= BUTTON_RC_MODE; + else + if (data < 0x5a) + btn |= BUTTON_RC_VOL_UP; + else + btn |= BUTTON_RC_BITRATE; + else + if (data < 0xa8) + if (data < 0x8c) + btn |= BUTTON_RC_REC; + else + btn |= BUTTON_RC_SOURCE; + else + if (data < 0xdf) + if(data < 0xc5) + btn |= BUTTON_RC_FF; + else + btn |= BUTTON_RC_MENU; + else + btn |= BUTTON_RC_REW; + } + break; + case REMOTETYPE_H300_LCD: + if (data < 0xf5) + { + if (data < 0x73) + if (data < 0x42) + if (data < 0x27) + if(data < 0x0c) + btn |= BUTTON_RC_VOL_DOWN; + else + btn |= BUTTON_RC_FF; + else + btn |= BUTTON_RC_STOP; + else + if (data < 0x5b) + btn |= BUTTON_RC_MODE; + else + btn |= BUTTON_RC_REC; + else + if (data < 0xab) + if (data < 0x8e) + btn |= BUTTON_RC_ON; + else + btn |= BUTTON_RC_BITRATE; + else + if (data < 0xde) + if(data < 0xc5) + btn |= BUTTON_RC_SOURCE; + else + btn |= BUTTON_RC_VOL_UP; + else + btn |= BUTTON_RC_REW; + } + break; + case REMOTETYPE_H300_NONLCD: + if (data < 0xf1) + { + if (data < 0x7d) + if (data < 0x25) + btn |= BUTTON_RC_FF; + else + btn |= BUTTON_RC_REW; + else + if (data < 0xd5) + btn |= BUTTON_RC_VOL_DOWN; + else + btn |= BUTTON_RC_VOL_UP; + } + break; + } + } + + if (!hold_button) + { + data = GPIO_READ; + if ((data & 0x0200) == 0) + btn |= BUTTON_MODE; + if ((data & 0x8000) == 0) + btn |= BUTTON_REC; + } + + data = GPIO1_READ; + if (!hold_button && ((data & 0x20) == 0)) + btn |= BUTTON_ON; + if (!remote_hold_button && ((data & 0x40) == 0)) + switch(remote_type()) + { + case REMOTETYPE_H100_LCD: + case REMOTETYPE_H300_NONLCD: + btn |= BUTTON_RC_ON; + break; + case REMOTETYPE_H300_LCD: + btn |= BUTTON_RC_MENU; + break; + } + + return btn; +} diff --git a/tools/configure b/tools/configure index 2f9e2db528..e7562f824b 100755 --- a/tools/configure +++ b/tools/configure @@ -685,6 +685,9 @@ EOF # toolset is the tools within the tools directory that we build for # this particular target. toolset=$iriverbitmaptools + t_cpu="coldfire" + t_manufacturer="iriver" + t_model="h100" ;; 11|h300) @@ -707,6 +710,9 @@ EOF # toolset is the tools within the tools directory that we build for # this particular target. toolset=$iriverbitmaptools + t_cpu="coldfire" + t_manufacturer="iriver" + t_model="h300" ;; 12|h100) @@ -729,6 +735,9 @@ EOF # toolset is the tools within the tools directory that we build for # this particular target. toolset=$iriverbitmaptools + t_cpu="coldfire" + t_manufacturer="iriver" + t_model="h100" ;; 30|x5) |