JuiceBox Code Test Main

From eLinux.org
Jump to: navigation, search
/* 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 */

    /* 8 bits, 2 stop bits, no parity, non-IrDA mode */

    /* Polled RX, polled TX, no break, no loopback, no error interrupts, 
        no RX fifo timeouts, TX level interrupts */

    /* Clear and enable FIFOs */

    /* Disable automatic flow control on handshake lines */

    /* 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! */

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 */

void set_lcd_brightness(unsigned int b)

int main(void)
    unsigned int i;

    /* Turn off display backlight during download */

    /* Dump 2MB ROM to serial port */
    for (i=0; i<0x200000; i++)

    /* Turn backlight to full on once download is complete */

    return 0;