summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-11-27 02:16:32 +0000
committerJens Arnold <amiconn@rockbox.org>2006-11-27 02:16:32 +0000
commit0e6dd7efcd21d48665b5a799fe081a75cdcb960f (patch)
tree9c0db844416a114adebb725f6172e38009b317f8
parente43f56b58d8540492d83b44abfdf4c758b0e74bf (diff)
downloadrockbox-0e6dd7efcd21d48665b5a799fe081a75cdcb960f.tar.gz
rockbox-0e6dd7efcd21d48665b5a799fe081a75cdcb960f.zip
Moved archos button reading to target tree. * Cleanup of button.[ch]. * Deactivated serial remote code for recorder FM/V2 as there is no remote pin, saving ~500 bytes of code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11612 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/keymaps/keymap-recorder.c4
-rw-r--r--apps/main.c3
-rw-r--r--apps/plugins/battery_bench.c8
-rw-r--r--apps/plugins/wormlet.c6
-rw-r--r--firmware/SOURCES4
-rw-r--r--firmware/drivers/button.c234
-rw-r--r--firmware/drivers/serial.c27
-rw-r--r--firmware/export/button.h127
-rw-r--r--firmware/target/coldfire/iriver/button-target.h1
-rwxr-xr-xfirmware/target/sh/archos/fm_v2/button-fm_v2.c97
-rwxr-xr-xfirmware/target/sh/archos/fm_v2/button-target.h53
-rwxr-xr-xfirmware/target/sh/archos/ondio/button-ondio.c65
-rwxr-xr-xfirmware/target/sh/archos/ondio/button-target.h45
-rwxr-xr-xfirmware/target/sh/archos/player/button-player.c74
-rwxr-xr-xfirmware/target/sh/archos/player/button-target.h56
-rwxr-xr-xfirmware/target/sh/archos/recorder/button-recorder.c108
-rwxr-xr-xfirmware/target/sh/archos/recorder/button-target.h63
-rwxr-xr-xtools/configure18
18 files changed, 625 insertions, 368 deletions
diff --git a/apps/keymaps/keymap-recorder.c b/apps/keymaps/keymap-recorder.c
index cc09b90bfd..c51bde9a4b 100644
--- a/apps/keymaps/keymap-recorder.c
+++ b/apps/keymaps/keymap-recorder.c
@@ -215,6 +215,7 @@ const struct button_mapping button_context_radio[] = {
215 215
216}; 216};
217 217
218#if BUTTON_REMOTE != 0
218/***************************************************************************** 219/*****************************************************************************
219 * Remote control mappings 220 * Remote control mappings
220 *****************************************************************************/ 221 *****************************************************************************/
@@ -254,11 +255,14 @@ static const struct button_mapping* get_context_mapping_remote( int context )
254 return remote_button_context_standard; 255 return remote_button_context_standard;
255 } 256 }
256} 257}
258#endif /* BUTTON_REMOTE != 0 */
257 259
258const struct button_mapping* get_context_mapping( int context ) 260const struct button_mapping* get_context_mapping( int context )
259{ 261{
262#if BUTTON_REMOTE != 0
260 if (context&CONTEXT_REMOTE) 263 if (context&CONTEXT_REMOTE)
261 return get_context_mapping_remote(context); 264 return get_context_mapping_remote(context);
265#endif
262 266
263 switch( context ) 267 switch( context )
264 { 268 {
diff --git a/apps/main.c b/apps/main.c
index abe73414c1..7a100eb5a8 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -309,8 +309,7 @@ void init(void)
309#ifdef DEBUG 309#ifdef DEBUG
310 debug_init(); 310 debug_init();
311#else 311#else
312#ifndef HAVE_MMC /* FIXME: This is also necessary for debug builds 312#if !defined(HAVE_FMADC) && !defined(HAVE_MMC)
313 * (do debug builds on the Ondio make sense?) */
314 serial_setup(); 313 serial_setup();
315#endif 314#endif
316#endif 315#endif
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index c9c289acb7..9b8871eb41 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -29,15 +29,17 @@ PLUGIN_HEADER
29#define EV_EXIT 1337 29#define EV_EXIT 1337
30 30
31/* seems to work with 1300, but who knows... */ 31/* seems to work with 1300, but who knows... */
32#define THREAD_STACK_SIZE DEFAULT_STACK_SIZE + 0x200 32#define THREAD_STACK_SIZE DEFAULT_STACK_SIZE + 0x200
33 33
34#if CONFIG_KEYPAD == RECORDER_PAD 34#if CONFIG_KEYPAD == RECORDER_PAD
35 35
36#define BATTERY_ON BUTTON_PLAY 36#define BATTERY_ON BUTTON_PLAY
37#define BATTERY_RC_ON BUTTON_RC_PLAY
38
39#define BATTERY_OFF BUTTON_OFF 37#define BATTERY_OFF BUTTON_OFF
38
39#if BUTTON_REMOTE != 0
40#define BATTERY_RC_ON BUTTON_RC_PLAY
40#define BATTERY_RC_OFF BUTTON_RC_STOP 41#define BATTERY_RC_OFF BUTTON_RC_STOP
42#endif
41 43
42#elif CONFIG_KEYPAD == ONDIO_PAD 44#elif CONFIG_KEYPAD == ONDIO_PAD
43 45
diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c
index 1ca570d24a..6a10fac984 100644
--- a/apps/plugins/wormlet.c
+++ b/apps/plugins/wormlet.c
@@ -47,15 +47,17 @@ PLUGIN_HEADER
47#define BTN_DIR_RIGHT BUTTON_RIGHT 47#define BTN_DIR_RIGHT BUTTON_RIGHT
48#define BTN_PLAYER2_DIR1 BUTTON_F2 48#define BTN_PLAYER2_DIR1 BUTTON_F2
49#define BTN_PLAYER2_DIR2 BUTTON_F3 49#define BTN_PLAYER2_DIR2 BUTTON_F3
50#define BTN_RC_UP BUTTON_RC_VOL_UP
51#define BTN_RC_DOWN BUTTON_RC_VOL_DOWN
52#define BTN_STARTPAUSE BUTTON_PLAY 50#define BTN_STARTPAUSE BUTTON_PLAY
53#define BTN_QUIT BUTTON_OFF 51#define BTN_QUIT BUTTON_OFF
54#define BTN_STOPRESET BUTTON_ON 52#define BTN_STOPRESET BUTTON_ON
55#define BTN_TOGGLE_KEYS BUTTON_F1 53#define BTN_TOGGLE_KEYS BUTTON_F1
56 54
55#if BUTTON_REMOTE != 0
56#define BTN_RC_UP BUTTON_RC_VOL_UP
57#define BTN_RC_DOWN BUTTON_RC_VOL_DOWN
57#define REMOTE 58#define REMOTE
58#define MULTIPLAYER 59#define MULTIPLAYER
60#endif
59 61
60#define PLAYERS_TEXT "UP/DN" 62#define PLAYERS_TEXT "UP/DN"
61#define WORMS_TEXT "L/R" 63#define WORMS_TEXT "L/R"
diff --git a/firmware/SOURCES b/firmware/SOURCES
index a6d29841ea..6bc9df231b 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -281,6 +281,7 @@ drivers/i2c.c
281 281
282#ifdef ARCHOS_PLAYER 282#ifdef ARCHOS_PLAYER
283#ifndef SIMULATOR 283#ifndef SIMULATOR
284target/sh/archos/player/button-player.c
284target/sh/archos/player/lcd-as-player.S 285target/sh/archos/player/lcd-as-player.S
285#endif /* SIMULATOR */ 286#endif /* SIMULATOR */
286#endif /* ARCHOS_PLAYER */ 287#endif /* ARCHOS_PLAYER */
@@ -289,6 +290,7 @@ target/sh/archos/player/lcd-as-player.S
289#ifndef SIMULATOR 290#ifndef SIMULATOR
290target/sh/archos/lcd-archos-bitmap.c 291target/sh/archos/lcd-archos-bitmap.c
291target/sh/archos/lcd-as-archos-bitmap.S 292target/sh/archos/lcd-as-archos-bitmap.S
293target/sh/archos/recorder/button-recorder.c
292#endif /* SIMULATOR */ 294#endif /* SIMULATOR */
293#endif /* ARCHOS_RECORDER */ 295#endif /* ARCHOS_RECORDER */
294 296
@@ -296,6 +298,7 @@ target/sh/archos/lcd-as-archos-bitmap.S
296#ifndef SIMULATOR 298#ifndef SIMULATOR
297target/sh/archos/lcd-archos-bitmap.c 299target/sh/archos/lcd-archos-bitmap.c
298target/sh/archos/lcd-as-archos-bitmap.S 300target/sh/archos/lcd-as-archos-bitmap.S
301target/sh/archos/fm_v2/button-fm_v2.c
299#endif /* SIMULATOR */ 302#endif /* SIMULATOR */
300#endif /* ARCHOS_FMRECORDER || ARCHOS_RECORDERV2 */ 303#endif /* ARCHOS_FMRECORDER || ARCHOS_RECORDERV2 */
301 304
@@ -303,6 +306,7 @@ target/sh/archos/lcd-as-archos-bitmap.S
303#ifndef SIMULATOR 306#ifndef SIMULATOR
304target/sh/archos/lcd-archos-bitmap.c 307target/sh/archos/lcd-archos-bitmap.c
305target/sh/archos/lcd-as-archos-bitmap.S 308target/sh/archos/lcd-as-archos-bitmap.S
309target/sh/archos/ondio/button-ondio.c
306#endif /* SIMULATOR */ 310#endif /* SIMULATOR */
307#endif /* ARCHOS_ONDIOFM || ARCHOS_ONDIOFM */ 311#endif /* ARCHOS_ONDIOFM || ARCHOS_ONDIOFM */
308 312
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 01b9174dae..deaf7f2fdd 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -9,12 +9,6 @@
9 * 9 *
10 * Copyright (C) 2002 by Daniel Stenberg 10 * Copyright (C) 2002 by Daniel Stenberg
11 * 11 *
12 * iPod driver based on code from the ipodlinux project - http://ipodlinux.org
13 * Adapted for Rockbox in December 2005
14 * Original file: linux/arch/armnommu/mach-ipod/keyboard.c
15 * Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
16 *
17 *
18 * All files in this archive are subject to the GNU General Public License. 12 * All files in this archive are subject to the GNU General Public License.
19 * See the file COPYING in the source tree root for full license agreement. 13 * See the file COPYING in the source tree root for full license agreement.
20 * 14 *
@@ -29,25 +23,19 @@
29 23
30#include <stdlib.h> 24#include <stdlib.h>
31#include "config.h" 25#include "config.h"
32#include "cpu.h"
33#include "system.h" 26#include "system.h"
34#include "button.h" 27#include "button.h"
35#include "kernel.h" 28#include "kernel.h"
36#include "backlight.h" 29#include "backlight.h"
37#include "adc.h"
38#include "serial.h" 30#include "serial.h"
39#include "power.h" 31#include "power.h"
40#include "system.h"
41#include "powermgmt.h" 32#include "powermgmt.h"
33#include "button-target.h"
42 34
43#ifdef HAVE_REMOTE_LCD 35#ifdef HAVE_REMOTE_LCD
44#include "lcd-remote.h" 36#include "lcd-remote.h"
45#endif 37#endif
46 38
47#ifdef TARGET_TREE
48#include "button-target.h"
49#endif
50
51struct event_queue button_queue; 39struct event_queue button_queue;
52 40
53static long lastbtn; /* Last valid button status */ 41static long lastbtn; /* Last valid button status */
@@ -60,6 +48,9 @@ static bool filter_first_keypress;
60#ifdef HAVE_REMOTE_LCD 48#ifdef HAVE_REMOTE_LCD
61static bool remote_filter_first_keypress; 49static bool remote_filter_first_keypress;
62#endif 50#endif
51#endif /* CONFIG_BACKLIGHT */
52#ifdef HAVE_HEADPHONE_DETECTION
53bool phones_present = false;
63#endif 54#endif
64 55
65/* how long until repeat kicks in, in ticks */ 56/* how long until repeat kicks in, in ticks */
@@ -71,18 +62,8 @@ static bool remote_filter_first_keypress;
71/* speed repeat finishes at, in ticks */ 62/* speed repeat finishes at, in ticks */
72#define REPEAT_INTERVAL_FINISH 5 63#define REPEAT_INTERVAL_FINISH 5
73 64
74/* the power-off button and number of repeated keys before shutting off */
75#if !defined(TARGET_TREE)
76#define POWEROFF_BUTTON BUTTON_OFF
77#define POWEROFF_COUNT 10
78#endif
79
80static int button_read(void); 65static int button_read(void);
81 66
82#ifdef HAVE_HEADPHONE_DETECTION
83bool phones_present = false;
84#endif
85
86static void button_tick(void) 67static void button_tick(void)
87{ 68{
88 static int count = 0; 69 static int count = 0;
@@ -99,8 +80,7 @@ static void button_tick(void)
99 int diff; 80 int diff;
100 int btn; 81 int btn;
101 82
102#if (CONFIG_KEYPAD == PLAYER_PAD) || (CONFIG_KEYPAD == RECORDER_PAD) 83#ifdef HAS_SERIAL_REMOTE
103
104 /* Post events for the remote control */ 84 /* Post events for the remote control */
105 btn = remote_control_rx(); 85 btn = remote_control_rx();
106 if(btn) 86 if(btn)
@@ -180,9 +160,7 @@ static void button_tick(void)
180 key */ 160 key */
181#ifdef HAVE_SW_POWEROFF 161#ifdef HAVE_SW_POWEROFF
182 if ((btn == POWEROFF_BUTTON 162 if ((btn == POWEROFF_BUTTON
183#ifdef BUTTON_RC_STOP 163#ifdef RC_POWEROFF_BUTTON
184 || btn == BUTTON_RC_STOP
185#elif defined(RC_POWEROFF_BUTTON)
186 || btn == RC_POWEROFF_BUTTON 164 || btn == RC_POWEROFF_BUTTON
187#endif 165#endif
188 ) && 166 ) &&
@@ -299,22 +277,8 @@ long button_get_w_tmo(int ticks)
299void button_init(void) 277void button_init(void)
300{ 278{
301 /* hardware inits */ 279 /* hardware inits */
302#ifdef TARGET_TREE
303 button_init_device(); 280 button_init_device();
304 281
305#elif CONFIG_KEYPAD == RECORDER_PAD
306 /* Set PB4 and PB8 as input pins */
307 PBCR1 &= 0xfffc; /* PB8MD = 00 */
308 PBCR2 &= 0xfcff; /* PB4MD = 00 */
309 PBIOR &= ~0x0110; /* Inputs */
310#elif CONFIG_KEYPAD == PLAYER_PAD
311 /* set PA5 and PA11 as input pins */
312 PACR1 &= 0xff3f; /* PA11MD = 00 */
313 PACR2 &= 0xfbff; /* PA5MD = 0 */
314 PAIOR &= ~0x0820; /* Inputs */
315#elif CONFIG_KEYPAD == ONDIO_PAD
316 /* nothing to initialize here */
317#endif /* CONFIG_KEYPAD */
318 queue_init(&button_queue, true); 282 queue_init(&button_queue, true);
319 button_read(); 283 button_read();
320 lastbtn = button_read(); 284 lastbtn = button_read();
@@ -410,194 +374,12 @@ void set_remote_backlight_filter_keypress(bool value)
410#endif 374#endif
411 375
412/* 376/*
413 Archos hardware button hookup
414 =============================
415
416 Recorder / Recorder FM/V2
417 -------------------------
418 F1, F2, F3, UP: connected to AN4 through a resistor network
419 DOWN, PLAY, LEFT, RIGHT: likewise connected to AN5
420
421 The voltage on AN4/ AN5 depends on which keys (or key combo) is pressed
422 FM/V2 has PLAY and RIGHT switched compared to plain recorder
423
424 ON: PB8, low active (plain recorder) / AN3, low active (fm/v2)
425 OFF: PB4, low active (plain recorder) / AN2, high active (fm/v2)
426
427 Player
428 ------
429 LEFT: AN0
430 MENU: AN1
431 RIGHT: AN2
432 PLAY: AN3
433
434 STOP: PA11
435 ON: PA5
436
437 All buttons are low active
438
439 Ondio
440 -----
441 LEFT, RIGHT, UP, DOWN: connected to AN4 through a resistor network
442
443 The voltage on AN4 depends on which keys (or key combo) is pressed
444
445 OPTION: AN2, high active (assigned as MENU)
446 ON/OFF: AN3, low active (assigned as OFF)
447
448*/
449
450#if CONFIG_KEYPAD == RECORDER_PAD
451
452#ifdef HAVE_FMADC
453/* FM Recorder super-special levels */
454#define LEVEL1 150
455#define LEVEL2 385
456#define LEVEL3 545
457#define LEVEL4 700
458#define ROW2_BUTTON1 BUTTON_PLAY
459#define ROW2_BUTTON3 BUTTON_RIGHT
460
461#else
462/* plain bog standard Recorder levels */
463#define LEVEL1 250
464#define LEVEL2 500
465#define LEVEL3 700
466#define LEVEL4 900
467#define ROW2_BUTTON1 BUTTON_RIGHT
468#define ROW2_BUTTON3 BUTTON_PLAY
469#endif /* HAVE_FMADC */
470
471#elif CONFIG_KEYPAD == ONDIO_PAD
472/* Ondio levels */
473#define LEVEL1 165
474#define LEVEL2 415
475#define LEVEL3 585
476#define LEVEL4 755
477
478#endif /* CONFIG_KEYPAD */
479
480/*
481 * Get button pressed from hardware 377 * Get button pressed from hardware
482 */ 378 */
483static int button_read(void) 379static int button_read(void)
484{ 380{
485 int btn = BUTTON_NONE; 381 int btn = button_read_device();
486 int retval; 382 int retval;
487#ifndef TARGET_TREE
488 int data;
489#endif
490
491#ifdef TARGET_TREE
492 btn = button_read_device();
493
494#elif CONFIG_KEYPAD == RECORDER_PAD
495#ifndef HAVE_FMADC
496 static int off_button_count = 0;
497#endif
498
499 /* check F1..F3 and UP */
500 data = adc_read(ADC_BUTTON_ROW1);
501 if (data >= LEVEL1)
502 {
503 if (data >= LEVEL3)
504 if (data >= LEVEL4)
505 btn = BUTTON_F3;
506 else
507 btn = BUTTON_UP;
508 else
509 if (data >= LEVEL2)
510 btn = BUTTON_F2;
511 else
512 btn = BUTTON_F1;
513 }
514
515 /* Some units have mushy keypads, so pressing UP also activates
516 the Left/Right buttons. Let's combat that by skipping the AN5
517 checks when UP is pressed. */
518 if(!(btn & BUTTON_UP))
519 {
520 /* check DOWN, PLAY, LEFT, RIGHT */
521 data = adc_read(ADC_BUTTON_ROW2);
522 if (data >= LEVEL1)
523 {
524 if (data >= LEVEL3)
525 if (data >= LEVEL4)
526 btn |= BUTTON_DOWN;
527 else
528 btn |= ROW2_BUTTON3;
529 else
530 if (data >= LEVEL2)
531 btn |= BUTTON_LEFT;
532 else
533 btn |= ROW2_BUTTON1;
534 }
535 }
536
537#ifdef HAVE_FMADC
538 if ( adc_read(ADC_BUTTON_ON) < 512 )
539 btn |= BUTTON_ON;
540 if ( adc_read(ADC_BUTTON_OFF) > 512 )
541 btn |= BUTTON_OFF;
542#else
543 /* check port B pins for ON and OFF */
544 data = PBDR;
545 if ((data & 0x0100) == 0)
546 btn |= BUTTON_ON;
547
548 if ((data & 0x0010) == 0)
549 {
550 /* When the batteries are low, the low-battery shutdown logic causes
551 * spurious OFF events due to voltage fluctuation on some units.
552 * Only accept OFF when read several times in sequence. */
553 if (++off_button_count > 3)
554 btn |= BUTTON_OFF;
555 }
556 else
557 off_button_count = 0;
558#endif
559
560#elif CONFIG_KEYPAD == PLAYER_PAD
561 /* buttons are active low */
562 if (adc_read(0) < 0x180)
563 btn = BUTTON_LEFT;
564 if (adc_read(1) < 0x180)
565 btn |= BUTTON_MENU;
566 if(adc_read(2) < 0x180)
567 btn |= BUTTON_RIGHT;
568 if(adc_read(3) < 0x180)
569 btn |= BUTTON_PLAY;
570
571 /* check port A pins for ON and STOP */
572 data = PADR;
573 if ( !(data & 0x0020) )
574 btn |= BUTTON_ON;
575 if ( !(data & 0x0800) )
576 btn |= BUTTON_STOP;
577
578#elif CONFIG_KEYPAD == ONDIO_PAD
579 /* Check the 4 direction keys */
580 data = adc_read(ADC_BUTTON_ROW1);
581 if (data >= LEVEL1)
582 {
583 if (data >= LEVEL3)
584 if (data >= LEVEL4)
585 btn = BUTTON_LEFT;
586 else
587 btn = BUTTON_RIGHT;
588 else
589 if (data >= LEVEL2)
590 btn = BUTTON_UP;
591 else
592 btn = BUTTON_DOWN;
593 }
594
595 if(adc_read(ADC_BUTTON_OPTION) > 0x200) /* active high */
596 btn |= BUTTON_MENU;
597 if(adc_read(ADC_BUTTON_ONOFF) < 0x120) /* active low */
598 btn |= BUTTON_OFF;
599
600#endif /* CONFIG_KEYPAD */
601 383
602#ifdef HAVE_LCD_BITMAP 384#ifdef HAVE_LCD_BITMAP
603 if (btn && flipped) 385 if (btn && flipped)
diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c
index 866d7616ed..142f67e609 100644
--- a/firmware/drivers/serial.c
+++ b/firmware/drivers/serial.c
@@ -33,7 +33,8 @@
33/* FIX: this doesn't work on iRiver or iPod yet */ 33/* FIX: this doesn't work on iRiver or iPod yet */
34/* iFP7xx has no remote */ 34/* iFP7xx has no remote */
35 35
36#ifndef HAVE_MMC /* MMC takes serial port 1, so don't mess with it */ 36#if !defined(HAVE_FMADC) /* Recorder FM/V2 has no remote control pin */ \
37 && !defined(HAVE_MMC) /* MMC takes serial port 1, so don't mess with it */
37 38
38/* Received byte identifiers */ 39/* Received byte identifiers */
39#define PLAY 0xC1 40#define PLAY 0xC1
@@ -51,8 +52,8 @@ void serial_setup (void)
51 SMR1 = 0x00; 52 SMR1 = 0x00;
52 SCR1 = 0; 53 SCR1 = 0;
53 BRR1 = (FREQ/(32*9600))-1; 54 BRR1 = (FREQ/(32*9600))-1;
54 SSR1 &= 0; /* The status bits must be read before they are cleared, 55 and_b(0, &SSR1); /* The status bits must be read before they are cleared,
55 so we do an AND operation */ 56 so we do an AND operation */
56 57
57 /* Let the hardware settle. The serial port needs to wait "at least 58 /* Let the hardware settle. The serial port needs to wait "at least
58 the interval required to transmit or receive one bit" before it 59 the interval required to transmit or receive one bit" before it
@@ -75,7 +76,7 @@ int remote_control_rx(void)
75 76
76 /* Errors? Just clear'em. The receiver stops if we don't */ 77 /* Errors? Just clear'em. The receiver stops if we don't */
77 if(SSR1 & (SCI_ORER | SCI_FER | SCI_PER)) { 78 if(SSR1 & (SCI_ORER | SCI_FER | SCI_PER)) {
78 SSR1 &= ~(SCI_ORER | SCI_FER | SCI_PER); 79 and_b(~(SCI_ORER | SCI_FER | SCI_PER), &SSR1);
79 last_valid_button = BUTTON_NONE; 80 last_valid_button = BUTTON_NONE;
80 last_was_error = true; 81 last_was_error = true;
81 return BUTTON_NONE; 82 return BUTTON_NONE;
@@ -84,7 +85,7 @@ int remote_control_rx(void)
84 if(SSR1 & SCI_RDRF) { 85 if(SSR1 & SCI_RDRF) {
85 /* Read byte and clear the Rx Full bit */ 86 /* Read byte and clear the Rx Full bit */
86 btn = RDR1; 87 btn = RDR1;
87 SSR1 &= ~SCI_RDRF; 88 and_b(~SCI_RDRF, &SSR1);
88 89
89 if(last_was_error) 90 if(last_was_error)
90 { 91 {
@@ -93,38 +94,36 @@ int remote_control_rx(void)
93 } 94 }
94 else 95 else
95 { 96 {
96#if CONFIG_KEYPAD != ONDIO_PAD
97 switch (btn) 97 switch (btn)
98 { 98 {
99 case STOP: 99 case STOP:
100 last_valid_button = BUTTON_RC_STOP; 100 last_valid_button = BUTTON_RC_STOP;
101 break; 101 break;
102 102
103 case PLAY: 103 case PLAY:
104 last_valid_button = BUTTON_RC_PLAY; 104 last_valid_button = BUTTON_RC_PLAY;
105 break; 105 break;
106 106
107 case VOLUP: 107 case VOLUP:
108 last_valid_button = BUTTON_RC_VOL_UP; 108 last_valid_button = BUTTON_RC_VOL_UP;
109 break; 109 break;
110 110
111 case VOLDN: 111 case VOLDN:
112 last_valid_button = BUTTON_RC_VOL_DOWN; 112 last_valid_button = BUTTON_RC_VOL_DOWN;
113 break; 113 break;
114 114
115 case PREV: 115 case PREV:
116 last_valid_button = BUTTON_RC_LEFT; 116 last_valid_button = BUTTON_RC_LEFT;
117 break; 117 break;
118 118
119 case NEXT: 119 case NEXT:
120 last_valid_button = BUTTON_RC_RIGHT; 120 last_valid_button = BUTTON_RC_RIGHT;
121 break; 121 break;
122 122
123 default: 123 default:
124 last_valid_button = BUTTON_NONE; 124 last_valid_button = BUTTON_NONE;
125 break; 125 break;
126 } 126 }
127#endif
128 } 127 }
129 } 128 }
130 else 129 else
@@ -142,7 +141,7 @@ int remote_control_rx(void)
142 return ret; 141 return ret;
143} 142}
144 143
145#endif /* HAVE_MMC */ 144#endif /* !HAVE_FMADC && !HAVE_MMC */
146#elif defined(CPU_COLDFIRE) && defined(HAVE_SERIAL) 145#elif defined(CPU_COLDFIRE) && defined(HAVE_SERIAL)
147 146
148void serial_tx(const unsigned char *buf) 147void serial_tx(const unsigned char *buf)
diff --git a/firmware/export/button.h b/firmware/export/button.h
index 9c0fe639a6..102d542d27 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -22,11 +22,8 @@
22 22
23#include <stdbool.h> 23#include <stdbool.h>
24#include "config.h" 24#include "config.h"
25#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ 25#include "button-target.h"
26 (CONFIG_KEYPAD == IRIVER_H300_PAD) 26
27#define HAS_BUTTON_HOLD
28#define HAS_REMOTE_BUTTON_HOLD
29#endif
30extern struct event_queue button_queue; 27extern struct event_queue button_queue;
31 28
32void button_init (void); 29void button_init (void);
@@ -44,12 +41,6 @@ void set_remote_backlight_filter_keypress(bool value);
44#endif 41#endif
45#endif 42#endif
46 43
47#ifdef HAS_BUTTON_HOLD
48bool button_hold(void);
49#endif
50#ifdef HAS_REMOTE_BUTTON_HOLD
51bool remote_button_hold(void);
52#endif
53#ifdef HAVE_HEADPHONE_DETECTION 44#ifdef HAVE_HEADPHONE_DETECTION
54bool headphones_inserted(void); 45bool headphones_inserted(void);
55#endif 46#endif
@@ -58,116 +49,10 @@ int wheel_status(void);
58void wheel_send_events(bool send); 49void wheel_send_events(bool send);
59#endif 50#endif
60 51
61#define BUTTON_NONE 0x00000000 52#define BUTTON_NONE 0x00000000
62
63 /* Button modifiers */
64#define BUTTON_REL 0x02000000
65#define BUTTON_REPEAT 0x04000000
66
67
68#ifdef TARGET_TREE
69#include "button-target.h"
70#else
71
72 /* Target specific button codes */
73#if CONFIG_KEYPAD == RECORDER_PAD
74
75 /* Recorder specific button codes */
76
77 /* Main unit's buttons */
78#define BUTTON_ON 0x00000001
79#define BUTTON_OFF 0x00000002
80
81#define BUTTON_LEFT 0x00000004
82#define BUTTON_RIGHT 0x00000008
83#define BUTTON_UP 0x00000010
84#define BUTTON_DOWN 0x00000020
85
86#define BUTTON_PLAY 0x00000040
87
88#define BUTTON_F1 0x00000080
89#define BUTTON_F2 0x00000100
90#define BUTTON_F3 0x00000200
91
92#define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT\
93 |BUTTON_UP|BUTTON_DOWN|BUTTON_PLAY\
94 |BUTTON_F1|BUTTON_F2|BUTTON_F3)
95
96 /* Remote control's buttons */
97#define BUTTON_RC_PLAY 0x00100000
98#define BUTTON_RC_STOP 0x00080000
99
100#define BUTTON_RC_LEFT 0x00040000
101#define BUTTON_RC_RIGHT 0x00020000
102#define BUTTON_RC_VOL_UP 0x00010000
103#define BUTTON_RC_VOL_DOWN 0x00008000
104
105#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_STOP\
106 |BUTTON_RC_LEFT|BUTTON_RC_RIGHT\
107 |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN)
108
109#elif CONFIG_KEYPAD == PLAYER_PAD
110 53
111 /* Main unit's buttons */ 54/* Button modifiers */
112#define BUTTON_ON 0x00000001 55#define BUTTON_REL 0x02000000
113#define BUTTON_STOP 0x00000002 56#define BUTTON_REPEAT 0x04000000
114
115#define BUTTON_LEFT 0x00000004
116#define BUTTON_RIGHT 0x00000008
117#define BUTTON_PLAY 0x00000010
118#define BUTTON_MENU 0x00000020
119
120#define BUTTON_MAIN (BUTTON_ON|BUTTON_STOP|BUTTON_LEFT|BUTTON_RIGHT\
121 |BUTTON_PLAY|BUTTON_MENU)
122
123 /* Remote control's buttons */
124#define BUTTON_RC_PLAY 0x00100000
125#define BUTTON_RC_STOP 0x00080000
126
127#define BUTTON_RC_LEFT 0x00040000
128#define BUTTON_RC_RIGHT 0x00020000
129#define BUTTON_RC_VOL_UP 0x00010000
130#define BUTTON_RC_VOL_DOWN 0x00008000
131
132#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_STOP\
133 |BUTTON_RC_LEFT|BUTTON_RC_RIGHT\
134 |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN)
135
136
137#elif CONFIG_KEYPAD == ONDIO_PAD
138
139 /* Ondio specific button codes */
140
141#define BUTTON_OFF 0x00000001
142#define BUTTON_MENU 0x00000002
143
144#define BUTTON_LEFT 0x00000004
145#define BUTTON_RIGHT 0x00000008
146#define BUTTON_UP 0x00000010
147#define BUTTON_DOWN 0x00000020
148
149#define BUTTON_MAIN (BUTTON_OFF|BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT\
150 |BUTTON_UP|BUTTON_DOWN)
151
152#define BUTTON_REMOTE 0
153
154#elif 0
155
156/*
157 * Please, add the next Rockbox target's button defines here,
158 * using:
159 * - bits 0 and up: for main unit's buttons
160 * - bits 20 (0x00100000) and downwards for the remote buttons (if applicable)
161 * Don't forget to add BUTTON_MAIN and BUTTON_REMOTE masks
162 * Currently, main buttons on all targets are up to bit 9 (0x00000200),
163 * and remote buttons are down to bit 10 (0x00000400)
164 */
165
166
167
168#endif /* RECORDER/PLAYER/ONDIO KEYPAD */
169
170#endif /* TARGET_TREE */
171 57
172#endif /* _BUTTON_H_ */ 58#endif /* _BUTTON_H_ */
173
diff --git a/firmware/target/coldfire/iriver/button-target.h b/firmware/target/coldfire/iriver/button-target.h
index 3d3247ab80..1702706ce4 100644
--- a/firmware/target/coldfire/iriver/button-target.h
+++ b/firmware/target/coldfire/iriver/button-target.h
@@ -80,6 +80,7 @@ bool button_scan_enabled(void);
80 |BUTTON_RC_SOURCE) 80 |BUTTON_RC_SOURCE)
81 81
82#define POWEROFF_BUTTON BUTTON_OFF 82#define POWEROFF_BUTTON BUTTON_OFF
83#define RC_POWEROFF_BUTTON BUTTON_RC_STOP
83#define POWEROFF_COUNT 10 84#define POWEROFF_COUNT 10
84 85
85#endif /* _BUTTON_TARGET_H_ */ 86#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/sh/archos/fm_v2/button-fm_v2.c b/firmware/target/sh/archos/fm_v2/button-fm_v2.c
new file mode 100755
index 0000000000..c430cf864b
--- /dev/null
+++ b/firmware/target/sh/archos/fm_v2/button-fm_v2.c
@@ -0,0 +1,97 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
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 "system.h"
22#include "button.h"
23#include "backlight.h"
24#include "adc.h"
25
26/*
27 Recorder FM/V2 hardware button hookup
28 =====================================
29
30 F1, F2, F3, UP: connected to AN4 through a resistor network
31 DOWN, PLAY, LEFT, RIGHT: likewise connected to AN5
32
33 The voltage on AN4/ AN5 depends on which keys (or key combo) is pressed
34 FM/V2 has PLAY and RIGHT switched compared to plain recorder
35
36 ON: AN3, low active
37 OFF: AN2, high active
38*/
39
40void button_init_device(void)
41{
42 /* Set PB4 and PB8 as input pins */
43 PBCR1 &= 0xfffc; /* PB8MD = 00 */
44 PBCR2 &= 0xfcff; /* PB4MD = 00 */
45 PBIOR &= ~0x0110; /* Inputs */
46}
47
48int button_read_device(void)
49{
50 int btn = BUTTON_NONE;
51 int data;
52
53 /* check F1..F3 and UP */
54 data = adc_read(ADC_BUTTON_ROW1);
55 if (data >= 150)
56 {
57 if (data >= 545)
58 if (data >= 700)
59 btn = BUTTON_F3;
60 else
61 btn = BUTTON_UP;
62 else
63 if (data >= 385)
64 btn = BUTTON_F2;
65 else
66 btn = BUTTON_F1;
67 }
68
69 /* Some units have mushy keypads, so pressing UP also activates
70 the Left/Right buttons. Let's combat that by skipping the AN5
71 checks when UP is pressed. */
72 if(!(btn & BUTTON_UP))
73 {
74 /* check DOWN, PLAY, LEFT, RIGHT */
75 data = adc_read(ADC_BUTTON_ROW2);
76 if (data >= 150)
77 {
78 if (data >= 545)
79 if (data >= 700)
80 btn |= BUTTON_DOWN;
81 else
82 btn |= BUTTON_RIGHT;
83 else
84 if (data >= 385)
85 btn |= BUTTON_LEFT;
86 else
87 btn |= BUTTON_PLAY;
88 }
89 }
90
91 if ( adc_read(ADC_BUTTON_ON) < 512 )
92 btn |= BUTTON_ON;
93 if ( adc_read(ADC_BUTTON_OFF) > 512 )
94 btn |= BUTTON_OFF;
95
96 return btn;
97}
diff --git a/firmware/target/sh/archos/fm_v2/button-target.h b/firmware/target/sh/archos/fm_v2/button-target.h
new file mode 100755
index 0000000000..3e7b7c6801
--- /dev/null
+++ b/firmware/target/sh/archos/fm_v2/button-target.h
@@ -0,0 +1,53 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
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#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26void button_init_device(void);
27int button_read_device(void);
28
29 /* Main unit's buttons */
30#define BUTTON_ON 0x00000001
31#define BUTTON_OFF 0x00000002
32
33#define BUTTON_LEFT 0x00000004
34#define BUTTON_RIGHT 0x00000008
35#define BUTTON_UP 0x00000010
36#define BUTTON_DOWN 0x00000020
37
38#define BUTTON_PLAY 0x00000040
39
40#define BUTTON_F1 0x00000080
41#define BUTTON_F2 0x00000100
42#define BUTTON_F3 0x00000200
43
44#define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT\
45 |BUTTON_UP|BUTTON_DOWN|BUTTON_PLAY\
46 |BUTTON_F1|BUTTON_F2|BUTTON_F3)
47
48#define BUTTON_REMOTE 0
49
50#define POWEROFF_BUTTON BUTTON_OFF
51#define POWEROFF_COUNT 10
52
53#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/sh/archos/ondio/button-ondio.c b/firmware/target/sh/archos/ondio/button-ondio.c
new file mode 100755
index 0000000000..c8797f743d
--- /dev/null
+++ b/firmware/target/sh/archos/ondio/button-ondio.c
@@ -0,0 +1,65 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
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 "system.h"
22#include "button.h"
23#include "backlight.h"
24#include "adc.h"
25
26/*
27 Ondio hardware button hookup
28 ============================
29
30 LEFT, RIGHT, UP, DOWN: connected to AN4 through a resistor network
31
32 The voltage on AN4 depends on which keys (or key combo) is pressed
33
34 OPTION: AN2, high active (assigned as MENU)
35 ON/OFF: AN3, low active (assigned as OFF)
36*/
37
38int button_read_device(void)
39{
40 int btn = BUTTON_NONE;
41 int data;
42
43 /* Check the 4 direction keys */
44 data = adc_read(ADC_BUTTON_ROW1);
45 if (data >= 165)
46 {
47 if (data >= 585)
48 if (data >= 755)
49 btn = BUTTON_LEFT;
50 else
51 btn = BUTTON_RIGHT;
52 else
53 if (data >= 415)
54 btn = BUTTON_UP;
55 else
56 btn = BUTTON_DOWN;
57 }
58
59 if(adc_read(ADC_BUTTON_OPTION) > 0x200) /* active high */
60 btn |= BUTTON_MENU;
61 if(adc_read(ADC_BUTTON_ONOFF) < 0x120) /* active low */
62 btn |= BUTTON_OFF;
63
64 return btn;
65}
diff --git a/firmware/target/sh/archos/ondio/button-target.h b/firmware/target/sh/archos/ondio/button-target.h
new file mode 100755
index 0000000000..8cb24b92b0
--- /dev/null
+++ b/firmware/target/sh/archos/ondio/button-target.h
@@ -0,0 +1,45 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
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#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26#define button_init_device()
27int button_read_device(void);
28
29#define BUTTON_OFF 0x00000001
30#define BUTTON_MENU 0x00000002
31
32#define BUTTON_LEFT 0x00000004
33#define BUTTON_RIGHT 0x00000008
34#define BUTTON_UP 0x00000010
35#define BUTTON_DOWN 0x00000020
36
37#define BUTTON_MAIN (BUTTON_OFF|BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT\
38 |BUTTON_UP|BUTTON_DOWN)
39
40#define BUTTON_REMOTE 0
41
42#define POWEROFF_BUTTON BUTTON_OFF
43#define POWEROFF_COUNT 10
44
45#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/sh/archos/player/button-player.c b/firmware/target/sh/archos/player/button-player.c
new file mode 100755
index 0000000000..fbc940f7de
--- /dev/null
+++ b/firmware/target/sh/archos/player/button-player.c
@@ -0,0 +1,74 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
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 "system.h"
22#include "button.h"
23#include "backlight.h"
24#include "adc.h"
25
26/*
27 Player hardware button hookup
28 =============================
29
30 Player
31 ------
32 LEFT: AN0
33 MENU: AN1
34 RIGHT: AN2
35 PLAY: AN3
36
37 STOP: PA11
38 ON: PA5
39
40 All buttons are low active
41*/
42
43void button_init_device(void)
44{
45 /* set PA5 and PA11 as input pins */
46 PACR1 &= 0xff3f; /* PA11MD = 00 */
47 PACR2 &= 0xfbff; /* PA5MD = 0 */
48 PAIOR &= ~0x0820; /* Inputs */
49}
50
51int button_read_device(void)
52{
53 int btn = BUTTON_NONE;
54 int data;
55
56 /* buttons are active low */
57 if (adc_read(0) < 0x180)
58 btn = BUTTON_LEFT;
59 if (adc_read(1) < 0x180)
60 btn |= BUTTON_MENU;
61 if (adc_read(2) < 0x180)
62 btn |= BUTTON_RIGHT;
63 if (adc_read(3) < 0x180)
64 btn |= BUTTON_PLAY;
65
66 /* check port A pins for ON and STOP */
67 data = PADR;
68 if ( !(data & 0x0020) )
69 btn |= BUTTON_ON;
70 if ( !(data & 0x0800) )
71 btn |= BUTTON_STOP;
72
73 return btn;
74}
diff --git a/firmware/target/sh/archos/player/button-target.h b/firmware/target/sh/archos/player/button-target.h
new file mode 100755
index 0000000000..c1e0e6646b
--- /dev/null
+++ b/firmware/target/sh/archos/player/button-target.h
@@ -0,0 +1,56 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
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#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26#define HAS_SERIAL_REMOTE
27
28void button_init_device(void);
29int button_read_device(void);
30
31 /* Main unit's buttons */
32#define BUTTON_ON 0x00000001
33#define BUTTON_STOP 0x00000002
34
35#define BUTTON_LEFT 0x00000004
36#define BUTTON_RIGHT 0x00000008
37#define BUTTON_PLAY 0x00000010
38#define BUTTON_MENU 0x00000020
39
40#define BUTTON_MAIN (BUTTON_ON|BUTTON_STOP|BUTTON_LEFT|BUTTON_RIGHT\
41 |BUTTON_PLAY|BUTTON_MENU)
42
43 /* Remote control's buttons */
44#define BUTTON_RC_PLAY 0x00100000
45#define BUTTON_RC_STOP 0x00080000
46
47#define BUTTON_RC_LEFT 0x00040000
48#define BUTTON_RC_RIGHT 0x00020000
49#define BUTTON_RC_VOL_UP 0x00010000
50#define BUTTON_RC_VOL_DOWN 0x00008000
51
52#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_STOP\
53 |BUTTON_RC_LEFT|BUTTON_RC_RIGHT\
54 |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN)
55
56#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/sh/archos/recorder/button-recorder.c b/firmware/target/sh/archos/recorder/button-recorder.c
new file mode 100755
index 0000000000..dc43cce0e0
--- /dev/null
+++ b/firmware/target/sh/archos/recorder/button-recorder.c
@@ -0,0 +1,108 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
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 "system.h"
22#include "button.h"
23#include "backlight.h"
24#include "adc.h"
25
26/*
27 Recorder hardware button hookup
28 ===============================
29
30 F1, F2, F3, UP: connected to AN4 through a resistor network
31 DOWN, PLAY, LEFT, RIGHT: likewise connected to AN5
32
33 The voltage on AN4/ AN5 depends on which keys (or key combo) is pressed
34
35 ON: PB8, low active
36 OFF: PB4, low active
37*/
38
39void button_init_device(void)
40{
41 /* Set PB4 and PB8 as input pins */
42 PBCR1 &= 0xfffc; /* PB8MD = 00 */
43 PBCR2 &= 0xfcff; /* PB4MD = 00 */
44 PBIOR &= ~0x0110; /* Inputs */
45}
46
47int button_read_device(void)
48{
49 int btn = BUTTON_NONE;
50 int data;
51 static int off_button_count = 0;
52
53 /* check F1..F3 and UP */
54 data = adc_read(ADC_BUTTON_ROW1);
55 if (data >= 250)
56 {
57 if (data >= 700)
58 if (data >= 900)
59 btn = BUTTON_F3;
60 else
61 btn = BUTTON_UP;
62 else
63 if (data >= 500)
64 btn = BUTTON_F2;
65 else
66 btn = BUTTON_F1;
67 }
68
69 /* Some units have mushy keypads, so pressing UP also activates
70 the Left/Right buttons. Let's combat that by skipping the AN5
71 checks when UP is pressed. */
72 if(!(btn & BUTTON_UP))
73 {
74 /* check DOWN, PLAY, LEFT, RIGHT */
75 data = adc_read(ADC_BUTTON_ROW2);
76 if (data >= 250)
77 {
78 if (data >= 700)
79 if (data >= 900)
80 btn |= BUTTON_DOWN;
81 else
82 btn |= BUTTON_PLAY;
83 else
84 if (data >= 500)
85 btn |= BUTTON_LEFT;
86 else
87 btn |= BUTTON_RIGHT;
88 }
89 }
90
91 /* check port B pins for ON and OFF */
92 data = PBDR;
93 if ((data & 0x0100) == 0)
94 btn |= BUTTON_ON;
95
96 if ((data & 0x0010) == 0)
97 {
98 /* When the batteries are low, the low-battery shutdown logic causes
99 * spurious OFF events due to voltage fluctuation on some units.
100 * Only accept OFF when read several times in sequence. */
101 if (++off_button_count > 3)
102 btn |= BUTTON_OFF;
103 }
104 else
105 off_button_count = 0;
106
107 return btn;
108}
diff --git a/firmware/target/sh/archos/recorder/button-target.h b/firmware/target/sh/archos/recorder/button-target.h
new file mode 100755
index 0000000000..77665c0ad5
--- /dev/null
+++ b/firmware/target/sh/archos/recorder/button-target.h
@@ -0,0 +1,63 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
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#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26#define HAS_SERIAL_REMOTE
27
28void button_init_device(void);
29int button_read_device(void);
30
31 /* Main unit's buttons */
32#define BUTTON_ON 0x00000001
33#define BUTTON_OFF 0x00000002
34
35#define BUTTON_LEFT 0x00000004
36#define BUTTON_RIGHT 0x00000008
37#define BUTTON_UP 0x00000010
38#define BUTTON_DOWN 0x00000020
39
40#define BUTTON_PLAY 0x00000040
41
42#define BUTTON_F1 0x00000080
43#define BUTTON_F2 0x00000100
44#define BUTTON_F3 0x00000200
45
46#define BUTTON_MAIN (BUTTON_ON|BUTTON_OFF|BUTTON_LEFT|BUTTON_RIGHT\
47 |BUTTON_UP|BUTTON_DOWN|BUTTON_PLAY\
48 |BUTTON_F1|BUTTON_F2|BUTTON_F3)
49
50 /* Remote control's buttons */
51#define BUTTON_RC_PLAY 0x00100000
52#define BUTTON_RC_STOP 0x00080000
53
54#define BUTTON_RC_LEFT 0x00040000
55#define BUTTON_RC_RIGHT 0x00020000
56#define BUTTON_RC_VOL_UP 0x00010000
57#define BUTTON_RC_VOL_DOWN 0x00008000
58
59#define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_STOP\
60 |BUTTON_RC_LEFT|BUTTON_RC_RIGHT\
61 |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN)
62
63#endif /* _BUTTON_TARGET_H_ */
diff --git a/tools/configure b/tools/configure
index 4d82948f5f..4c53612ede 100755
--- a/tools/configure
+++ b/tools/configure
@@ -640,6 +640,9 @@ EOF
640 # firmware/Makefile assumes it is present always, and 2) we will need it when we 640 # firmware/Makefile assumes it is present always, and 2) we will need it when we
641 # build the player simulator 641 # build the player simulator
642 642
643 t_cpu="sh"
644 t_manufacturer="archos"
645 t_model="player"
643 ;; 646 ;;
644 647
645 1|recorder) 648 1|recorder)
@@ -659,6 +662,9 @@ EOF
659 # toolset is the tools within the tools directory that we build for 662 # toolset is the tools within the tools directory that we build for
660 # this particular target. 663 # this particular target.
661 toolset=$archosbitmaptools 664 toolset=$archosbitmaptools
665 t_cpu="sh"
666 t_manufacturer="archos"
667 t_model="recorder"
662 ;; 668 ;;
663 669
664 2|fmrecorder) 670 2|fmrecorder)
@@ -678,6 +684,9 @@ EOF
678 # toolset is the tools within the tools directory that we build for 684 # toolset is the tools within the tools directory that we build for
679 # this particular target. 685 # this particular target.
680 toolset=$archosbitmaptools 686 toolset=$archosbitmaptools
687 t_cpu="sh"
688 t_manufacturer="archos"
689 t_model="fm_v2"
681 ;; 690 ;;
682 691
683 3|recorderv2) 692 3|recorderv2)
@@ -697,6 +706,9 @@ EOF
697 # toolset is the tools within the tools directory that we build for 706 # toolset is the tools within the tools directory that we build for
698 # this particular target. 707 # this particular target.
699 toolset=$archosbitmaptools 708 toolset=$archosbitmaptools
709 t_cpu="sh"
710 t_manufacturer="archos"
711 t_model="fm_v2"
700 ;; 712 ;;
701 713
702 4|ondiosp) 714 4|ondiosp)
@@ -716,6 +728,9 @@ EOF
716 # toolset is the tools within the tools directory that we build for 728 # toolset is the tools within the tools directory that we build for
717 # this particular target. 729 # this particular target.
718 toolset=$archosbitmaptools 730 toolset=$archosbitmaptools
731 t_cpu="sh"
732 t_manufacturer="archos"
733 t_model="ondio"
719 ;; 734 ;;
720 735
721 5|ondiofm) 736 5|ondiofm)
@@ -733,6 +748,9 @@ EOF
733 plugins="yes" 748 plugins="yes"
734 codecs="" 749 codecs=""
735 toolset=$archosbitmaptools 750 toolset=$archosbitmaptools
751 t_cpu="sh"
752 t_manufacturer="archos"
753 t_model="ondio"
736 ;; 754 ;;
737 755
738 10|h120) 756 10|h120)