2002-03-28 15:09:10 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2002-08-12 12:44:18 +00:00
|
|
|
* Copyright (C) 2002 by Alan Korr & Nick Robinson
|
2002-03-28 15:09:10 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2002-08-12 12:44:18 +00:00
|
|
|
#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"
|
2002-04-21 21:50:00 +00:00
|
|
|
#include "serial.h"
|
2002-03-28 15:09:10 +00:00
|
|
|
|
2002-08-12 12:44:18 +00:00
|
|
|
/* Recieved byte identifiers */
|
|
|
|
#define PLAY 0xC1
|
|
|
|
#define STOP 0xC2
|
|
|
|
#define PREV 0xC4
|
|
|
|
#define NEXT 0xC8
|
|
|
|
#define VOLUP 0xD0
|
|
|
|
#define VOLDN 0xE0
|
2002-03-28 15:09:10 +00:00
|
|
|
|
2002-08-12 12:44:18 +00:00
|
|
|
void serial_setup (void)
|
|
|
|
{
|
|
|
|
char dummy;
|
|
|
|
dummy = SSR1;
|
2002-08-13 20:58:03 +00:00
|
|
|
SSR1 = 0;
|
2002-08-12 12:44:18 +00:00
|
|
|
SMR1 = 0x00;
|
2002-08-13 20:58:03 +00:00
|
|
|
SCR1 = 0;
|
2002-08-12 12:44:18 +00:00
|
|
|
BRR1 = (FREQ/(32*9600))-1;
|
2002-08-13 20:58:03 +00:00
|
|
|
|
2002-08-12 12:44:18 +00:00
|
|
|
/* let the hardware settle */
|
2002-08-13 20:58:03 +00:00
|
|
|
sleep(1);
|
2002-08-12 12:44:18 +00:00
|
|
|
|
|
|
|
SCR1 = 0x50;
|
|
|
|
|
|
|
|
/* This enables the serial Rx interrupt*/
|
|
|
|
IPRE = (IPRE & 0x0FFF) | 0x8000; /* Set to medium priority */
|
2002-04-20 13:25:58 +00:00
|
|
|
}
|
2002-03-28 15:09:10 +00:00
|
|
|
|
2002-08-13 20:58:03 +00:00
|
|
|
static void process_byte(int byte)
|
2002-04-20 13:25:58 +00:00
|
|
|
{
|
2002-08-12 12:44:18 +00:00
|
|
|
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;
|
|
|
|
}
|
2002-03-28 15:09:10 +00:00
|
|
|
|
2002-08-12 12:44:18 +00:00
|
|
|
if ( btn ) {
|
|
|
|
queue_post(&button_queue, btn, NULL);
|
|
|
|
backlight_on();
|
|
|
|
queue_post(&button_queue, btn | BUTTON_REL, NULL);
|
|
|
|
}
|
2002-04-20 13:25:58 +00:00
|
|
|
}
|
2002-03-28 15:09:10 +00:00
|
|
|
|
|
|
|
#pragma interrupt
|
|
|
|
void REI1 (void)
|
2002-04-20 13:25:58 +00:00
|
|
|
{
|
2002-08-12 12:44:18 +00:00
|
|
|
SSR1 = SSR1 & ~0x10; /* Clear FER */
|
|
|
|
SSR1 = SSR1 & ~0x40; /* Clear RDRF */
|
2002-04-20 13:25:58 +00:00
|
|
|
}
|
2002-03-28 15:09:10 +00:00
|
|
|
|
|
|
|
#pragma interrupt
|
|
|
|
void RXI1 (void)
|
2002-04-20 13:25:58 +00:00
|
|
|
{
|
2002-08-13 20:58:03 +00:00
|
|
|
unsigned char serial_byte;
|
2002-04-20 13:25:58 +00:00
|
|
|
serial_byte = RDR1;
|
2002-08-12 12:44:18 +00:00
|
|
|
SSR1 = SSR1 & ~0x40; /* Clear RDRF */
|
|
|
|
process_byte(serial_byte);
|
2002-04-20 13:25:58 +00:00
|
|
|
}
|