summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-08-12 12:44:18 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-08-12 12:44:18 +0000
commit18239b831d466e4e3822528462e1a6c00d702e93 (patch)
treea4de386da96b6140bfacae0c70b659332deaaa73
parent1cf6fa07d5b336cd82cb0586f47b69cc92a13b7c (diff)
downloadrockbox-18239b831d466e4e3822528462e1a6c00d702e93.zip
rockbox-18239b831d466e4e3822528462e1a6c00d702e93.tar.gz
rockbox-18239b831d466e4e3822528462e1a6c00d702e93.tar.bz2
rockbox-18239b831d466e4e3822528462e1a6c00d702e93.tar.xz
Remote control support added
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1685 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/main.c6
-rw-r--r--apps/wps.c8
-rw-r--r--firmware/drivers/button.h4
-rw-r--r--firmware/drivers/serial.c111
-rw-r--r--firmware/drivers/serial.h8
5 files changed, 97 insertions, 40 deletions
diff --git a/apps/main.c b/apps/main.c
index 887c85b..307dd71 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -36,6 +36,9 @@
#ifndef SIMULATOR
#include "dmalloc.h"
#include "bmalloc.h"
+#ifndef DEBUG
+#include "serial.h"
+#endif
#endif
#include "mpeg.h"
#include "main_menu.h"
@@ -50,6 +53,7 @@
#include "unicode.h"
#endif
+
char appsversion[]=APPSVERSION;
void init(void);
@@ -98,6 +102,8 @@ void init(void)
#ifdef DEBUG
debug_init();
+#else
+ serial_setup();
#endif
set_irq_level(0);
diff --git a/apps/wps.c b/apps/wps.c
index 4de8738..3137a26 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -296,6 +296,9 @@ int wps_show(void)
#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
+#else
+ case BUTTON_VOL_UP:
+#endif
if (keys_locked)
{
display_keylock_text(keys_locked);
@@ -310,8 +313,12 @@ int wps_show(void)
status_draw();
break;
+#ifdef HAVE_RECORDER_KEYPAD
case BUTTON_DOWN:
case BUTTON_DOWN | BUTTON_REPEAT:
+#else
+ case BUTTON_VOL_DOWN:
+#endif
if (keys_locked)
{
display_keylock_text(keys_locked);
@@ -325,7 +332,6 @@ int wps_show(void)
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
status_draw();
break;
-#endif
case BUTTON_LEFT:
if (keys_locked)
diff --git a/firmware/drivers/button.h b/firmware/drivers/button.h
index 035fedd..6563f1b 100644
--- a/firmware/drivers/button.h
+++ b/firmware/drivers/button.h
@@ -38,6 +38,10 @@ int button_set_release(int newmask);
#define BUTTON_LEFT 0x0040
#define BUTTON_RIGHT 0x0080
+/* remote control buttons */
+#define BUTTON_VOL_UP 0x1000
+#define BUTTON_VOL_DOWN 0x1001
+
/* Button modifiers */
#define BUTTON_REPEAT 0x4000
#define BUTTON_REL 0x8000
diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c
index ca69147..ee83e2a 100644
--- a/firmware/drivers/serial.c
+++ b/firmware/drivers/serial.c
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2002 by Alan Korr
+ * Copyright (C) 2002 by Alan Korr & Nick Robinson
*
* 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.
@@ -16,54 +16,101 @@
* KIND, either express or implied.
*
****************************************************************************/
-
+#include <stdlib.h>
+#include "button.h"
+#include "config.h"
+#include "sh7034.h"
+#include "system.h"
+#include "kernel.h"
+#include "backlight.h"
+#include "adc.h"
+#include "lcd.h"
#include "serial.h"
-static int serial_byte,serial_flag;
+/* Recieved byte identifiers */
+#define PLAY 0xC1
+#define STOP 0xC2
+#define PREV 0xC4
+#define NEXT 0xC8
+#define VOLUP 0xD0
+#define VOLDN 0xE0
-void serial_putc (char byte)
-{
- while (!(SSR1 & 0x80)); /* Wait for TDRE */
- TDR1 = byte;
- SSR1 &= 0x80; /* Clear TDRE */
-}
+void serial_setup (void)
+{
+ char dummy;
+ int i;
+ int j;
+ dummy = SSR1;
+ SSR1=0;
+ SMR1 = 0x00;
+ SCR1=0;
+ BRR1 = (FREQ/(32*9600))-1;
+
+ /* let the hardware settle */
+ for (i = 0; i < 1000; i++)
+ j++;
+
+ SCR1 = 0x50;
+
+ /* This enables the serial Rx interrupt*/
+ IPRE = (IPRE & 0x0FFF) | 0x8000; /* Set to medium priority */
-void serial_puts (char const *string)
-{
- int byte;
- while ((byte = *string++))
- serial_putc (byte);
}
-int serial_getc( void )
+static void process_byte(char byte)
{
- int byte;
- while (!serial_flag);
- byte = serial_byte;
- serial_flag = 0;
- serial_putc (byte);
- return byte;
-}
+ int btn = 0;
+
+ switch (byte)
+ {
+ case STOP:
+#ifdef HAVE_RECORDER_KEYPAD
+ btn = BUTTON_OFF;
+#else
+ btn = BUTTON_STOP;
+#endif
+ break;
+
+ case PLAY:
+ btn = BUTTON_PLAY;
+ break;
+
+ case VOLUP:
+ btn = BUTTON_VOL_UP;
+ break;
+
+ case VOLDN:
+ btn = BUTTON_VOL_DOWN;
+ break;
+
+ case PREV:
+ btn = BUTTON_LEFT;
+ break;
+
+ case NEXT:
+ btn = BUTTON_RIGHT;
+ break;
+ }
-void serial_setup (int baudrate)
-{
- SCR1 = 0;
- SSR1 = 0;
- SMR1 = 0;
- BRR1 = (FREQ/(32*baudrate))-1;
- SCR1 = 0x70;
+ if ( btn ) {
+ queue_post(&button_queue, btn, NULL);
+ backlight_on();
+ queue_post(&button_queue, btn | BUTTON_REL, NULL);
+ }
}
#pragma interrupt
void REI1 (void)
{
- SSR1 &= 0x10; /* Clear FER */
+ SSR1 = SSR1 & ~0x10; /* Clear FER */
+ SSR1 = SSR1 & ~0x40; /* Clear RDRF */
}
#pragma interrupt
void RXI1 (void)
{
+ char serial_byte;
serial_byte = RDR1;
- serial_flag = 1;
- SSR1 &= 0x40; /* Clear RDRF */
+ SSR1 = SSR1 & ~0x40; /* Clear RDRF */
+ process_byte(serial_byte);
}
diff --git a/firmware/drivers/serial.h b/firmware/drivers/serial.h
index eac02e4..d13b785 100644
--- a/firmware/drivers/serial.h
+++ b/firmware/drivers/serial.h
@@ -20,12 +20,6 @@
#ifndef __SERIAL_H__
#define __SERIAL_H__
-#include <sh7034.h>
-#include <system.h>
-
-extern void serial_putc (char);
-extern void serial_puts (char const *);
-extern int serial_getc (void);
-extern void serial_setup (int);
+extern void serial_setup (void);
#endif