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"
|
2005-02-02 21:47:43 +00:00
|
|
|
#include "cpu.h"
|
2002-08-12 12:44:18 +00:00
|
|
|
#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
|
|
|
|
2006-02-05 17:16:34 +00:00
|
|
|
|
|
|
|
#if (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730) && \
|
|
|
|
(CONFIG_CPU != PP5020) && (CONFIG_CPU != PNX0101) && \
|
2006-08-01 22:28:14 +00:00
|
|
|
(CONFIG_CPU != PP5002) && (CONFIG_CPU != MCF5250) && \
|
|
|
|
(CONFIG_CPU != PP5024)
|
2006-02-05 17:16:34 +00:00
|
|
|
|
2005-11-07 23:07:19 +00:00
|
|
|
/* FIX: this doesn't work on iRiver or Gmini or iPod yet */
|
2006-01-12 00:35:50 +00:00
|
|
|
/* iFP7xx has no remote */
|
2005-02-04 15:07:50 +00:00
|
|
|
|
2004-09-20 22:15:35 +00:00
|
|
|
#ifndef HAVE_MMC /* MMC takes serial port 1, so don't mess with it */
|
|
|
|
|
2002-09-04 12:34:13 +00:00
|
|
|
/* Received byte identifiers */
|
2002-08-12 12:44:18 +00:00
|
|
|
#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)
|
2003-07-11 07:30:59 +00:00
|
|
|
{
|
|
|
|
/* Set PB10 function to serial Rx */
|
|
|
|
PBCR1 = (PBCR1 & 0xffcf) | 0x0020;
|
|
|
|
|
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-09-30 08:55:22 +00:00
|
|
|
SSR1 &= 0; /* The status bits must be read before they are cleared,
|
|
|
|
so we do an AND operation */
|
2002-08-13 20:58:03 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
/* Let the hardware settle. The serial port needs to wait "at least
|
|
|
|
the interval required to transmit or receive one bit" before it
|
|
|
|
can be used. */
|
2002-08-13 20:58:03 +00:00
|
|
|
sleep(1);
|
2002-08-12 12:44:18 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
SCR1 = 0x10; /* Enable the receiver, no interrupt */
|
2002-04-20 13:25:58 +00:00
|
|
|
}
|
2002-03-28 15:09:10 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
/* This function returns the received remote control code only if it is
|
|
|
|
received without errors before or after the reception.
|
|
|
|
It therefore returns the received code on the second call after the
|
|
|
|
code has been received. */
|
|
|
|
int remote_control_rx(void)
|
2002-04-20 13:25:58 +00:00
|
|
|
{
|
2002-09-30 08:55:22 +00:00
|
|
|
static int last_valid_button = BUTTON_NONE;
|
|
|
|
static int last_was_error = false;
|
|
|
|
int btn;
|
|
|
|
int ret = BUTTON_NONE;
|
|
|
|
|
|
|
|
/* Errors? Just clear'em. The receiver stops if we don't */
|
|
|
|
if(SSR1 & (SCI_ORER | SCI_FER | SCI_PER)) {
|
|
|
|
SSR1 &= ~(SCI_ORER | SCI_FER | SCI_PER);
|
|
|
|
last_valid_button = BUTTON_NONE;
|
|
|
|
last_was_error = true;
|
|
|
|
return BUTTON_NONE;
|
|
|
|
}
|
2002-08-12 12:44:18 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
if(SSR1 & SCI_RDRF) {
|
|
|
|
/* Read byte and clear the Rx Full bit */
|
|
|
|
btn = RDR1;
|
|
|
|
SSR1 &= ~SCI_RDRF;
|
|
|
|
|
|
|
|
if(last_was_error)
|
|
|
|
{
|
|
|
|
last_valid_button = BUTTON_NONE;
|
|
|
|
ret = BUTTON_NONE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-09-28 22:13:26 +00:00
|
|
|
#if CONFIG_KEYPAD != ONDIO_PAD
|
2002-09-30 08:55:22 +00:00
|
|
|
switch (btn)
|
|
|
|
{
|
|
|
|
case STOP:
|
2003-04-23 09:21:37 +00:00
|
|
|
last_valid_button = BUTTON_RC_STOP;
|
2002-09-30 08:55:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PLAY:
|
2003-04-23 09:21:37 +00:00
|
|
|
last_valid_button = BUTTON_RC_PLAY;
|
2002-09-30 08:55:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VOLUP:
|
2003-04-23 09:21:37 +00:00
|
|
|
last_valid_button = BUTTON_RC_VOL_UP;
|
2002-09-30 08:55:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VOLDN:
|
2003-04-23 09:21:37 +00:00
|
|
|
last_valid_button = BUTTON_RC_VOL_DOWN;
|
2002-09-30 08:55:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PREV:
|
2003-04-23 09:21:37 +00:00
|
|
|
last_valid_button = BUTTON_RC_LEFT;
|
2002-09-30 08:55:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NEXT:
|
2003-04-23 09:21:37 +00:00
|
|
|
last_valid_button = BUTTON_RC_RIGHT;
|
2002-09-30 08:55:22 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
last_valid_button = BUTTON_NONE;
|
|
|
|
break;
|
|
|
|
}
|
2003-12-12 13:23:33 +00:00
|
|
|
#endif
|
2002-09-30 08:55:22 +00:00
|
|
|
}
|
2002-08-12 12:44:18 +00:00
|
|
|
}
|
2002-09-30 08:55:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* This means that a valid remote control character was received
|
|
|
|
the last time we were called, with no receiver errors either before
|
|
|
|
or after. Then we can assume that there really is a remote control
|
|
|
|
attached, and return the button code. */
|
|
|
|
ret = last_valid_button;
|
|
|
|
last_valid_button = BUTTON_NONE;
|
2002-08-12 12:44:18 +00:00
|
|
|
}
|
2002-09-30 08:55:22 +00:00
|
|
|
|
|
|
|
last_was_error = false;
|
2002-03-28 15:09:10 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
return ret;
|
2002-04-20 13:25:58 +00:00
|
|
|
}
|
2004-09-20 22:15:35 +00:00
|
|
|
|
|
|
|
#endif /* HAVE_MMC */
|
2005-02-04 15:07:50 +00:00
|
|
|
#else /* (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730) */
|
2005-02-02 21:47:43 +00:00
|
|
|
void serial_setup (void)
|
|
|
|
{
|
|
|
|
/* a dummy */
|
|
|
|
}
|
2005-02-04 15:07:50 +00:00
|
|
|
#endif /* ! (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730) */
|