X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=betty%2Ffwbc.c;h=a625716b4123a9b4c6d3f0d4108663a29b87c888;hb=b6437bf5a7811ee84717854f95c515a137eb5b74;hp=6a8f187c55b80db709a2e8c1de7737e0ce3d6805;hpb=90fa4f3eca580f497dd24e9b3afd818d3b1f7054;p=my-code%2Farm.git diff --git a/betty/fwbc.c b/betty/fwbc.c index 6a8f187..a625716 100644 --- a/betty/fwbc.c +++ b/betty/fwbc.c @@ -6,23 +6,75 @@ * */ +#include "lpc2xxx.h" + +#define OSC_CLOCK 10000000 +#define BAUDRATE 9600 +#define P_DIV 4 +#define P_CLOCK (OSC_CLOCK/P_DIV) + +typedef unsigned char u8; +typedef unsigned int u32; + + +/* memory mapping */ + +#define MMAP_BL 0x00 +#define MMAP_RAM 0x02 +#define MMAP_EXT 0x03 + +void mmap_init(u8 memtype) { + + MEMMAP=memtype; +} + void uart0_init(void) { - PINSEL0|=((1<<0)|(1<<2)); /* pin select: tx, rx */ + /* pin select -> tx rx */ + PINSEL0=0x05; + + /* enable fifo */ + UART0_FCR=0x07; + /* set dlab + word length */ + UART0_LCR=0x83; + + /* set baud rate to 9600 @ 10/4 mhz */ + UART0_DLL=0x10; + UART0_DLM=0x00; + + /* unset dlab */ + UART0_LCR=0x03; } -void arm_init(void) { +void uart_send(char *txbuf) { - /* pin selection */ - uart0_init(); + int i; + + i=0; + + while(txbuf[i]) + UART0_THR=txbuf[i++]; + UART0_THR='\n'; + UART0_THR='\r'; + while(!(UART0_LSR&(1<<6))) {} } -void main(void) { +int main(void) { + + char txbuf[]="uart0 working"; + + /* memory mapping of interrupt vectors to static ram */ + mmap_init(MMAP_RAM); /* initialization */ - arm_init(); + uart0_init(); + + while(1) { + uart_send(txbuf); + } + return 0; }