From: hackbard Date: Wed, 8 Aug 2007 16:31:58 +0000 (+0200) Subject: fwbc transmitting 0x23 now, though it's still curious. Makefile updates. X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=commitdiff_plain;h=ba94d4dc80e71b41a6458e028dd45673782bc5f5 fwbc transmitting 0x23 now, though it's still curious. Makefile updates. --- diff --git a/betty/Makefile b/betty/Makefile index 1155b45..a1e44da 100644 --- a/betty/Makefile +++ b/betty/Makefile @@ -3,10 +3,17 @@ CFLAGS = -Wall ARMCC = /scratch/arm-elf/bin/arm-elf-gcc ARMCFLAGS = -Wall -mcpu=arm7tdmi-s - ARMOBJCOPY = /scratch/arm-elf/bin/arm-elf-objcopy -all: lpcload fwbc.hex +HOSTOBJECTS = lpcload + +ARMOBJECTS = fwbc.hex + +# all projects +all: $(HOSTOBJECTS) $(ARMOBJECTS) + +# arm code +arm: arm_clean $(ARMOBJECTS) # fwbc fwbc: @@ -17,3 +24,6 @@ fwbc.hex: fwbc clean: rm -f lpcload fwbc.hex fwbc + +arm_clean: + rm -f fwbc.hex fwbc diff --git a/betty/fwbc.c b/betty/fwbc.c index a625716..9682ee8 100644 --- a/betty/fwbc.c +++ b/betty/fwbc.c @@ -6,48 +6,97 @@ * */ +/* + * 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 + +/* + * type definitions + */ + typedef unsigned char u8; typedef unsigned int u32; +/* + * function prototypes + */ -/* memory mapping */ +void mmap_init(u8 memtype); +void uart0_init(void); +void uart0_send_string(char *txbuf); +void uart0_send_char(char send); -#define MMAP_BL 0x00 -#define MMAP_RAM 0x02 -#define MMAP_EXT 0x03 +/* + * main function + */ -void mmap_init(u8 memtype) { +int main(void) { - MEMMAP=memtype; + /* memory mapping of interrupt vectors to static ram */ + + //mmap_init(MMAP_RAM); + + /* uart initialization */ + +#ifdef USE_FUNCTIONS + //uart0_init(); +#else + 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 +#endif + + /* external memory init */ + + while(1) { + while(!(UART0_LSR&(1<<5))) + continue; + UART0_THR=0x23; + } + + return 0; } -void uart0_init(void) { +/* + * functions + */ - /* pin select -> tx rx */ - PINSEL0=0x05; +void mmap_init(u8 memtype) { - /* enable fifo */ - UART0_FCR=0x07; + MEMMAP=memtype; +} - /* set dlab + word length */ - UART0_LCR=0x83; +void uart0_init(void) { - /* 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; - - /* unset dlab */ - UART0_LCR=0x03; + UART0_LCR=0x03; // unset dlab } -void uart_send(char *txbuf) { +void uart0_send_string(char *txbuf) { int i; @@ -61,20 +110,11 @@ void uart_send(char *txbuf) { while(!(UART0_LSR&(1<<6))) {} } -int main(void) { - - char txbuf[]="uart0 working"; +void uart0_send_char(char send) { - /* memory mapping of interrupt vectors to static ram */ - mmap_init(MMAP_RAM); + while(!(UART0_LSR&(1<<5))) + continue; - /* initialization */ - uart0_init(); - - while(1) { - uart_send(txbuf); - } - - return 0; + UART0_THR=send; }