X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=blobdiff_plain;f=betty%2Ffwbc.c;h=e8fea0da70495e3ff944fa98820a5ad0bc51cd93;hp=a625716b4123a9b4c6d3f0d4108663a29b87c888;hb=67e8acdb6e63a64f34120318e44238869891deff;hpb=b6437bf5a7811ee84717854f95c515a137eb5b74 diff --git a/betty/fwbc.c b/betty/fwbc.c index a625716..e8fea0d 100644 --- a/betty/fwbc.c +++ b/betty/fwbc.c @@ -6,48 +6,123 @@ * */ +/* + * include files + */ + #include "lpc2xxx.h" +/* + * defines + */ + +/* misc */ #define OSC_CLOCK 10000000 #define BAUDRATE 9600 #define P_DIV 4 #define P_CLOCK (OSC_CLOCK/P_DIV) +/* memory mapping */ +#define MMAP_BL 0x00 +#define MMAP_RAM 0x02 +#define MMAP_EXT 0x03 + +/* band 0/2 addr */ +#define BANK0 0x80000000 +#define BANK2 0x82000000 + +/* + * type definitions + */ + typedef unsigned char u8; +typedef unsigned short u16; typedef unsigned int u32; +/* + * function prototypes + */ + +void mmap_init(u8 memtype); +void uart0_init(void); +void uart0_send_string(char *txbuf); +void uart0_send_char(char send); -/* memory mapping */ +/* + * main function + */ -#define MMAP_BL 0x00 -#define MMAP_RAM 0x02 -#define MMAP_EXT 0x03 +int main(void) { -void mmap_init(u8 memtype) { + /* variables */ - MEMMAP=memtype; -} + u16 *flash; + u32 i; + u8 start; -void uart0_init(void) { + /* memory mapping of interrupt vectors to static ram */ - /* pin select -> tx rx */ - PINSEL0=0x05; + //mmap_init(MMAP_RAM); - /* enable fifo */ - UART0_FCR=0x07; + /* uart initialization */ - /* set dlab + word length */ - UART0_LCR=0x83; + //uart0_init(); - /* set baud rate to 9600 @ 10/4 mhz */ - UART0_DLL=0x10; + PINSEL0=0x05; // pin select -> tx, rx + UART0_FCR=0x07; // enable fifo + UART0_LCR=0x83; // set dlab + word length + UART0_DLL=0x10; // br: 9600 @ 10/4 mhz UART0_DLM=0x00; + UART0_LCR=0x03; // unset dlab + + /* external memory init */ + + BCFG0=0x1000FBEF; // no boot[1:0] influence? (thnx colibri) + // BCFG2 should be fine as is + flash=(u16 *)BANK0; - /* unset dlab */ - UART0_LCR=0x03; + /* wait for fwdump to send transmit start character */ + start=0; + while(start!=0x23) { + while(!(UART0_LSR&(1<<0))) + continue; + start=UART0_RBR; + } + + /* transmit 1 mb of data */ + for(i=0;i<524288;i++) { + while(!(UART0_LSR&(1<<5))) + continue; + UART0_THR=(*flash&0xff); // care for endianness + while(!(UART0_LSR&(1<<5))) + continue; + UART0_THR=((*flash&0xff00)>>8); + flash++; + } + + return 0; } -void uart_send(char *txbuf) { +/* + * functions + */ + +void mmap_init(u8 memtype) { + + MEMMAP=memtype; +} + +void uart0_init(void) { + + PINSEL0=0x05; // pin select -> tx, rx + UART0_FCR=0x07; // enable fifo + UART0_LCR=0x83; // set dlab + word length + UART0_DLL=0x10; // br: 9600 @ 10/4 mhz + UART0_DLM=0x00; + UART0_LCR=0x03; // unset dlab +} + +void uart0_send_string(char *txbuf) { int i; @@ -61,20 +136,11 @@ void uart_send(char *txbuf) { while(!(UART0_LSR&(1<<6))) {} } -int main(void) { - - char txbuf[]="uart0 working"; - - /* memory mapping of interrupt vectors to static ram */ - mmap_init(MMAP_RAM); - - /* initialization */ - uart0_init(); +void uart0_send_char(char send) { - while(1) { - uart_send(txbuf); - } + while(!(UART0_LSR&(1<<5))) + continue; - return 0; + UART0_THR=send; }