From: hackbard Date: Sun, 5 Aug 2007 15:23:58 +0000 (+0200) Subject: added initial testing fwbc code X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=commitdiff_plain;h=2cdab277c293b22742ebf7888ca8ac40555f4f1d added initial testing fwbc code --- diff --git a/betty/Makefile b/betty/Makefile index 3bff9d0..6975542 100644 --- a/betty/Makefile +++ b/betty/Makefile @@ -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 diff --git a/betty/fwbc.c b/betty/fwbc.c index 6a8f187..46a342c 100644 --- a/betty/fwbc.c +++ b/betty/fwbc.c @@ -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; }