more testing, still uart0 not working!
[my-code/arm.git] / betty / fwbc.c
index 6a8f187..a625716 100644 (file)
@@ -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;
 }