1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Alan Korr & Nick Robinson
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
25 #include "backlight.h"
31 #if CONFIG_CPU == SH7034
33 /* FIX: this doesn't work on iRiver or iPod yet */
34 /* iFP7xx has no remote */
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 */
39 /* Received byte identifiers */
47 void serial_setup (void)
49 /* Set PB10 function to serial Rx */
50 PBCR1
= (PBCR1
& 0xffcf) | 0x0020;
54 BRR1
= (FREQ
/(32*9600))-1;
55 and_b(0, &SSR1
); /* The status bits must be read before they are cleared,
56 so we do an AND operation */
58 /* Let the hardware settle. The serial port needs to wait "at least
59 the interval required to transmit or receive one bit" before it
63 SCR1
= 0x10; /* Enable the receiver, no interrupt */
66 /* This function returns the received remote control code only if it is
67 received without errors before or after the reception.
68 It therefore returns the received code on the second call after the
69 code has been received. */
70 int remote_control_rx(void)
72 static int last_valid_button
= BUTTON_NONE
;
73 static int last_was_error
= false;
75 int ret
= BUTTON_NONE
;
77 /* Errors? Just clear'em. The receiver stops if we don't */
78 if(SSR1
& (SCI_ORER
| SCI_FER
| SCI_PER
)) {
79 and_b(~(SCI_ORER
| SCI_FER
| SCI_PER
), &SSR1
);
80 last_valid_button
= BUTTON_NONE
;
81 last_was_error
= true;
86 /* Read byte and clear the Rx Full bit */
88 and_b(~SCI_RDRF
, &SSR1
);
92 last_valid_button
= BUTTON_NONE
;
100 last_valid_button
= BUTTON_RC_STOP
;
104 last_valid_button
= BUTTON_RC_PLAY
;
108 last_valid_button
= BUTTON_RC_VOL_UP
;
112 last_valid_button
= BUTTON_RC_VOL_DOWN
;
116 last_valid_button
= BUTTON_RC_LEFT
;
120 last_valid_button
= BUTTON_RC_RIGHT
;
124 last_valid_button
= BUTTON_NONE
;
131 /* This means that a valid remote control character was received
132 the last time we were called, with no receiver errors either before
133 or after. Then we can assume that there really is a remote control
134 attached, and return the button code. */
135 ret
= last_valid_button
;
136 last_valid_button
= BUTTON_NONE
;
139 last_was_error
= false;
144 #endif /* !HAVE_FMADC && !HAVE_MMC */
145 #elif defined(CPU_COLDFIRE) && defined(HAVE_SERIAL)
147 void serial_tx(const unsigned char *buf
)
150 while(!(USR0
& 0x04))
157 void serial_setup (void)
159 UCR0
= 0x30; /* Reset transmitter */
160 UCSR0
= 0xdd; /* Timer mode */
162 UCR0
= 0x10; /* Reset pointer */
163 UMR0
= 0x13; /* No parity, 8 bits */
164 UMR0
= 0x07; /* 1 stop bit */
166 UCR0
= 0x04; /* Tx enable */
169 #else /* Other targets */
170 void serial_setup (void)