added initial testing fwbc code
authorhackbard <hackbard@staubsauger.localdomain>
Sun, 5 Aug 2007 15:23:58 +0000 (17:23 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Sun, 5 Aug 2007 15:23:58 +0000 (17:23 +0200)
betty/Makefile
betty/fwbc.c

index 3bff9d0..6975542 100644 (file)
@@ -1,5 +1,19 @@
 CC = gcc
 CFLAGS = -Wall
 
-all: lpcload
+ARMCC = /scratch/arm-elf/bin/arm-elf-gcc
+ARMCFLAGS = -Wall -mcpu=arm7tdmi 
 
+ARMOBJCOPY = /scratch/arm-elf/bin/arm-elf-objcopy
+
+all: lpcload fwbc.hex
+
+# fwbc
+fwbc:
+       $(ARMCC) $(ARMCFLAGS) -c fwbc.c -o fwbc
+
+fwbc.hex: fwbc
+       $(ARMOBJCOPY) -O ihex fwbc fwbc.hex
+
+clean:
+       rm -f lpcload fwbc.hex fwbc
index 6a8f187..46a342c 100644 (file)
@@ -6,23 +6,49 @@
  *
  */
 
-void uart0_init(void) {
+#include "lpc2xxx.h"
 
-       PINSEL0|=((1<<0)|(1<<2));       /* pin select: tx, rx */
+#define OSC_CLOCK              10000000
+#define BAUDRATE               9600
+#define P_DIV                  1
+#define P_CLOCK                        (OSC_CLOCK/P_DIV)
 
+typedef unsigned char u8;
+
+void uart0_init(int br) {
+
+       PINSEL0&=~((0x03<<0)|(0x03<<2));        // clear bits 0-3
+       PINSEL0|=((1<<0)|(1<<2));               // pin select: tx, rx
+
+       UART0_LCR|=(1<<7);                      // enable access to divisor
+       UART0_DLL=(P_CLOCK/(br*16))&0xff;       // set divisor
+       UART0_DLL=((P_CLOCK/(br*16))&0xff00)>>8;
+       UART0_LCR&=~(1<<7);                     // disable access to divisor
+
+       UART0_LCR&=~(0x03<<2);                  // 1 stop bit, no parity
+       UART0_LCR|=0x03;                        // 8 data bits
+
+       UART0_FCR=0x01;                         // activate fifo
 }
 
-void arm_init(void) {
+void uart_send(u8 byte) {
 
-       /* pin selection */
-       uart0_init();
+       /* wait for empty transmit buffer */
+       while(!(UART0_LSR&(1<<5)))
+               continue;
 
+       UART0_THR=byte;
 }
 
-void main(void) {
+int main(void) {
 
        /* initialization */
-       arm_init();
+       uart0_init(9600);
+
+       while(1) {
+               uart_send(0x23);
+       }
 
+       return 0;
 }