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
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-03-28 15:09:10 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2008-12-25 01:46:16 +00:00
|
|
|
#include <stdio.h>
|
2002-08-12 12:44:18 +00:00
|
|
|
#include <stdlib.h>
|
2008-12-25 01:46:16 +00:00
|
|
|
#include <stdarg.h>
|
2002-08-12 12:44:18 +00:00
|
|
|
#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 "lcd.h"
|
2002-04-21 21:50:00 +00:00
|
|
|
#include "serial.h"
|
2008-12-25 01:46:16 +00:00
|
|
|
#include "iap.h"
|
2002-03-28 15:09:10 +00:00
|
|
|
|
2007-09-22 02:17:08 +00:00
|
|
|
#if CONFIG_CPU == IMX31L
|
|
|
|
#include "serial-imx31.h"
|
|
|
|
#endif
|
2006-02-05 17:16:34 +00:00
|
|
|
|
2006-08-12 08:01:54 +00:00
|
|
|
#if CONFIG_CPU == SH7034
|
2006-02-05 17:16:34 +00:00
|
|
|
|
2006-11-10 20:26:01 +00:00
|
|
|
/* FIX: this doesn't work on iRiver or iPod yet */
|
2006-01-12 00:35:50 +00:00
|
|
|
/* iFP7xx has no remote */
|
2005-02-04 15:07:50 +00:00
|
|
|
|
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
|
|
|
|
2008-12-25 03:23:22 +00:00
|
|
|
void serial_setup (void)
|
2003-07-11 07:30:59 +00:00
|
|
|
{
|
|
|
|
/* Set PB10 function to serial Rx */
|
|
|
|
PBCR1 = (PBCR1 & 0xffcf) | 0x0020;
|
2008-12-25 03:23:22 +00:00
|
|
|
|
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;
|
2006-11-27 02:16:32 +00:00
|
|
|
and_b(0, &SSR1); /* 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
|
|
|
|
2008-12-25 01:46:16 +00:00
|
|
|
int tx_rdy(void)
|
|
|
|
{
|
|
|
|
/* a dummy */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-12-25 03:23:22 +00:00
|
|
|
int rx_rdy(void)
|
2008-12-25 01:46:16 +00:00
|
|
|
{
|
|
|
|
if(SSR1 & SCI_RDRF)
|
2009-01-11 18:13:58 +00:00
|
|
|
return 1;
|
2008-12-25 01:46:16 +00:00
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tx_writec(unsigned char c)
|
|
|
|
{
|
|
|
|
/* a dummy */
|
2008-12-25 03:35:38 +00:00
|
|
|
(void)c;
|
2008-12-25 01:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char rx_readc(void)
|
|
|
|
{
|
|
|
|
char tmp;
|
|
|
|
/* Read byte and clear the Rx Full bit */
|
|
|
|
tmp = RDR1;
|
|
|
|
and_b(~SCI_RDRF, &SSR1);
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
2008-12-25 03:23:22 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
/* Errors? Just clear'em. The receiver stops if we don't */
|
|
|
|
if(SSR1 & (SCI_ORER | SCI_FER | SCI_PER)) {
|
2006-11-27 02:16:32 +00:00
|
|
|
and_b(~(SCI_ORER | SCI_FER | SCI_PER), &SSR1);
|
2002-09-30 08:55:22 +00:00
|
|
|
last_valid_button = BUTTON_NONE;
|
|
|
|
last_was_error = true;
|
|
|
|
return BUTTON_NONE;
|
|
|
|
}
|
2002-08-12 12:44:18 +00:00
|
|
|
|
2008-12-25 01:46:16 +00:00
|
|
|
if(rx_rdy()) {
|
2009-01-11 18:13:58 +00:00
|
|
|
btn = rx_readc();
|
2008-12-25 03:23:22 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
if(last_was_error)
|
|
|
|
{
|
|
|
|
last_valid_button = BUTTON_NONE;
|
|
|
|
ret = BUTTON_NONE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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;
|
2006-11-27 02:16:32 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
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;
|
2006-11-27 02:16:32 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
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;
|
2006-11-27 02:16:32 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
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;
|
2006-11-27 02:16:32 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
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;
|
2006-11-27 02:16:32 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
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;
|
2006-11-27 02:16:32 +00:00
|
|
|
|
2002-09-30 08:55:22 +00:00
|
|
|
default:
|
|
|
|
last_valid_button = BUTTON_NONE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
2008-12-25 03:23:22 +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
|
|
|
|
2009-02-07 11:15:30 +00:00
|
|
|
#elif defined(CPU_COLDFIRE)
|
2006-10-12 20:22:16 +00:00
|
|
|
|
2008-12-25 03:23:22 +00:00
|
|
|
void serial_setup (void)
|
2006-10-12 20:22:16 +00:00
|
|
|
{
|
|
|
|
UCR0 = 0x30; /* Reset transmitter */
|
|
|
|
UCSR0 = 0xdd; /* Timer mode */
|
|
|
|
|
|
|
|
UCR0 = 0x10; /* Reset pointer */
|
|
|
|
UMR0 = 0x13; /* No parity, 8 bits */
|
|
|
|
UMR0 = 0x07; /* 1 stop bit */
|
|
|
|
|
|
|
|
UCR0 = 0x04; /* Tx enable */
|
|
|
|
}
|
|
|
|
|
2008-12-25 01:46:16 +00:00
|
|
|
int tx_rdy(void)
|
|
|
|
{
|
|
|
|
if(USR0 & 0x04)
|
|
|
|
return 1;
|
|
|
|
else
|
2009-01-11 18:13:58 +00:00
|
|
|
return 0;
|
2008-12-25 01:46:16 +00:00
|
|
|
}
|
|
|
|
|
2008-12-25 03:23:22 +00:00
|
|
|
int rx_rdy(void)
|
2008-12-25 01:46:16 +00:00
|
|
|
{
|
|
|
|
/* a dummy */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tx_writec(unsigned char c)
|
|
|
|
{
|
|
|
|
UTB0 = c;
|
|
|
|
}
|
|
|
|
|
2007-09-22 02:17:08 +00:00
|
|
|
#elif (CONFIG_CPU == IMX31L)
|
|
|
|
|
|
|
|
void serial_setup(void)
|
|
|
|
{
|
|
|
|
#ifdef UART_INT /*enable UART Interrupts */
|
2008-02-19 14:30:29 +00:00
|
|
|
UCR1_1 |= (EUARTUCR1_TRDYEN | EUARTUCR1_RRDYEN | EUARTUCR1_TXMPTYEN);
|
2008-02-19 14:15:59 +00:00
|
|
|
UCR4_1 |= (EUARTUCR4_TCEN);
|
2007-09-22 02:17:08 +00:00
|
|
|
#else /*disable UART Interrupts*/
|
2008-02-19 14:15:59 +00:00
|
|
|
UCR1_1 &= ~(EUARTUCR1_TRDYEN | EUARTUCR1_RRDYEN | EUARTUCR1_TXMPTYEN);
|
|
|
|
UCR4_1 &= ~(EUARTUCR4_TCEN);
|
2007-09-22 02:17:08 +00:00
|
|
|
#endif
|
2008-02-19 14:15:59 +00:00
|
|
|
UCR1_1 |= EUARTUCR1_UARTEN;
|
|
|
|
UCR2_1 |= (EUARTUCR2_TXEN | EUARTUCR2_RXEN | EUARTUCR2_IRTS);
|
2007-09-22 02:17:08 +00:00
|
|
|
|
|
|
|
/* Tx,Rx Interrupt Trigger levels, Disable for now*/
|
|
|
|
/*UFCR1 |= (UFCR1_TXTL_32 | UFCR1_RXTL_32);*/
|
|
|
|
}
|
|
|
|
|
2008-02-19 14:15:59 +00:00
|
|
|
int tx_rdy(void)
|
2007-09-22 02:17:08 +00:00
|
|
|
{
|
2008-02-19 14:15:59 +00:00
|
|
|
if((UTS1 & EUARTUTS_TXEMPTY))
|
2007-09-22 02:17:08 +00:00
|
|
|
return 1;
|
2008-02-19 14:15:59 +00:00
|
|
|
else
|
|
|
|
return 0;
|
2007-09-22 02:17:08 +00:00
|
|
|
}
|
|
|
|
|
2008-12-25 03:23:22 +00:00
|
|
|
/*Not ready...After first Rx, UTS1 & UTS1_RXEMPTY
|
2007-09-22 02:17:08 +00:00
|
|
|
keeps returning true*/
|
2008-12-25 03:23:22 +00:00
|
|
|
int rx_rdy(void)
|
2007-09-22 02:17:08 +00:00
|
|
|
{
|
2008-02-19 14:15:59 +00:00
|
|
|
if(!(UTS1 & EUARTUTS_RXEMPTY))
|
2007-09-22 02:17:08 +00:00
|
|
|
return 1;
|
2008-02-19 14:15:59 +00:00
|
|
|
else
|
|
|
|
return 0;
|
2007-09-22 02:17:08 +00:00
|
|
|
}
|
|
|
|
|
2008-12-25 01:46:16 +00:00
|
|
|
void tx_writec(unsigned char c)
|
2007-09-22 02:17:08 +00:00
|
|
|
{
|
|
|
|
UTXD1=(int) c;
|
|
|
|
}
|
|
|
|
|
2008-12-25 01:46:16 +00:00
|
|
|
#elif defined(IPOD_ACCESSORY_PROTOCOL)
|
|
|
|
static int autobaud = 0;
|
|
|
|
void serial_setup (void)
|
|
|
|
{
|
|
|
|
int tmp;
|
2008-12-25 03:23:22 +00:00
|
|
|
|
2011-02-12 21:28:23 +00:00
|
|
|
#if defined(IPOD_COLOR) || defined(IPOD_4G)
|
2008-12-25 01:46:16 +00:00
|
|
|
/* Route the Tx/Rx pins. 4G Ipod??? */
|
|
|
|
outl(0x70000018, inl(0x70000018) & ~0xc00);
|
2011-02-12 21:28:23 +00:00
|
|
|
#elif defined(IPOD_NANO) || defined(IPOD_VIDEO)
|
2008-12-25 01:46:16 +00:00
|
|
|
/* Route the Tx/Rx pins. 5G Ipod */
|
|
|
|
(*(volatile unsigned long *)(0x7000008C)) &= ~0x0C;
|
|
|
|
GPO32_ENABLE &= ~0x0C;
|
|
|
|
#endif
|
2008-12-25 03:23:22 +00:00
|
|
|
|
2008-12-25 01:46:16 +00:00
|
|
|
DEV_EN = DEV_EN | DEV_SER0;
|
|
|
|
CPU_HI_INT_DIS = SER0_MASK;
|
|
|
|
|
|
|
|
DEV_RS |= DEV_SER0;
|
|
|
|
sleep(1);
|
|
|
|
DEV_RS &= ~DEV_SER0;
|
|
|
|
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLM = 0x00;
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
SER0_IER = 0x01;
|
|
|
|
|
|
|
|
SER0_FCR = 0x07; /* Tx+Rx FIFO reset and FIFO enable */
|
|
|
|
|
|
|
|
CPU_INT_EN |= HI_MASK;
|
|
|
|
CPU_HI_INT_EN |= SER0_MASK;
|
|
|
|
tmp = SER0_RBR;
|
|
|
|
|
|
|
|
serial_bitrate(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void serial_bitrate(int rate)
|
|
|
|
{
|
|
|
|
if(rate == 0)
|
|
|
|
{
|
2009-01-11 18:13:58 +00:00
|
|
|
autobaud = 2;
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x0D; /* 24000000/13/16 = 115384 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
2008-12-25 01:46:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
autobaud = 0;
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 24000000L / rate / 16;
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
}
|
|
|
|
|
|
|
|
int tx_rdy(void)
|
|
|
|
{
|
|
|
|
if((SER0_LSR & 0x20))
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-25 03:23:22 +00:00
|
|
|
int rx_rdy(void)
|
2008-12-25 01:46:16 +00:00
|
|
|
{
|
|
|
|
if((SER0_LSR & 0x1))
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tx_writec(unsigned char c)
|
|
|
|
{
|
|
|
|
SER0_THR =(int) c;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char rx_readc(void)
|
|
|
|
{
|
|
|
|
return (SER0_RBR & 0xFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SERIAL0(void)
|
|
|
|
{
|
|
|
|
static int badbaud = 0;
|
|
|
|
static bool newpkt = true;
|
|
|
|
char temp;
|
2008-12-25 03:23:22 +00:00
|
|
|
|
2008-12-25 01:46:16 +00:00
|
|
|
while(rx_rdy())
|
|
|
|
{
|
2009-01-11 18:13:58 +00:00
|
|
|
temp = rx_readc();
|
|
|
|
if (newpkt && autobaud > 0)
|
|
|
|
{
|
|
|
|
if (autobaud == 1)
|
|
|
|
{
|
|
|
|
switch (temp)
|
|
|
|
{
|
|
|
|
case 0xFF:
|
|
|
|
case 0x55:
|
|
|
|
break;
|
|
|
|
case 0xFC:
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x4E; /* 24000000/78/16 = 19230 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
temp = 0xFF;
|
|
|
|
break;
|
|
|
|
case 0xE0:
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x9C; /* 24000000/156/16 = 9615 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
temp = 0xFF;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
badbaud++;
|
|
|
|
if (badbaud >= 6) /* Switch baud detection mode */
|
|
|
|
{
|
|
|
|
autobaud = 2;
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x0D; /* 24000000/13/16 = 115384 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
badbaud = 0;
|
|
|
|
} else {
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x1A; /* 24000000/26/16 = 57692 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (temp)
|
|
|
|
{
|
|
|
|
case 0xFF:
|
|
|
|
case 0x55:
|
|
|
|
break;
|
|
|
|
case 0xFE:
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x1A; /* 24000000/26/16 = 57692 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
temp = 0xFF;
|
|
|
|
break;
|
|
|
|
case 0xFC:
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x27; /* 24000000/39/16 = 38461 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
temp = 0xFF;
|
|
|
|
break;
|
|
|
|
case 0xE0:
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x4E; /* 24000000/78/16 = 19230 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
temp = 0xFF;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
badbaud++;
|
|
|
|
if (badbaud >= 6) /* Switch baud detection */
|
|
|
|
{
|
|
|
|
autobaud = 1;
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x1A; /* 24000000/26/16 = 57692 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
badbaud = 0;
|
|
|
|
} else {
|
|
|
|
SER0_LCR = 0x80; /* Divisor latch enable */
|
|
|
|
SER0_DLL = 0x0D; /* 24000000/13/16 = 115384 baud */
|
|
|
|
SER0_LCR = 0x03; /* Divisor latch disable, 8-N-1 */
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bool pkt = iap_getc(temp);
|
2010-01-02 16:03:30 +00:00
|
|
|
if(newpkt && !pkt)
|
2009-01-11 18:13:58 +00:00
|
|
|
autobaud = 0; /* Found good baud */
|
|
|
|
newpkt = pkt;
|
2008-12-25 01:46:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-09-22 02:17:08 +00:00
|
|
|
void dprintf(const char * str, ... )
|
|
|
|
{
|
|
|
|
char dprintfbuff[256];
|
2008-12-25 01:46:16 +00:00
|
|
|
char * ptr;
|
2008-12-25 03:23:22 +00:00
|
|
|
|
2007-09-22 02:17:08 +00:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, str);
|
|
|
|
|
|
|
|
ptr = dprintfbuff;
|
|
|
|
vsnprintf(ptr,sizeof(dprintfbuff),str,ap);
|
|
|
|
va_end(ap);
|
|
|
|
|
2008-12-25 01:46:16 +00:00
|
|
|
serial_tx((unsigned char *)ptr);
|
2007-09-22 02:17:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void serial_tx(const unsigned char * buf)
|
|
|
|
{
|
|
|
|
/*Tx*/
|
|
|
|
for(;;) {
|
2008-02-19 14:15:59 +00:00
|
|
|
if(tx_rdy()) {
|
2007-09-22 02:17:08 +00:00
|
|
|
if(*buf == '\0')
|
|
|
|
return;
|
|
|
|
if(*buf == '\n')
|
2008-02-19 14:15:59 +00:00
|
|
|
tx_writec('\r');
|
|
|
|
tx_writec(*buf);
|
2007-09-22 02:17:08 +00:00
|
|
|
buf++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|