/* file: test_1.c */
/* Some CPU register constants */
unsigned long int * const control_e=(unsigned long int*)0x01D20028;
unsigned long int * const port_e=(unsigned long int*)0x01D2002c;
unsigned long int * const ulcon0=(unsigned long int*)0x01D00000;
unsigned long int * const ucon0=(unsigned long int*)0x01D00004;
unsigned long int * const ufcon0=(unsigned long int*)0x01D00008;
unsigned long int * const umcon0=(unsigned long int*)0x01D0000c;
unsigned long int * const utrstat0=(unsigned long int*)0x01D00010;
unsigned long int * const uerstat0=(unsigned long int*)0x01D00014;
unsigned long int * const ufstat0=(unsigned long int*)0x01D00018;
unsigned char * const utxh0=(unsigned char*)0x01D00020;
unsigned long int * const urxh0=(unsigned long int*)0x01D00024;
unsigned long int * const ubrdiv0=(unsigned long int*)0x01D00028;
unsigned long int * const tcmpb1=(unsigned long int*)0x01D5001c;
void uart_init()
{
/* Assign TX and RX pins to the UART */
*control_e&=~0x0c;
*control_e|=0x08;
/* 8 bits, 2 stop bits, no parity, non-IrDA mode */
*ulcon0=0x03;
/* Polled RX, polled TX, no break, no loopback, no error interrupts,
no RX fifo timeouts, TX level interrupts */
*ucon0=0x205;
/* Clear and enable FIFOs */
*ufcon0=7;
/* Disable automatic flow control on handshake lines */
*umcon0=0;
/* Set baud rate divisor
0x20 = 115.2k baud, JB demo app running
0x23 = 115.2k baud, MP3 player app running
The demo app and the MP3 app set the CPU clock to
different frequencies! */
*ubrdiv0=0x20;
}
void uart_tx_byte(unsigned int i)
{
unsigned char c=*(unsigned char*)i;
/* Spin until TX FIFO isn't full */
while ((*ufstat0 & 0x0200)) {};
/* TX byte */
*utxh0=c;
}
void set_lcd_brightness(unsigned int b)
{
*tcmpb1=b;
}
int main(void)
{
unsigned int i;
/* Turn off display backlight during download */
set_lcd_brightness(0);
uart_init();
/* Dump 2MB ROM to serial port */
for (i=0; i<0x200000; i++)
{
uart_tx_byte(i);
}
/* Turn backlight to full on once download is complete */
set_lcd_brightness(0xa00);
for(;;);
return 0;
}