Initial transfer from sourceforge

This commit is contained in:
Telekatz 2017-07-01 21:56:25 +02:00
commit f2259c5424
415 changed files with 73200 additions and 0 deletions

View file

@ -0,0 +1,51 @@
include ../Makefile.inc
all: tool_data.h
ramtool.bin: ramtool.elf
$(OC) -O binary ramtool.elf ramtool.bin
ramtool.elf: crt.o serial.o lcd.o fonty.o flash.o ramtool.o lpc2220.ld
$(LD) $(LDFLAGS) -o ramtool.elf crt.o serial.o lcd.o fonty.o flash.o ramtool.o
romtool.bin: romtool.elf
$(OC) -O binary romtool.elf romtool.bin
romtool.elf: crt.o serial.o lcd.o fonty.o flash.o romtool.o lpc2220_rom.ld
$(LD) $(ROMLDFLAGS) -o romtool.elf crt.o serial.o lcd.o fonty.o flash.o romtool.o
crt.o: crt.s
$(AS) $(ASFLAGS) -o crt.o crt.s
flash.o: flash.c flash.h serial.h lcd.h
$(CC) $(CFLAGS) -o flash.o flash.c
lcd.o: lcd.c lcd.h lpc2220.h
$(CC) $(CFLAGS) -o lcd.o lcd.c
fonty.o: fonty.c fonty.h charset.bits charset.info lcd.h
$(CC) $(CFLAGS) -o fonty.o fonty.c
serial.o: serial.c serial.h lcd.h lpc2220.h
$(CC) $(CFLAGS) -o serial.o serial.c
ramtool.o: ramtool.c serial.o lcd.h flash.h lpc2220.h
$(CC) $(CFLAGS) -o ramtool.o ramtool.c
romtool.o: ramtool.c serial.o lcd.h flash.h lpc2220.h
$(CC) $(CFLAGS) -DRESIDENT -o romtool.o ramtool.c
bin2h: bin2h.c ramtool.bin
gcc -Os bin2h.c -o bin2h
strip bin2h
tool_data.h: bin2h
./bin2h > tool_data.h
mv tool_data.h ..
clean:
$(RM) *.o ramtool.elf ramtool.bin romtool.elf romtool.bin *~ bin2h
### EOF

View file

@ -0,0 +1,30 @@
#include "stdio.h"
#include "string.h"
#include <fcntl.h>
int main(void)
{
int fd;
unsigned long cnt, cnt2;
unsigned char buf[0x10000];
fd = open("ramtool.bin", O_RDONLY);
if(fd)
{
cnt = read(fd, buf, 0x10000);
cnt2 = 0;
printf("#define tool_len 0x%08lX\n",cnt);
printf("const unsigned char tool_data[] = {\n\t");
while(cnt--)
{
printf("0x%02X,",buf[cnt2++]);
if((cnt2 & 0x0F) == 0)
printf("\n\t");
}
printf("\n};\n");
close(fd);
}
return 0;
}

View file

@ -0,0 +1,118 @@
const unsigned char charset_bits[] = {
0x80, 0xc0, 0x80, 0xe0, 0x80, 0xc0, 0x80, 0xf0, 0x01, 0x03, 0x01, 0x07,
0x01, 0x03, 0x01, 0x0f, 0x80, 0x88, 0xaa, 0xff, 0xff, 0xaa, 0x88, 0x80,
0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x00, 0xf0, 0x00, 0x03, 0x00, 0x07,
0x00, 0x03, 0x00, 0x0f, 0x80, 0x88, 0xaa, 0xab, 0xab, 0xaa, 0x88, 0x80,
0x80, 0x80, 0x80, 0x70, 0x01, 0x01, 0x01, 0x0e, 0x0e, 0x01, 0x01, 0x01,
0x70, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x00, 0x24,
0x00, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x80, 0x00, 0x80,
0x00, 0x80, 0x00, 0x92, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xaa,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xaa, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x81,
0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xaa, 0x02, 0x05, 0x02, 0x00,
0x3e, 0x41, 0x41, 0x22, 0x02, 0x05, 0x02, 0x00, 0x7f, 0x09, 0x09, 0x01,
0x1c, 0x22, 0x41, 0x4f, 0x41, 0x22, 0x1c, 0x1c, 0x22, 0x41, 0x4f, 0x47,
0x22, 0x1c, 0x1c, 0x22, 0x41, 0x4f, 0x4f, 0x2e, 0x1c, 0x1c, 0x22, 0x41,
0x4f, 0x5f, 0x3e, 0x1c, 0x1c, 0x22, 0x41, 0x7f, 0x7f, 0x3e, 0x1c, 0x1c,
0x22, 0x71, 0x7f, 0x7f, 0x3e, 0x1c, 0x1c, 0x3a, 0x79, 0x7f, 0x7f, 0x3e,
0x1c, 0x1c, 0x3e, 0x7d, 0x7f, 0x7f, 0x3e, 0x1c, 0x1c, 0x3e, 0x7f, 0x7f,
0x7f, 0x3e, 0x1c, 0x00, 0x00, 0x5f, 0x03, 0x00, 0x03, 0x14, 0x7f, 0x14,
0x7f, 0x14, 0x24, 0x4a, 0xff, 0x4a, 0x32, 0x63, 0x13, 0x08, 0x64, 0x63,
0x36, 0x49, 0x55, 0x22, 0x50, 0x03, 0x1c, 0x22, 0x41, 0x41, 0x22, 0x1c,
0x14, 0x08, 0x3e, 0x08, 0x14, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x80, 0x60,
0x60, 0x08, 0x08, 0x08, 0x08, 0x08, 0x60, 0x60, 0xc0, 0x30, 0x0c, 0x03,
0x3e, 0x51, 0x49, 0x45, 0x3e, 0x00, 0x42, 0x7f, 0x40, 0x00, 0x42, 0x61,
0x51, 0x49, 0x46, 0x22, 0x41, 0x49, 0x49, 0x36, 0x18, 0x14, 0x12, 0x7f,
0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3e, 0x49, 0x49, 0x49, 0x32, 0x61,
0x11, 0x09, 0x05, 0x03, 0x36, 0x49, 0x49, 0x49, 0x36, 0x26, 0x49, 0x49,
0x49, 0x3e, 0x6c, 0x6c, 0x80, 0x6c, 0x6c, 0x08, 0x14, 0x22, 0x41, 0x14,
0x14, 0x14, 0x14, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x51, 0x09, 0x06,
0x3e, 0x41, 0x59, 0x55, 0x5e, 0x7e, 0x09, 0x09, 0x09, 0x7e, 0x7f, 0x49,
0x49, 0x49, 0x36, 0x3e, 0x41, 0x41, 0x41, 0x22, 0x7f, 0x41, 0x41, 0x41,
0x3e, 0x7f, 0x49, 0x49, 0x41, 0x41, 0x7f, 0x09, 0x09, 0x01, 0x01, 0x3e,
0x41, 0x41, 0x49, 0x3a, 0x7f, 0x08, 0x08, 0x08, 0x7f, 0x41, 0x7f, 0x41,
0x30, 0x41, 0x41, 0x41, 0x3f, 0x7f, 0x08, 0x14, 0x22, 0x41, 0x7f, 0x40,
0x40, 0x40, 0x40, 0x7f, 0x02, 0x0c, 0x02, 0x7f, 0x7f, 0x02, 0x04, 0x08,
0x7f, 0x3e, 0x41, 0x41, 0x41, 0x3e, 0x7f, 0x09, 0x09, 0x09, 0x06, 0x3e,
0x41, 0x41, 0x41, 0xbe, 0x7f, 0x09, 0x09, 0x09, 0x76, 0x26, 0x49, 0x49,
0x49, 0x32, 0x01, 0x01, 0x7f, 0x01, 0x01, 0x3f, 0x40, 0x40, 0x40, 0x3f,
0x1f, 0x20, 0x40, 0x20, 0x1f, 0x7f, 0x20, 0x10, 0x20, 0x7f, 0x41, 0x22,
0x1c, 0x22, 0x41, 0x07, 0x08, 0x70, 0x08, 0x07, 0x61, 0x51, 0x49, 0x45,
0x43, 0x7f, 0x41, 0x41, 0x03, 0x0c, 0x30, 0xc0, 0x41, 0x41, 0x7f, 0x02,
0x01, 0x02, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01, 0x02, 0x20, 0x54, 0x54,
0x78, 0x7f, 0x48, 0x48, 0x30, 0x38, 0x44, 0x44, 0x24, 0x30, 0x48, 0x48,
0x7f, 0x38, 0x54, 0x54, 0x18, 0x08, 0x7e, 0x09, 0x02, 0x98, 0xa4, 0xa4,
0x78, 0x7f, 0x08, 0x08, 0x70, 0x44, 0x7d, 0x40, 0x44, 0x84, 0x7d, 0x7f,
0x10, 0x28, 0x44, 0x41, 0x7f, 0x40, 0x7c, 0x04, 0x18, 0x04, 0x78, 0x7c,
0x08, 0x04, 0x78, 0x38, 0x44, 0x44, 0x38, 0xfc, 0x24, 0x24, 0x18, 0x18,
0x24, 0x24, 0xfc, 0x7c, 0x08, 0x04, 0x08, 0x48, 0x54, 0x54, 0x24, 0x04,
0x3f, 0x44, 0x3c, 0x40, 0x20, 0x7c, 0x1c, 0x20, 0x40, 0x20, 0x1c, 0x3c,
0x40, 0x30, 0x40, 0x3c, 0x44, 0x28, 0x10, 0x28, 0x44, 0x9c, 0xa0, 0xa0,
0x7c, 0x64, 0x54, 0x54, 0x4c, 0x08, 0x36, 0x41, 0x77, 0x41, 0x36, 0x08,
0x08, 0x08, 0x2a, 0x1c, 0x08, 0x08, 0x1c, 0x2a, 0x08, 0x08, 0x00, 0x00,
0x00, 0xdf, 0xdf, 0x07, 0x07, 0x00, 0x07, 0x07, 0x14, 0x3e, 0x14, 0x3e,
0x14, 0x24, 0x4a, 0xff, 0x4a, 0x32, 0xf3, 0xfb, 0x18, 0xdf, 0xc7, 0x36,
0x49, 0x55, 0x22, 0x50, 0x04, 0x07, 0x03, 0x3c, 0x7e, 0xc3, 0x81, 0x81,
0xc3, 0x7e, 0x3c, 0x14, 0x08, 0x3e, 0x08, 0x14, 0x18, 0x7e, 0x7e, 0x18,
0x80, 0x60, 0x60, 0x18, 0x18, 0x18, 0x18, 0x18, 0x60, 0x60, 0xc0, 0xf0,
0x3c, 0x0f, 0x03, 0x7e, 0xff, 0xc3, 0xff, 0x7e, 0x04, 0xc6, 0xff, 0xff,
0xc0, 0xe6, 0xf7, 0xd3, 0xdf, 0xce, 0x42, 0xc3, 0xdb, 0xff, 0x76, 0x38,
0x3c, 0x36, 0xff, 0xff, 0x5f, 0xdf, 0xdb, 0xfb, 0x73, 0x7e, 0xff, 0xdb,
0xfb, 0x72, 0x03, 0xf3, 0xfb, 0x0f, 0x07, 0x76, 0xff, 0xdb, 0xff, 0x76,
0x4e, 0xdf, 0xdb, 0xff, 0x7e, 0x6c, 0x6c, 0x80, 0x6c, 0x6c, 0x18, 0x3c,
0x66, 0xc3, 0x81, 0x36, 0x36, 0x36, 0x36, 0x81, 0xc3, 0x66, 0x3c, 0x18,
0x06, 0xd3, 0xd9, 0x0f, 0x06, 0x7e, 0xc3, 0xdb, 0xd7, 0xde, 0xfe, 0xff,
0x33, 0xff, 0xfe, 0xff, 0xff, 0xdb, 0xff, 0x66, 0x7e, 0xff, 0xc3, 0xe7,
0x66, 0xff, 0xff, 0xc3, 0xff, 0x7e, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xff,
0xff, 0x1b, 0x1b, 0x03, 0x7e, 0xff, 0xc3, 0xfb, 0x7a, 0xff, 0xff, 0x18,
0xff, 0xff, 0xc3, 0xff, 0xff, 0xc3, 0x60, 0xe3, 0xc3, 0xff, 0x7f, 0xff,
0xff, 0x1c, 0xf7, 0xe3, 0xff, 0xff, 0xc0, 0xc0, 0xc0, 0xff, 0xfe, 0x0c,
0xfe, 0xff, 0xff, 0xfe, 0x18, 0x7f, 0xff, 0x7e, 0xff, 0xc3, 0xff, 0x7e,
0xff, 0xff, 0x1b, 0x1f, 0x0e, 0x7e, 0xff, 0xc3, 0x7f, 0xde, 0xff, 0xff,
0x1b, 0xff, 0xee, 0x4e, 0xdf, 0xdb, 0xfb, 0x72, 0x03, 0xff, 0xff, 0x03,
0x03, 0x7f, 0xff, 0xc0, 0xff, 0x7f, 0x3f, 0x7f, 0xc0, 0x7f, 0x3f, 0xff,
0x7f, 0x30, 0x7f, 0xff, 0xe7, 0xe7, 0x18, 0x18, 0xe7, 0xe7, 0x0f, 0x1f,
0xf0, 0x1f, 0x0f, 0xe3, 0xf3, 0xdb, 0xcf, 0xc7, 0xff, 0xff, 0xc3, 0xc3,
0x03, 0x0f, 0x3c, 0xf0, 0xc0, 0xc3, 0xc3, 0xff, 0xff, 0x04, 0x06, 0x03,
0x06, 0x04, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x03, 0x07, 0x60, 0xf4, 0xd4,
0xf4, 0xf8, 0xff, 0xff, 0xcc, 0xfc, 0x78, 0x78, 0xfc, 0xcc, 0xcc, 0x48,
0x78, 0xfc, 0xcc, 0xff, 0xff, 0x78, 0xfc, 0xac, 0xbc, 0xb8, 0x18, 0xfe,
0xff, 0x1b, 0x1b, 0xb8, 0xbc, 0xac, 0xfc, 0x78, 0xff, 0xff, 0x18, 0xf8,
0xf0, 0xcc, 0xfd, 0xfd, 0xc0, 0xc0, 0xcc, 0xfd, 0x7d, 0xff, 0xff, 0x10,
0xfc, 0xec, 0x7f, 0xff, 0xc0, 0xc0, 0xfc, 0xfc, 0x0c, 0xfc, 0x0c, 0xfc,
0xf8, 0xfc, 0xf8, 0x0c, 0xfc, 0xf8, 0x78, 0xfc, 0xcc, 0xfc, 0x78, 0xfc,
0xfc, 0x6c, 0x7c, 0x38, 0x38, 0x7c, 0x6c, 0xfc, 0xf8, 0xfc, 0xf8, 0x0c,
0x1c, 0x18, 0xd8, 0xdc, 0xfc, 0xec, 0x6c, 0x0c, 0x7f, 0xff, 0xcc, 0xcc,
0x7c, 0xfc, 0xc0, 0x7c, 0xfc, 0x3c, 0x7c, 0xc0, 0x7c, 0x3c, 0x7c, 0xfc,
0xc0, 0x60, 0xc0, 0xfc, 0x7c, 0xcc, 0xfc, 0x30, 0xfc, 0xdc, 0x9c, 0xbc,
0xb0, 0xfc, 0x7c, 0xcc, 0xec, 0xfc, 0xdc, 0xcc, 0x10, 0x56, 0xef, 0x81,
0xef, 0xef, 0x81, 0xee, 0x56, 0x10, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x18,
0x3c, 0x7e, 0x18, 0x18, 0x8f, 0xc7, 0xe3, 0xf1, 0xf8, 0x7c, 0x3e, 0x1f,
0xc7, 0xe3, 0xf1, 0xf8, 0x7c, 0x3e, 0x1f, 0x8f, 0xe3, 0xf1, 0xf8, 0x7c,
0x3e, 0x1f, 0x8f, 0xc7, 0xf1, 0xf8, 0x7c, 0x3e, 0x1f, 0x8f, 0xc7, 0xe3,
0xf8, 0x7c, 0x3e, 0x1f, 0x8f, 0xc7, 0xe3, 0xf1, 0x7c, 0x3e, 0x1f, 0x8f,
0xc7, 0xe3, 0xf1, 0xf8, 0x3e, 0x1f, 0x8f, 0xc7, 0xe3, 0xf1, 0xf8, 0x7c,
0x1f, 0x8f, 0xc7, 0xe3, 0xf1, 0xf8, 0x7c, 0x3e, 0xff, 0xff, 0xe7, 0xc3,
0xc3, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xc3, 0xc3, 0xe7, 0xff, 0xff,
0xff, 0xf8, 0xe0, 0xc0, 0xc0, 0xe0, 0xf8, 0xff, 0xff, 0x1f, 0x07, 0x03,
0x03, 0x07, 0x1f, 0xff, 0x1c, 0x3e, 0x77, 0x63, 0x77, 0x3e, 0x1c, 0x1c,
0x36, 0x63, 0x41, 0x63, 0x36, 0x1c, 0x1c, 0x08, 0x41, 0x63, 0x41, 0x08,
0x1c, 0x08, 0x14, 0x22, 0x49, 0x22, 0x14, 0x08, 0x55, 0xaa, 0x55, 0xaa,
0x55, 0xaa, 0x55, 0xaa, 0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc,
0x33, 0x33, 0x0e, 0x11, 0x0e, 0x12, 0x1f, 0x10, 0x19, 0x15, 0x12, 0x11,
0x15, 0x0a, 0x07, 0x04, 0x1e, 0x17, 0x15, 0x09, 0x0e, 0x15, 0x09, 0x01,
0x1d, 0x03, 0x0a, 0x15, 0x0a, 0x12, 0x15, 0x0e, 0x0a, 0x10, 0x0a, 0x04,
0x0a, 0x11, 0x0a, 0x0a, 0x0a, 0x11, 0x0a, 0x04, 0x01, 0x15, 0x02, 0x01,
0x03, 0x07, 0x03, 0x01, 0x04, 0x06, 0x07, 0x06, 0x04, 0x04, 0x0e, 0x1f,
0x1f, 0x0e, 0x04, 0x18, 0x3c, 0x7e, 0x7e, 0x3c, 0x18, 0x3c, 0x42, 0x81,
0x81, 0x81, 0x81, 0x42, 0x3c, 0x3c, 0x42, 0x99, 0xbd, 0xbd, 0x99, 0x42,
0x3c, 0x7f, 0x49, 0x41, 0x6b, 0x41, 0x49, 0x7f, 0x80, 0x40, 0x20, 0x10,
0x0f, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x3e, 0x01, 0x01, 0x01,
0x01, 0x02, 0x04, 0x38, 0x08, 0x08, 0x08, 0x08, 0x01, 0x01, 0x01, 0x01,
0x15, 0x0a, 0x15, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

View file

@ -0,0 +1,22 @@
const unsigned char charset_info[] = {
0x08, 0x84, 0x48, 0x84, 0x44, 0x44, 0x48, 0x88, // 0- 15 graticule & borders
0x88, 0x88, 0x88, 0x87, 0x77, 0x77, 0x77, 0x77, // 16- 31 graticule & symbols
0x21, 0x35, 0x55, 0x51, 0x33, 0x55, 0x35, 0x24, // 32- 47 ascii, font 1
0x55, 0x55, 0x55, 0x55, 0x55, 0x23, 0x44, 0x45, // 48- 63 ascii, font 1
0x55, 0x55, 0x55, 0x55, 0x53, 0x55, 0x55, 0x55, // 64- 80 ascii, font 1
0x55, 0x55, 0x55, 0x55, 0x55, 0x53, 0x43, 0x35, // 80- 95 ascii, font 1
0x24, 0x44, 0x44, 0x44, 0x43, 0x34, 0x35, 0x44, // 96-112 ascii, font 1
0x44, 0x44, 0x34, 0x55, 0x54, 0x43, 0x13, 0x55, // 112-127 ascii, font 1
0x32, 0x55, 0x55, 0x53, 0x44, 0x54, 0x35, 0x25, // 128-143 ascii, bold font
0x55, 0x55, 0x55, 0x55, 0x55, 0x23, 0x54, 0x55, // 144-159 ascii, bold font
0x55, 0x55, 0x55, 0x55, 0x54, 0x55, 0x55, 0x55, // 160-175 ascii, bold font
0x55, 0x55, 0x55, 0x55, 0x65, 0x54, 0x54, 0x55, // 176-191 ascii, bold font
0x25, 0x55, 0x55, 0x55, 0x54, 0x45, 0x47, 0x55, // 192-207 ascii, bold font
0x55, 0x55, 0x55, 0x57, 0x55, 0x54, 0x24, 0x55, // 208-223 ascii, bold font
0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x77, 0x77, // 224-239 symbols
0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 240-255 symbols
0x33, 0x33, 0x33, 0x33, 0x33, 0x12, 0x33, 0x33, // 256-271 small numbers
0x55, 0x33, 0x68, 0x87, 0x84, 0x44, 0x44, 0x44 // 272-288 symbols
};
const unsigned char charset_dlines = 1;

View file

@ -0,0 +1,163 @@
/* *************************************************************
crt.s STARTUP ASSEMBLY CODE
-----------------------
Module includes the interrupt vectors and start-up code.
****************************************************************/
/* Stack Sizes */
.set UND_STACK_SIZE, 0x00000004 /* stack for "undefined instruction" interrupts is 4 bytes */
.set ABT_STACK_SIZE, 0x00000004 /* stack for "abort" interrupts is 4 bytes */
.set FIQ_STACK_SIZE, 0x00000010 /* stack for "FIQ" interrupts is 4 bytes */
.set IRQ_STACK_SIZE, 0X00000020 /* stack for "IRQ" normal interrupts is 4 bytes */
.set SVC_STACK_SIZE, 0x00000010 /* stack for "SVC" supervisor mode is 4 bytes */
/* Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs (program status registers) */
.set MODE_USR, 0x10 /* Normal User Mode */
.set MODE_FIQ, 0x11 /* FIQ Processing Fast Interrupts Mode */
.set MODE_IRQ, 0x12 /* IRQ Processing Standard Interrupts Mode */
.set MODE_SVC, 0x13 /* Supervisor Processing Software Interrupts Mode */
.set MODE_ABT, 0x17 /* Abort Processing memory Faults Mode */
.set MODE_UND, 0x1B /* Undefined Processing Undefined Instructions Mode */
.set MODE_SYS, 0x1F /* System Running Priviledged Operating System Tasks Mode */
.set I_BIT, 0x80 /* when I bit is set, IRQ is disabled (program status registers) */
.set F_BIT, 0x40 /* when F bit is set, FIQ is disabled (program status registers) */
.text
.arm
.global Reset_Handler
.global _startup
.func _startup
_startup:
# Exception Vectors
_vectors: ldr PC, Reset_Addr
ldr PC, Undef_Addr
ldr PC, SWI_Addr
ldr PC, PAbt_Addr
ldr PC, DAbt_Addr
nop /* Reserved Vector (holds Philips ISP checksum) */
ldr PC, [PC,#-0xFF0] /* see page 71 of "Insiders Guide to the Philips ARM7-Based Microcontrollers" by Trevor Martin */
ldr PC, FIQ_Addr
Reset_Addr: .word Reset_Handler /* defined in this module below */
Undef_Addr: .word UNDEF_Routine /* defined in main.c */
SWI_Addr: .word SWI_Routine /* defined in main.c */
PAbt_Addr: .word UNDEF_Routine /* defined in main.c */
DAbt_Addr: .word UNDEF_Routine /* defined in main.c */
IRQ_Addr: .word IRQ_Routine /* defined in main.c */
FIQ_Addr: .word FIQ_Routine /* defined in main.c */
.word 0 /* rounds the vectors and ISR addresses to 64 bytes total */
# Reset Handler
Reset_Handler:
/* Setup a stack for each mode - note that this only sets up a usable stack
for User mode. Also each mode is setup with interrupts initially disabled. */
ldr r0, =_stack_end
msr CPSR_c, #MODE_UND|I_BIT|F_BIT /* Undefined Instruction Mode */
mov sp, r0
sub r0, r0, #UND_STACK_SIZE
msr CPSR_c, #MODE_ABT|I_BIT|F_BIT /* Abort Mode */
mov sp, r0
sub r0, r0, #ABT_STACK_SIZE
msr CPSR_c, #MODE_FIQ|I_BIT|F_BIT /* FIQ Mode */
mov sp, r0
sub r0, r0, #FIQ_STACK_SIZE
msr CPSR_c, #MODE_IRQ|I_BIT|F_BIT /* IRQ Mode */
mov sp, r0
sub r0, r0, #IRQ_STACK_SIZE
msr CPSR_c, #MODE_SVC|I_BIT|F_BIT /* Supervisor Mode */
mov sp, r0
sub r0, r0, #SVC_STACK_SIZE
msr CPSR_c, #MODE_SYS|F_BIT /* User Mode */
mov sp, r0
/* set up pins and membanks */
ldr r0, = PINSEL2
ldr r2, =0xD6041D4
str r2, [r0]
ldr r1, =0x10000420
ldr r0,=BCFG0
str r1,[r0]
str r1,[r0,#0x08]
/* copy .data section (Copy from ROM to RAM) */
ldr R1, =_etext
ldr R2, =_data
ldr R3, =_edata
1: cmp R2, R3
ldrlo R0, [R1], #4
strlo R0, [R2], #4
blo 1b
/* Clear .bss section (Zero init) */
mov R0, #0
ldr R1, =_bss_start
ldr R2, =_bss_end
2: cmp R1, R2
strlo R0, [R1], #4
blo 2b
/* set up the pll */
ldr r0, =0xe01fc000
ldr r2, =0xaa
ldr r3, =0x55
ldr r1, =0x03
str r1, [r0,#0x80]
ldr r1, =0x0
str r1, [r0,#0x100]
ldr r1, =0x42
str r1,[r0,#0x84]
str r2, [r0,#0x8c]
str r3, [r0,#0x8c]
ldr r2, =IO0PIN
mov r3, #0x10
str r3, [r2,#0xc]
ldr r3, [r2,#8]
bic r3, r3, #0x10
str r3, [r2,#8]
ldr r1, =0xc42
ldr r0, =BCFG1
str r1, [r0]
ldr r2, =PINSEL0
ldr r3, [r2,#0x14]
orr r3, r3, #0x800
str r3, [r2,#0x14]
ldr r3, [r2,#0x14]
orr r3, r3, #0x800000
str r3, [r2,#0x14]
/* Enter the C code */
mov r0,#0
mov r1,r0
mov r2,r0
mov fp,r0
mov r7,r0
ldr r10,=main
mov lr,pc
bx r10
.endfunc
entry_mask: .word 0x4FFFFFFF /* defined in this module below */
.end

View file

@ -0,0 +1,230 @@
#include "lpc2220.h"
#include "flash.h"
#include "serial.h"
#include "lcd.h"
const unsigned long secaddr[19] =
{ 0x00000,
0x02000,
0x03000,
0x04000,
0x08000,
0x10000,
0x18000,
0x20000,
0x28000,
0x30000,
0x38000,
0x40000,
0x48000,
0x50000,
0x58000,
0x60000,
0x68000,
0x70000,
0x78000 };
unsigned long flash_base;
unsigned short check1, check2;
void slow(void)
{
BCFG0 = 0x10000420;
BCFG2 = 0x10000420;
}
void fast(void)
{
BCFG0 = 0x10000400;
BCFG2 = 0x10000400;
}
int eraseSector(unsigned char chip, unsigned char secnum)
{
if(chip == 0)
flash_base = FLASH0_BASE;
else
flash_base = FLASH1_BASE;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0xAA;
*((volatile unsigned short *)(flash_base | 0x554)) = 0x55;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0x80;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0xAA;
*((volatile unsigned short *)(flash_base | 0x554)) = 0x55;
*((volatile unsigned short *)(flash_base + (secaddr[secnum]<<1))) = 0x30;
retry:
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if((check1 & 0x44) == (check2 & 0x44))
goto done;
if(!(check2 & 0x24))
goto retry;
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if((check1 & 0x44) == (check2 & 0x44))
goto done;
*((volatile unsigned short *)flash_base) = 0xF0;
return -1;
done:
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if(check1 != check2)
goto retry;
return 0;
}
int eraseSectorAt(unsigned long sadr)
{
flash_base = sadr & 0xFF000000;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0xAA;
*((volatile unsigned short *)(flash_base | 0x554)) = 0x55;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0x80;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0xAA;
*((volatile unsigned short *)(flash_base | 0x554)) = 0x55;
*((volatile unsigned short *)(sadr)) = 0x30;
retry:
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if((check1 & 0x44) == (check2 & 0x44))
goto done;
if(!(check2 & 0x24))
goto retry;
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if((check1 & 0x44) == (check2 & 0x44))
goto done;
*((volatile unsigned short *)flash_base) = 0xF0;
return -1;
done:
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if(check1 != check2)
goto retry;
return 0;
}
int eraseFlash(unsigned char chip)
{
if(chip == 0)
flash_base = FLASH0_BASE;
else
flash_base = FLASH1_BASE;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0xAA;
*((volatile unsigned short *)(flash_base | 0x554)) = 0x55;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0x80;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0xAA;
*((volatile unsigned short *)(flash_base | 0x554)) = 0x55;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0x10;
retry:
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if((check1 & 0x44) == (check2 & 0x44))
goto done;
if(!(check2 & 0x24))
goto retry;
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if((check1 & 0x44) == (check2 & 0x44))
goto done;
*((volatile unsigned short *)flash_base) = 0xF0;
return -1;
done:
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if(check1 != check2)
goto retry;
return 0;
}
int writeWord(unsigned long addr, unsigned short data)
{
flash_base = addr & 0xFF000000;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0xAA;
*((volatile unsigned short *)(flash_base | 0x554)) = 0x55;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0xA0;
*((volatile unsigned short *)(addr)) = data;
retry:
check1 = *((volatile unsigned short *)addr);
check2 = *((volatile unsigned short *)addr);
if((check1 & 0x40) == (check2 & 0x40))
goto done;
if(!(check2 & 0x20))
goto retry;
check1 = *((volatile unsigned short *)addr);
check2 = *((volatile unsigned short *)addr);
if((check1 & 0x40) == (check2 & 0x40))
goto done;
*((volatile unsigned short *)addr) = 0xF0;
return -1;
done:
check1 = *((volatile unsigned short *)addr);
check2 = *((volatile unsigned short *)addr);
if(check1 != check2)
goto retry;
return 0;
}
void prepareBulk(unsigned long dst)
{
flash_base = dst & 0xFF000000;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0xAA;
*((volatile unsigned short *)(flash_base | 0x554)) = 0x55;
*((volatile unsigned short *)(flash_base | 0xAAA)) = 0x20;
}
void endBulk(unsigned long dst)
{
flash_base = dst & 0xFF000000;
*((volatile unsigned short *)(flash_base)) = 0x90;
*((volatile unsigned short *)(flash_base)) = 0x00;
}
int writeBulk(unsigned long src, unsigned long dst, unsigned long cnt)
{
flash_base = dst;
while(cnt--)
{
if(*((volatile unsigned short *)src) != 0xFFFF)
{
*((volatile unsigned short *)flash_base) = 0xA0;
*((volatile unsigned short *)flash_base) = *((volatile unsigned short *)src);
retry:
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if((check1 & 0x40) == (check2 & 0x40))
goto done;
if(!(check2 & 0x20))
goto retry;
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if((check1 & 0x40) == (check2 & 0x40))
goto done;
*((volatile unsigned short *)flash_base) = 0xF0;
return -1;
done:
check1 = *((volatile unsigned short *)flash_base);
check2 = *((volatile unsigned short *)flash_base);
if(check1 != check2)
goto retry;
}
src+=2;
flash_base+=2;
}
return 0;
}

View file

@ -0,0 +1,16 @@
#ifndef FLASH_H
#define FLASH_H
#define FLASH0_BASE 0x80000000
#define FLASH1_BASE 0x82000000
void prepareBulk(unsigned long dst);
void endBulk(unsigned long dst);
int eraseSector(unsigned char chip, unsigned char secnum);
int eraseSectorAt(unsigned long sadr);
int eraseFlash(unsigned char chip);
int writeWord(unsigned long addr, unsigned short data);
int writeBulk(unsigned long src, unsigned long dst, unsigned long cnt);
void lcd_set(unsigned char s);
#endif

View file

@ -0,0 +1,175 @@
#include "lcd.h"
#include "fonty.h"
#include "charset.info"
#include "charset.bits"
static unsigned char tx, ty;
static unsigned short coff;
unsigned char *font_bits, *font_info;
void set_font(unsigned char f)
{
font_bits = (unsigned char*) charset_bits;
font_info = (unsigned char*) charset_info;
switch(f)
{
case 0:
coff = 0;
break;
case 1:
coff = 96;
break;
case 2:
coff = 224;
break;
case 3:
case 4:
coff = 272;
break;
}
}
void _draw_char(
unsigned int ch, // char
unsigned char c, // color
unsigned char m // mode
)
{
unsigned char p,s;
unsigned int cpos, cnt;
cpos = 0;
for(cnt=0; cnt<ch; cnt++)
{
if(cnt & 0x01)
{
cpos += (font_info[cnt>>1] & 0x0F);
}
else
{
cpos += (font_info[cnt>>1] >> 4);
}
}
p = font_info[ch>>1];
if(ch & 0x01)
{
p &= 0x0F;
}
else
{
p >>= 4;
}
if(ty & 0x07)
{
s = ty & 0x07;
for(cnt=0;cnt<p;cnt++)
{
if(c & 0x02)
drawbuf[0][p-cnt-1] = font_bits[cpos+cnt] << s;
else
drawbuf[0][p-cnt-1] = 0x00;
if(c & 0x01)
drawbuf[1][p-cnt-1] = font_bits[cpos+cnt] << s;
else
drawbuf[1][p-cnt-1] = 0x00;
}
do_rcu(tx,ty,p,m);
for(cnt=0;cnt<p;cnt++)
{
if(c & 0x02)
drawbuf[0][p-cnt-1] = font_bits[cpos+cnt] >> (8-s);
else
drawbuf[0][p-cnt-1] = 0x00;
if(c & 0x01)
drawbuf[1][p-cnt-1] = font_bits[cpos+cnt] >> (8-s);
else
drawbuf[1][p-cnt-1] = 0x00;
}
do_rcu(tx,ty+8,p,m);
}
else
{
for(cnt=0;cnt<p;cnt++)
{
if(c & 0x02)
drawbuf[0][p-cnt-1] = font_bits[cpos+cnt];
else
drawbuf[0][p-cnt-1] = 0x00;
if(c & 0x01)
drawbuf[1][p-cnt-1] = font_bits[cpos+cnt];
else
drawbuf[1][p-cnt-1] = 0x00;
}
do_rcu(tx,ty,p,m);
}
tx += (p+1);
}
void draw_char(unsigned char x, unsigned char y, unsigned char ch, unsigned char c, unsigned char m)
{
tx = x;
ty = y;
_draw_char(ch+coff, c, m);
}
void draw_string(unsigned char x, unsigned char y, char *st, unsigned char c, unsigned char m)
{
unsigned char cp;
tx = x;
ty = y;
cp = 0;
while(st[cp] != 0)
{
_draw_char(st[cp]+coff, c, m);
cp++;
}
}
void draw_stringc(unsigned char x, unsigned char y, char *st, unsigned char cnt, unsigned char c, unsigned char m)
{
unsigned char cp,cx;
cx = cnt;
tx = x;
ty = y;
cp = 0;
while(cx--)
{
_draw_char(st[cp]+coff, c, m);
cp++;
}
}
extern char hval[16];
void draw_hexC(unsigned char x, unsigned char y, const unsigned char v, unsigned char c, unsigned char m)
{
tx = x;
ty = y;
_draw_char(hval[v>>4]+coff, c, m);
_draw_char(hval[v & 0x0F]+coff, c, m);
}
void draw_hexS(unsigned char x, unsigned char y, const unsigned short v, unsigned char c, unsigned char m)
{
tx = x;
ty = y;
draw_hexC(x, y, v >> 8, c, m);
draw_hexC(tx, ty, v & 0xFF, c, m);
}
void draw_hexW(unsigned char x, unsigned char y, const unsigned long v, unsigned char c, unsigned char m)
{
draw_hexS(x, y, v >> 16, c, m);
draw_hexS(tx, ty, v & 0xFFFF, c, m);
}

View file

@ -0,0 +1,14 @@
#ifndef FONTY_H
#define FONTY_H
extern unsigned char drawbuf[2][128];
void set_font(unsigned char f);
void draw_char(unsigned char x, unsigned char y, unsigned char ch, unsigned char c, unsigned char m);
void draw_string(unsigned char x, unsigned char y, char *st, unsigned char c, unsigned char m);
void draw_stringc(unsigned char x, unsigned char y, char *st, unsigned char cnt, unsigned char c, unsigned char m);
void draw_hexC(unsigned char x, unsigned char y, const unsigned char v, unsigned char c, unsigned char m);
void draw_hexS(unsigned char x, unsigned char y, const unsigned short v, unsigned char c, unsigned char m);
void draw_hexW(unsigned char x, unsigned char y, const unsigned long v, unsigned char c, unsigned char m);
#endif

View file

@ -0,0 +1,43 @@
#include "lpc2220.hh"
#include "irq.h"
#define IRQ_MASK 0x00000080
static inline unsigned asm_get_cpsr(void)
{
unsigned long retval;
asm volatile (" mrs %0, cpsr" : "=r" (retval) : /* no inputs */ );
return retval;
}
static inline void asm_set_cpsr(unsigned val)
{
asm volatile (" msr cpsr, %0" : /* no outputs */ : "r" (val) );
}
unsigned enableIRQ(void)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr(_cpsr & ~IRQ_MASK);
return _cpsr;
}
unsigned disableIRQ(void)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr(_cpsr | IRQ_MASK);
return _cpsr;
}
unsigned restoreIRQ(unsigned oldCPSR)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
return _cpsr;
}

View file

@ -0,0 +1,450 @@
#include "lpc2220.h"
#include "lcd.h"
#include "fonty.h"
//#include "b.h"
void pause(unsigned int ptime)
{
unsigned long xx;
xx = ptime * 750;
while(xx--)
{};
}
void clearStatus(void)
{
draw_block(0, 151, 128, 10, 3, DRAW_ERASE);
timer++;
}
void drawStatus(char *msg)
{
draw_block(0, 152, 128, 10, 3, DRAW_PUT);
draw_string(1,152,">>",3,DRAW_XOR);
draw_string(16,152,msg,3,DRAW_XOR);
timer = 0;
}
void lcd_fill(unsigned char f)
{
unsigned char x,y;
for(y=0;y<20;y++)
{
LCD_CMD = 0xB0;
LCD_CMD = y;
LCD_CMD = 0x10;
LCD_CMD = 0x00;
for(x=0;x<128;x++)
{
LCD_DATA = f;
LCD_DATA = f;
}
}
}
void lcd_set(unsigned char s)
{
if(s == 0)
{
LCD_CMD = 0xA0; // set segment remap (00H mapped to seg0)
LCD_CMD = 0xC8; // set com output scan direction (remapped mode)
}
else
{
LCD_CMD = 0xA1; // set segment remap (7FH mapped to seg0)
LCD_CMD = 0xC0; // set com output scan direction (normal mode)
}
}
void lcd_init(unsigned char s)
{
LCD_CMD = 0xE1; // exit power save mode
LCD_CMD = 0xE2; // software reset
pause(0x64);
LCD_CMD = 0xAB; // start internal oscillator
LCD_CMD = 0x27; // set internal regulator resistor ratio (8.1)
LCD_CMD = 0x81; // volume cmd
LCD_CMD = 0x3B; // volume cmd value
LCD_CMD = 0x65; // set DC-DC converter factor (4x)
LCD_CMD = 0x60; // set upper window corner ax cmd
LCD_CMD = 0x1C; // set upper window corner ax value
LCD_CMD = 0x61; // set upper window corner ay cmd
LCD_CMD = 0x0A; // set upper window corner ay value
LCD_CMD = 0x62; // set lower window corner bx cmd
LCD_CMD = 0x75; // set lower window corner bx value
LCD_CMD = 0x63; // set lower window corner by cmd
LCD_CMD = 0x81; // set lower window corner by value
LCD_CMD = 0x90; // set PWM and FRC (4-frames)
LCD_CMD = 0x88; // set white mode frame 2nd and 1st cmd
LCD_CMD = 0x00; // set white mode frame 2nd and 1st value
LCD_CMD = 0x89; // set white mode frame 4th and 3rd cmd
LCD_CMD = 0x00; // set white mode frame 4th and 3rd value
LCD_CMD = 0x8A; // set light gray mode frame 2nd and 1st cmd
LCD_CMD = 0x55; // set light gray mode frame 2nd and 1st value
LCD_CMD = 0x8B; // set light gray mode frame 4th and 3rd cmd
LCD_CMD = 0x55; // set light gray mode frame 4th and 3rd vakue
LCD_CMD = 0x8C; // set dark gray mode frame 2nd and 1st cmd
LCD_CMD = 0x66; // set dark gray mode frame 2nd and 1st value
LCD_CMD = 0x8D; // set dark gray mode frame 4th and 3rd cmd
LCD_CMD = 0x66; // set dark gray mode frame 4th and 3rd vakue
LCD_CMD = 0x8E; // set black mode frame 2nd and 1st cmd
LCD_CMD = 0xAA; // set black mode frame 2nd and 1st value
LCD_CMD = 0x8F; // set black mode frame 4th and 3rd cmd
LCD_CMD = 0xAA; // set black mode frame 4th and 3rd value
lcd_set(s);
LCD_CMD = 0x2E; // set power control register (boost on, reg on, buffer off)
pause(0x64);
LCD_CMD = 0x2F; // set power control register (boost on, reg on, buffer on)
LCD_CMD = 0xA4; // set entire display on, normal mode)
LCD_CMD = 0xA6; // set normal display mode, inverse = 0xA7
lcd_fill(0x00);
LCD_CMD = 0xAF;
set_font(0);
}
void lcd_enable(unsigned char e)
{
if(e)
{
LCD_CMD = 0xAF; // set display on
}
else
{
LCD_CMD = 0xAE; // set display off
}
}
unsigned char rcubuf[2][128];
unsigned char drawbuf[2][128];
void do_rcu(unsigned char x, unsigned char y, unsigned char l, unsigned char m)
{
unsigned char q;
LCD_CMD = 0xB0;
LCD_CMD = (y >> 3);
LCD_CMD = (0x10 + (x >> 4));
LCD_CMD = (x & 0x0F);
q = LCD_DATA;
q = l;
while(q--)
{
rcubuf[0][q] = LCD_DATA;
rcubuf[1][q] = LCD_DATA;
}
q = LCD_DATA;
LCD_CMD = 0xB0;
LCD_CMD = (y >> 3);
LCD_CMD = (0x10 + (x >> 4));
LCD_CMD = (x & 0x0F);
q = l;
switch(m)
{
case DRAW_PUT: // draw put
while(q--)
{
LCD_DATA = rcubuf[0][q] | drawbuf[0][q];
LCD_DATA = rcubuf[1][q] | drawbuf[1][q];
}
break;
case DRAW_XOR: // draw xor
while(q--)
{
LCD_DATA = rcubuf[0][q] ^ drawbuf[0][q];
LCD_DATA = rcubuf[1][q] ^ drawbuf[1][q];
}
break;
case DRAW_ERASE: // draw erase
while(q--)
{
LCD_DATA = rcubuf[0][q] & ~drawbuf[0][q];
LCD_DATA = rcubuf[1][q] & ~drawbuf[1][q];
}
break;
}
}
void do_rcuS(unsigned char x, unsigned char y, unsigned char m)
{
unsigned char q;
LCD_CMD = 0xB0;
LCD_CMD = (y >> 3);
LCD_CMD = (0x10 + (x >> 4));
LCD_CMD = (x & 0x0F);
q = LCD_DATA;
rcubuf[0][0] = LCD_DATA;
rcubuf[1][0] = LCD_DATA;
q = LCD_DATA;
LCD_CMD = 0xB0;
LCD_CMD = (y >> 3);
LCD_CMD = (0x10 + (x >> 4));
LCD_CMD = (x & 0x0F);
switch(m)
{
case 0: // draw put
LCD_DATA = rcubuf[0][0] | drawbuf[0][0];
LCD_DATA = rcubuf[1][0] | drawbuf[1][0];
break;
case 1: // draw xor
LCD_DATA = rcubuf[0][0] ^ drawbuf[0][0];
LCD_DATA = rcubuf[1][0] ^ drawbuf[1][0];
break;
case 2: // draw erase
LCD_DATA = rcubuf[0][0] & ~drawbuf[0][0];
LCD_DATA = rcubuf[1][0] & ~drawbuf[1][0];
break;
}
}
void draw_block(unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char c, unsigned char m)
{
unsigned char q,s;
unsigned char yy,ss,vv,ww,xx;
unsigned char segm;
s = y;
if(h)
{
yy = h;
ss = y >> 3;
vv = y & 0x07;
ww = yy & 0x07;
segm = 0xFF;
xx = 8;
if(yy < 8)
{
segm >>= (8-ww);
xx -= (8-ww);
if(vv > (8-xx))
{
xx = yy -(vv-(8-xx));
}
else
{
xx = yy;
}
}
else
{
xx -= vv;
}
segm <<= vv;
q = w;
while(q--)
{
if(c & 0x02)
drawbuf[0][q] = segm;
else
drawbuf[0][q] = 0;
if(c & 0x01)
drawbuf[1][q] = segm;
else
drawbuf[1][q] = 0;
}
do_rcu(x,s,w,m);
yy -= xx;
while(yy > 8)
{
s += 8;
yy -= 8;
q = w;
while(q--)
{
if(c & 0x02)
drawbuf[0][q] = 0xFF;
else
drawbuf[0][q] = 0;
if(c & 0x01)
drawbuf[1][q] = 0xFF;
else
drawbuf[1][q] = 0;
}
do_rcu(x,s,w,m);
}
if(yy)
{
s += 8;
q = w;
while(q--)
{
if(c & 0x02)
drawbuf[0][q] = 0xFF >> (8-yy);
else
drawbuf[0][q] = 0;
if(c & 0x01)
drawbuf[1][q] = 0xFF >> (8-yy);
else
drawbuf[1][q] = 0;
}
do_rcu(x,s,w,m);
}
}
}
void draw_hline(unsigned char x, unsigned char y, unsigned char l, unsigned char c, unsigned char m)
{
unsigned char p,q;
q = l;
p = 0x01 << (y & 0x07);
while(q--)
{
if(c & 0x02)
drawbuf[0][q] = p;
else
drawbuf[0][q] = 0;
if(c & 0x01)
drawbuf[1][q] = p;
else
drawbuf[1][q] = 0;
}
do_rcu(x,y,l,m);
}
void draw_vline(unsigned char x, unsigned char y, unsigned char l, unsigned char c, unsigned char m)
{
unsigned char s;
unsigned char yy,ss,vv,ww,xx;
unsigned char segm;
s = y;
if(l)
{
yy = l;
ss = y >> 3;
vv = y & 0x07;
ww = yy & 0x07;
segm = 0xFF;
xx = 8;
if(yy < 8)
{
segm >>= (8-ww);
xx -= (8-ww);
if(vv > (8-xx))
{
xx = yy -(vv-(8-xx));
}
else
{
xx = yy;
}
}
else
{
xx -= vv;
}
segm <<= vv;
if(c & 0x02)
drawbuf[0][0] = segm;
else
drawbuf[0][0] = 0;
if(c & 0x01)
drawbuf[1][0] = segm;
else
drawbuf[1][0] = 0;
do_rcuS(x,s,m);
yy -= xx;
while(yy > 8)
{
s += 8;
yy -= 8;
if(c & 0x02)
drawbuf[0][0] = 0xFF;
else
drawbuf[0][0] = 0;
if(c & 0x01)
drawbuf[1][0] = 0xFF;
else
drawbuf[1][0] = 0;
do_rcuS(x,s,m);
}
if(yy)
{
s += 8;
if(c & 0x02)
drawbuf[0][0] = 0xFF >> (8-yy);
else
drawbuf[0][0] = 0;
if(c & 0x01)
drawbuf[1][0] = 0xFF >> (8-yy);
else
drawbuf[1][0] = 0;
do_rcuS(x,s,m);
}
}
}
void draw_rect(unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char lw, unsigned char c, unsigned char m)
{
if(lw)
{
if(lw == 1)
{
draw_hline(x, y, w, c, m);
draw_hline(x, y+h-1, w, c, m);
draw_vline(x, y+1, h-2, c, m);
draw_vline(x+w-1, y+1, h-2, c, m);
}
else
{
draw_block(x, y, w, lw, c, m);
draw_block(x, y+h-lw, w, lw, c, m);
draw_block(x, y+lw, lw, h-(2*lw), c, m);
draw_block(x+w-lw, y+lw, lw, h-(2*lw), c, m);
}
}
}

View file

@ -0,0 +1,42 @@
#ifndef LCD_H
#define LCD_H
// the lcd data & command ports
#define LCD_CMD (*((volatile unsigned char *) 0x81000000))
#define LCD_DATA (*((volatile unsigned char *) 0x81000001))
// drawmodes
#define DRAW_PUT 0
#define DRAW_XOR 1
#define DRAW_ERASE 2
#define DRAW_RAW 10
#define DRAW_RAW_INV 11
#define TIMEOUT 0x00400000
struct t_bitmap
{
unsigned char width;
unsigned char height;
unsigned char mode;
unsigned char *data;
} ;
extern unsigned long timer;
struct t_bitmap bitmap;
void lcd_init(unsigned char s);
void lcd_enable(unsigned char e);
void do_rcu(unsigned char x, unsigned char y, unsigned char l, unsigned char m);
void lcd_fill(unsigned char f);
void draw_block(unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char c, unsigned char m);
void draw_hline(unsigned char x, unsigned char y, unsigned char l, unsigned char c, unsigned char m);
void draw_vline(unsigned char x, unsigned char y, unsigned char l, unsigned char c, unsigned char m);
void draw_rect(unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned char lw, unsigned char c, unsigned char m);
void clearStatus(void);
void drawStatus(char *msg);
#endif

View file

@ -0,0 +1,261 @@
/********************************************************/
/* */
/* philips */
/* lpc2220 */
/* */
/********************************************************/
#ifndef LPC2220_H
#define LPC2220_H
/* External Memory Controller (EMC) */
#define BCFG0 (*((volatile unsigned long *) 0xFFE00000))
#define BCFG1 (*((volatile unsigned long *) 0xFFE00004))
#define BCFG2 (*((volatile unsigned long *) 0xFFE00008))
#define BCFG3 (*((volatile unsigned long *) 0xFFE0000C))
/* Vectored Interrupt Controller (VIC) */
#define VICIRQStatus (*((volatile unsigned long *) 0xFFFFF000))
#define VICFIQStatus (*((volatile unsigned long *) 0xFFFFF004))
#define VICRawIntr (*((volatile unsigned long *) 0xFFFFF008))
#define VICIntSelect (*((volatile unsigned long *) 0xFFFFF00C))
#define VICIntEnable (*((volatile unsigned long *) 0xFFFFF010))
#define VICIntEnClr (*((volatile unsigned long *) 0xFFFFF014))
#define VICSoftInt (*((volatile unsigned long *) 0xFFFFF018))
#define VICSoftIntClr (*((volatile unsigned long *) 0xFFFFF01C))
#define VICProtection (*((volatile unsigned long *) 0xFFFFF020))
#define VICVectAddr (*((volatile unsigned long *) 0xFFFFF030))
#define VICDefVectAddr (*((volatile unsigned long *) 0xFFFFF034))
#define VICVectAddr0 (*((volatile unsigned long *) 0xFFFFF100))
#define VICVectAddr1 (*((volatile unsigned long *) 0xFFFFF104))
#define VICVectAddr2 (*((volatile unsigned long *) 0xFFFFF108))
#define VICVectAddr3 (*((volatile unsigned long *) 0xFFFFF10C))
#define VICVectAddr4 (*((volatile unsigned long *) 0xFFFFF110))
#define VICVectAddr5 (*((volatile unsigned long *) 0xFFFFF114))
#define VICVectAddr6 (*((volatile unsigned long *) 0xFFFFF118))
#define VICVectAddr7 (*((volatile unsigned long *) 0xFFFFF11C))
#define VICVectAddr8 (*((volatile unsigned long *) 0xFFFFF120))
#define VICVectAddr9 (*((volatile unsigned long *) 0xFFFFF124))
#define VICVectAddr10 (*((volatile unsigned long *) 0xFFFFF128))
#define VICVectAddr11 (*((volatile unsigned long *) 0xFFFFF12C))
#define VICVectAddr12 (*((volatile unsigned long *) 0xFFFFF130))
#define VICVectAddr13 (*((volatile unsigned long *) 0xFFFFF134))
#define VICVectAddr14 (*((volatile unsigned long *) 0xFFFFF138))
#define VICVectAddr15 (*((volatile unsigned long *) 0xFFFFF13C))
#define VICVectCntl0 (*((volatile unsigned long *) 0xFFFFF200))
#define VICVectCntl1 (*((volatile unsigned long *) 0xFFFFF204))
#define VICVectCntl2 (*((volatile unsigned long *) 0xFFFFF208))
#define VICVectCntl3 (*((volatile unsigned long *) 0xFFFFF20C))
#define VICVectCntl4 (*((volatile unsigned long *) 0xFFFFF210))
#define VICVectCntl5 (*((volatile unsigned long *) 0xFFFFF214))
#define VICVectCntl6 (*((volatile unsigned long *) 0xFFFFF218))
#define VICVectCntl7 (*((volatile unsigned long *) 0xFFFFF21C))
#define VICVectCntl8 (*((volatile unsigned long *) 0xFFFFF220))
#define VICVectCntl9 (*((volatile unsigned long *) 0xFFFFF224))
#define VICVectCntl10 (*((volatile unsigned long *) 0xFFFFF228))
#define VICVectCntl11 (*((volatile unsigned long *) 0xFFFFF22C))
#define VICVectCntl12 (*((volatile unsigned long *) 0xFFFFF230))
#define VICVectCntl13 (*((volatile unsigned long *) 0xFFFFF234))
#define VICVectCntl14 (*((volatile unsigned long *) 0xFFFFF238))
#define VICVectCntl15 (*((volatile unsigned long *) 0xFFFFF23C))
/* Pin Connect Block */
#define PINSEL0 (*((volatile unsigned long *) 0xE002C000))
#define PINSEL1 (*((volatile unsigned long *) 0xE002C004))
#define PINSEL2 (*((volatile unsigned long *) 0xE002C014))
/* General Purpose Input/Output (GPIO) */
#define IOPIN0 (*((volatile unsigned long *) 0xE0028000))
#define IOSET0 (*((volatile unsigned long *) 0xE0028004))
#define IODIR0 (*((volatile unsigned long *) 0xE0028008))
#define IOCLR0 (*((volatile unsigned long *) 0xE002800C))
#define IOPIN1 (*((volatile unsigned long *) 0xE0028010))
#define IOSET1 (*((volatile unsigned long *) 0xE0028014))
#define IODIR1 (*((volatile unsigned long *) 0xE0028018))
#define IOCLR1 (*((volatile unsigned long *) 0xE002801C))
#define IOPIN2 (*((volatile unsigned long *) 0xE0028020))
#define IOSET2 (*((volatile unsigned long *) 0xE0028024))
#define IODIR2 (*((volatile unsigned long *) 0xE0028028))
#define IOCLR2 (*((volatile unsigned long *) 0xE002802C))
#define IOPIN3 (*((volatile unsigned long *) 0xE0028030))
#define IOSET3 (*((volatile unsigned long *) 0xE0028034))
#define IODIR3 (*((volatile unsigned long *) 0xE0028038))
#define IOCLR3 (*((volatile unsigned long *) 0xE002803C))
/* Phase Locked Loop (PLL) */
#define PLLCON (*((volatile unsigned char *) 0xE01FC080))
#define PLLCFG (*((volatile unsigned char *) 0xE01FC084))
#define PLLSTAT (*((volatile unsigned short*) 0xE01FC088))
#define PLLFEED (*((volatile unsigned char *) 0xE01FC08C))
/* VPB Divider */
#define VPBDIV (*((volatile unsigned char *) 0xE01FC100))
/* Power Control */
#define PCON (*((volatile unsigned char *) 0xE01FC0C0))
#define PCONP (*((volatile unsigned long *) 0xE01FC0C4))
/* External Interrupts */
#define EXTINT (*((volatile unsigned char *) 0xE01FC140))
#define EXTWAKE (*((volatile unsigned char *) 0xE01FC144))
#define EXTMODE (*((volatile unsigned char *) 0xE01FC148))
#define EXTPOLAR (*((volatile unsigned char *) 0xE01FC14C))
/* Timer 0 */
#define T0IR (*((volatile unsigned long *) 0xE0004000))
#define T0TCR (*((volatile unsigned long *) 0xE0004004))
#define T0TC (*((volatile unsigned long *) 0xE0004008))
#define T0PR (*((volatile unsigned long *) 0xE000400C))
#define T0PC (*((volatile unsigned long *) 0xE0004010))
#define T0MCR (*((volatile unsigned long *) 0xE0004014))
#define T0MR0 (*((volatile unsigned long *) 0xE0004018))
#define T0MR1 (*((volatile unsigned long *) 0xE000401C))
#define T0MR2 (*((volatile unsigned long *) 0xE0004020))
#define T0MR3 (*((volatile unsigned long *) 0xE0004024))
#define T0CCR (*((volatile unsigned long *) 0xE0004028))
#define T0CR0 (*((volatile unsigned long *) 0xE000402C))
#define T0CR1 (*((volatile unsigned long *) 0xE0004030))
#define T0CR2 (*((volatile unsigned long *) 0xE0004034))
#define T0CR3 (*((volatile unsigned long *) 0xE0004038))
#define T0EMR (*((volatile unsigned long *) 0xE000403C))
/* Timer 1 */
#define T1IR (*((volatile unsigned long *) 0xE0008000))
#define T1TCR (*((volatile unsigned long *) 0xE0008004))
#define T1TC (*((volatile unsigned long *) 0xE0008008))
#define T1PR (*((volatile unsigned long *) 0xE000800C))
#define T1PC (*((volatile unsigned long *) 0xE0008010))
#define T1MCR (*((volatile unsigned long *) 0xE0008014))
#define T1MR0 (*((volatile unsigned long *) 0xE0008018))
#define T1MR1 (*((volatile unsigned long *) 0xE000801C))
#define T1MR2 (*((volatile unsigned long *) 0xE0008020))
#define T1MR3 (*((volatile unsigned long *) 0xE0008024))
#define T1CCR (*((volatile unsigned long *) 0xE0008028))
#define T1CR0 (*((volatile unsigned long *) 0xE000802C))
#define T1CR1 (*((volatile unsigned long *) 0xE0008030))
#define T1CR2 (*((volatile unsigned long *) 0xE0008034))
#define T1CR3 (*((volatile unsigned long *) 0xE0008038))
#define T1EMR (*((volatile unsigned long *) 0xE000803C))
/* Pulse Width Modulator (PWM) */
#define PWMIR (*((volatile unsigned long *) 0xE0014000))
#define PWMTCR (*((volatile unsigned long *) 0xE0014004))
#define PWMTC (*((volatile unsigned long *) 0xE0014008))
#define PWMPR (*((volatile unsigned long *) 0xE001400C))
#define PWMPC (*((volatile unsigned long *) 0xE0014010))
#define PWMMCR (*((volatile unsigned long *) 0xE0014014))
#define PWMMR0 (*((volatile unsigned long *) 0xE0014018))
#define PWMMR1 (*((volatile unsigned long *) 0xE001401C))
#define PWMMR2 (*((volatile unsigned long *) 0xE0014020))
#define PWMMR3 (*((volatile unsigned long *) 0xE0014024))
#define PWMMR4 (*((volatile unsigned long *) 0xE0014040))
#define PWMMR5 (*((volatile unsigned long *) 0xE0014044))
#define PWMMR6 (*((volatile unsigned long *) 0xE0014048))
#define PWMCCR (*((volatile unsigned long *) 0xE0014028))
#define PWMCR0 (*((volatile unsigned long *) 0xE001402C))
#define PWMCR1 (*((volatile unsigned long *) 0xE0014030))
#define PWMCR2 (*((volatile unsigned long *) 0xE0014034))
#define PWMCR3 (*((volatile unsigned long *) 0xE0014038))
#define PWMEMR (*((volatile unsigned long *) 0xE001403C))
#define PWMPCR (*((volatile unsigned long *) 0xE001404C))
#define PWMLER (*((volatile unsigned long *) 0xE0014050))
/* Universal Asynchronous Receiver Transmitter 0 (UART0) */
#define U0RBR (*((volatile unsigned char *) 0xE000C000))
#define U0THR (*((volatile unsigned char *) 0xE000C000))
#define U0IER (*((volatile unsigned char *) 0xE000C004))
#define U0IIR (*((volatile unsigned char *) 0xE000C008))
#define U0FCR (*((volatile unsigned char *) 0xE000C008))
#define U0LCR (*((volatile unsigned char *) 0xE000C00C))
#define U0MCR (*((volatile unsigned char *) 0xE000C010))
#define U0LSR (*((volatile unsigned char *) 0xE000C014))
#define U0MSR (*((volatile unsigned char *) 0xE000C018))
#define U0SCR (*((volatile unsigned char *) 0xE000C01C))
#define U0FDR (*((volatile unsigned char *) 0xE000C028))
#define U0DLL (*((volatile unsigned char *) 0xE000C000))
#define U0DLM (*((volatile unsigned char *) 0xE000C004))
/* Universal Asynchronous Receiver Transmitter 1 (UART1) */
#define U1RBR (*((volatile unsigned char *) 0xE0010000))
#define U1THR (*((volatile unsigned char *) 0xE0010000))
#define U1IER (*((volatile unsigned char *) 0xE0010004))
#define U1IIR (*((volatile unsigned char *) 0xE0010008))
#define U1FCR (*((volatile unsigned char *) 0xE0010008))
#define U1LCR (*((volatile unsigned char *) 0xE001000C))
#define U1MCR (*((volatile unsigned char *) 0xE0010010))
#define U1LSR (*((volatile unsigned char *) 0xE0010014))
#define U1MSR (*((volatile unsigned char *) 0xE0010018))
#define U1SCR (*((volatile unsigned char *) 0xE001001C))
#define U1DLL (*((volatile unsigned char *) 0xE0010000))
#define U1DLM (*((volatile unsigned char *) 0xE0010004))
/* I2C Interface */
#define I2CONSET (*((volatile unsigned char *) 0xE001C000))
#define I2STAT (*((volatile unsigned char *) 0xE001C004))
#define I2DAT (*((volatile unsigned char *) 0xE001C008))
#define I2ADR (*((volatile unsigned char *) 0xE001C00C))
#define I2SCLH (*((volatile unsigned short*) 0xE001C010))
#define I2SCLL (*((volatile unsigned short*) 0xE001C014))
#define I2CONCLR (*((volatile unsigned char *) 0xE001C018))
/* SPI0 (Serial Peripheral Interface 0) */
#define S0SPCR (*((volatile unsigned char *) 0xE0020000))
#define S0SPSR (*((volatile unsigned char *) 0xE0020004))
#define S0SPDR (*((volatile unsigned char *) 0xE0020008))
#define S0SPCCR (*((volatile unsigned char *) 0xE002000C))
#define S0SPTCR (*((volatile unsigned char *) 0xE0020010))
#define S0SPTSR (*((volatile unsigned char *) 0xE0020014))
#define S0SPTOR (*((volatile unsigned char *) 0xE0020018))
#define S0SPINT (*((volatile unsigned char *) 0xE002001C))
/* SPI1 (Serial Peripheral Interface 1) */
#define S1SPCR (*((volatile unsigned char *) 0xE0030000))
#define S1SPSR (*((volatile unsigned char *) 0xE0030004))
#define S1SPDR (*((volatile unsigned char *) 0xE0030008))
#define S1SPCCR (*((volatile unsigned char *) 0xE003000C))
#define S1SPTCR (*((volatile unsigned char *) 0xE0030010))
#define S1SPTSR (*((volatile unsigned char *) 0xE0030014))
#define S1SPTOR (*((volatile unsigned char *) 0xE0030018))
#define S1SPINT (*((volatile unsigned char *) 0xE003001C))
/* Real Time Clock */
#define ILR (*((volatile unsigned char *) 0xE0024000))
#define CTC (*((volatile unsigned short*) 0xE0024004))
#define CCR (*((volatile unsigned char *) 0xE0024008))
#define CIIR (*((volatile unsigned char *) 0xE002400C))
#define AMR (*((volatile unsigned char *) 0xE0024010))
#define CTIME0 (*((volatile unsigned long *) 0xE0024014))
#define CTIME1 (*((volatile unsigned long *) 0xE0024018))
#define CTIME2 (*((volatile unsigned long *) 0xE002401C))
#define SEC (*((volatile unsigned char *) 0xE0024020))
#define MIN (*((volatile unsigned char *) 0xE0024024))
#define HOUR (*((volatile unsigned char *) 0xE0024028))
#define DOM (*((volatile unsigned char *) 0xE002402C))
#define DOW (*((volatile unsigned char *) 0xE0024030))
#define DOY (*((volatile unsigned short*) 0xE0024034))
#define MONTH (*((volatile unsigned char *) 0xE0024038))
#define YEAR (*((volatile unsigned short*) 0xE002403C))
#define ALSEC (*((volatile unsigned char *) 0xE0024060))
#define ALMIN (*((volatile unsigned char *) 0xE0024064))
#define ALHOUR (*((volatile unsigned char *) 0xE0024068))
#define ALDOM (*((volatile unsigned char *) 0xE002406C))
#define ALDOW (*((volatile unsigned char *) 0xE0024070))
#define ALDOY (*((volatile unsigned short*) 0xE0024074))
#define ALMON (*((volatile unsigned char *) 0xE0024078))
#define ALYEAR (*((volatile unsigned short*) 0xE002407C))
#define PREINT (*((volatile unsigned short*) 0xE0024080))
#define PREFRAC (*((volatile unsigned short*) 0xE0024084))
/* A/D Converter */
#define ADCR (*((volatile unsigned long *) 0xE0034000))
#define ADDR (*((volatile unsigned long *) 0xE0034004))
/* Watchdog */
#define WDMOD (*((volatile unsigned char *) 0xE0000000))
#define WDTC (*((volatile unsigned long *) 0xE0000004))
#define WDFEED (*((volatile unsigned char *) 0xE0000008))
#define WDTV (*((volatile unsigned long *) 0xE000000C))
/* Memory Mapping control register */
#define MEMMAP (*((volatile unsigned long *) 0xE01FC040))
#endif /* __ASM_ARCH_HARDWARE_H */

View file

@ -0,0 +1,60 @@
/* identify the Entry Point */
ENTRY(Reset_Handler)
/* specify the LPC2106 memory areas */
MEMORY
{
flash : ORIGIN = 0x00000000, LENGTH = 128K /* free FLASH EPROM area */
ram : ORIGIN = 0x40000200, LENGTH = 64K - 0x200 /* free RAM area */
}
/* define a global symbol _stack_end */
_stack_end = 0x4000FEDC;
/* now define the output sections */
SECTIONS
{
startup :
{
*(.startup)
} >ram /* the startup code goes into FLASH */
.text : /* collect all sections that should go into FLASH after startup */
{
*(.text) /* all .text sections (code) */
*(.rodata) /* all .rodata sections (constants, strings, etc.) */
*(.rodata*) /* all .rodata* sections (constants, strings, etc.) */
*(.glue_7) /* all .glue_7 sections (no idea what these are) */
*(.glue_7t) /* all .glue_7t sections (no idea what these are) */
_etext = .; /* define a global symbol _etext just after the last code byte */
} >ram /* put all the above into FLASH */
.data : /* collect all initialized .data sections that go into RAM */
{
_data = .; /* create a global symbol marking the start of the .data section */
*(.data) /* all .data sections */
_edata = .; /* define a global symbol marking the end of the .data section */
} >ram /* put all the above into RAM (but load the LMA copy into FLASH) */
.bss : /* collect all uninitialized .bss sections that go into RAM */
{
_bss_start = .; /* define a global symbol marking the start of the .bss section */
*(.bss) /* all .bss sections */
} >ram /* put all the above in RAM (it will be cleared in the startup code */
. = ALIGN(4); /* advance location counter to the next 32-bit boundary */
_bss_end = . ; /* define a global symbol marking the end of the .bss section */
_end = .; /* define a global symbol marking the end of application RAM */
}
PROVIDE( BCFG0 = 0xFFE00000);
PROVIDE( BCFG1 = 0xFFE00004);
PROVIDE( BCFG2 = 0xFFE00008);
PROVIDE( PINSEL0 = 0xE002C000);
PROVIDE( PINSEL2 = 0xE002C014);
PROVIDE( IO0PIN = 0xE0028000);

View file

@ -0,0 +1,61 @@
/* identify the Entry Point */
ENTRY(_startup)
/* specify the LPC2106 memory areas */
MEMORY
{
flash : ORIGIN = 0x80000000, LENGTH = 1M /* FLASH ROM */
ram : ORIGIN = 0x40000200, LENGTH = 64K - 0x220 /* free RAM area */
}
/* define a global symbol _stack_end */
_stack_end = 0x4000FEDC;
/* now define the output sections */
SECTIONS
{
. = 0; /* set location counter to address zero */
startup :
{
*(.startup)
} >flash /* the startup code goes into FLASH */
.text : /* collect all sections that should go into FLASH after startup */
{
*(.text) /* all .text sections (code) */
*(.rodata) /* all .rodata sections (constants, strings, etc.) */
*(.rodata*) /* all .rodata* sections (constants, strings, etc.) */
*(.glue_7) /* all .glue_7 sections (no idea what these are) */
*(.glue_7t) /* all .glue_7t sections (no idea what these are) */
_etext = .; /* define a global symbol _etext just after the last code byte */
} >flash /* put all the above into FLASH */
.data : /* collect all initialized .data sections that go into RAM */
{
_data = .; /* create a global symbol marking the start of the .data section */
*(.data) /* all .data sections */
_edata = .; /* define a global symbol marking the end of the .data section */
} >ram AT >flash /* put all the above into RAM (but load the LMA copy into FLASH) */
.bss : /* collect all uninitialized .bss sections that go into RAM */
{
_bss_start = .; /* define a global symbol marking the start of the .bss section */
*(.bss) /* all .bss sections */
} >ram /* put all the above in RAM (it will be cleared in the startup code */
. = ALIGN(4); /* advance location counter to the next 32-bit boundary */
_bss_end = . ; /* define a global symbol marking the end of the .bss section */
}
_end = .; /* define a global symbol marking the end of application RAM */
PROVIDE( BCFG0 = 0xFFE00000);
PROVIDE( BCFG1 = 0xFFE00004);
PROVIDE( BCFG2 = 0xFFE00008);
PROVIDE( PINSEL0 = 0xE002C000);
PROVIDE( PINSEL2 = 0xE002C014);
PROVIDE( IO0PIN = 0xE0028000);

View file

@ -0,0 +1,368 @@
void IRQ_Routine (void) __attribute__ ((interrupt("IRQ")));
void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
void SWI_Routine (void) __attribute__ ((interrupt("SWI")));
void UNDEF_Routine (void) __attribute__ ((interrupt("UNDEF")));
typedef volatile unsigned int *reg32_t;
#include "lpc2220.h"
#include "serial.h"
#include "flash.h"
#include "lcd.h"
#include "../toolcmd.h"
#include "fonty.h"
union
{
unsigned long wbuf[128];
unsigned short sbuf[256];
unsigned char bbuf[512];
} buf;
unsigned long checksum;
unsigned short count;
unsigned long adr;
unsigned long numBytes;
void putHN(unsigned char pos, unsigned long hn)
{
draw_string(33,pos,"0x",3,DRAW_PUT);
draw_hexW(45,pos,hn,3,DRAW_PUT);
}
void putInfoVal(unsigned char pos, char *name, unsigned long val)
{
draw_block(0, pos, 128, 8, 3, DRAW_ERASE);
draw_string(0,pos,name,3,DRAW_PUT);
putHN(pos, val);
}
void ACK(void)
{
serial_puts(ACKTOKEN);
}
void BACK(void)
{
serial_puts(BACKTOKEN);
}
void NACK(void)
{
serial_puts(NACKTOKEN);
}
int receiveBuf(void)
{
unsigned long ccheck;
unsigned short cnt, cnt2, cnt3;
cnt = count<<2;
if(cnt > 512)
return 0;
checksum = 0;
ccheck = 0;
cnt2 = 0;
#define XFERSIZE 16
while(cnt >= XFERSIZE)
{
cnt3=XFERSIZE;
while(cnt3--)
{
buf.bbuf[cnt2] = serial_getc();
checksum += buf.bbuf[cnt2++];
}
BACK();
cnt -= XFERSIZE;
}
if(cnt)
{
while(cnt--)
{
buf.bbuf[cnt2] = serial_getc();
checksum += buf.bbuf[cnt2++];
}
BACK();
}
ccheck = serial_getc() << 24;
ccheck += serial_getc() << 16;
ccheck += serial_getc() << 8;
ccheck += serial_getc();
if(ccheck == checksum)
{
return 1;
}
drawStatus("Wrong Checksum");
return 0;
}
int main(void)
{
unsigned char i;
unsigned char counter;
count = 0;
adr = 0x00000000;
timer = TIMEOUT+1;
numBytes = 0;
lcd_init(0);
IODIR0|=0x10;
IOCLR0=0x10;
serial_init();
set_font(1);
#ifdef RESIDENT
draw_string(0, 0,">> FlashTool V0.2-r",3,DRAW_PUT);
#else
draw_string(0, 0,">> FlashTool V0.2",3,DRAW_PUT);
#endif
set_font(0);
draw_string(0,14,"This tool is licensed under",3,DRAW_PUT);
draw_string(0,22,"the GNU GPL 3 or later",3,DRAW_PUT);
draw_string(0,34,"(c) 2007 Ch. Klippel",3,DRAW_PUT);
draw_string(0,42,"<ck@mamalala.net>",3,DRAW_PUT);
drawStatus("FlashTool ready!");
adr = 0x00000000;
while (1)
{
i = serial_getc();
if (i) // misses 0x00 !
{
counter += 10;
if ( counter > 100)
counter = 50;
putInfoVal(counter, "i:", i);
}
if(i==HELO_CMD)
{
serial_puts(HELOTOKEN);
drawStatus("Sent HELO");
}
else if(i==BULKENABLE_CMD)
{
putInfoVal(80, "Bulk:", 1);
if((adr & 0xFF000000) == 0x80000000 || (adr & 0xFF000000) == 0x82000000)
{
prepareBulk(adr);
drawStatus("Enabled bulk write");
draw_string(100,80,ACKTOKEN,3,DRAW_PUT);
ACK();
}
else
{
draw_string(100,80,NACKTOKEN,3,DRAW_PUT);
NACK();
}
}
else if(i==SKIP_CMD)
{
adr += (serial_getc() << 16);
adr += serial_getc();
ACK();
}
else if(i==BULKDISABLE_CMD)
{
putInfoVal(80, "Bulk:", 0);
if((adr & 0xFF000000) == 0x80000000 || (adr & 0xFF000000) == 0x82000000)
{
endBulk(adr);
drawStatus("Disabled bulk write");
draw_string(100,80,ACKTOKEN,3,DRAW_PUT);
ACK();
}
else
{
draw_string(100,80,NACKTOKEN,3,DRAW_PUT);
NACK();
}
}
else if(i==SETADR_CMD)
{
adr = serial_getc() << 24;
adr += serial_getc() << 16;
adr += serial_getc() << 8;
adr += serial_getc();
putInfoVal(72, "Addr:", adr);
if((adr & 0xFF000000) == 0x40000000 || (adr & 0xFF000000) == 0x80000000 || (adr & 0xFF000000) == 0x82000000)
{
drawStatus("Address changed");
draw_string(100,72,ACKTOKEN,3,DRAW_PUT);
ACK();
}
else
{
draw_string(100,72,NACKTOKEN,3,DRAW_PUT);
adr = 0x00000000;
NACK();
}
}
else if(i==FILLBUF_CMD)
{
count = serial_getc();
putInfoVal(88, "Buf:", count<<2);
if(count > 0 && count <= 128)
{
if(receiveBuf())
{
ACK();
}
else
{
goto fail_f;
}
}
else
{
fail_f:
draw_string(100,88,NACKTOKEN,3,DRAW_PUT);
count = 0;
NACK();
}
}
else if(i==WRITE_CMD)
{
putInfoVal(96, "Write:", adr);
i = serial_getc();
if(i==WRITEGO_CMD && count > 0)
{
if(writeBulk((unsigned long) &buf.bbuf, adr, count<<1) == 0)
{
adr += (count<<2);
ACK();
}
else
{
draw_string(100,96,NACKTOKEN,3,DRAW_PUT);
NACK();
}
}
}
else if(i==SECTERASE_CMD)
{
drawStatus("Erasing Flash Sector");
if(eraseSectorAt(adr) == 0)
{
drawStatus("Erased Flash Sector");
ACK();
}
else
{
drawStatus("Erase Sector FAILED!!");
NACK();
}
}
else if(i==FULLERASE_CMD)
{
unsigned char w;
w = 0xFF;
if((adr & 0xFF000000) == 0x82000000)
{
drawStatus("Erasing Flash #1");
w = 1;
}
else
{
drawStatus("Erasing Flash #0");
w = 0;
}
if(eraseFlash(w) == 0)
{
if(w==1)
{
drawStatus("Erased Flash #1");
}
else if(w==0)
{
drawStatus("Erased Flash #0");
}
ACK();
}
else
{
if(w)
{
drawStatus("Flash #1 Erase FAILED!!");
}
else
{
drawStatus("Flash #0 Erase FAILED!!");
}
NACK();
}
}
else if(i==SETNUMBYTES_CMD)
{
numBytes = serial_getc() << 24;
numBytes += serial_getc() << 16;
numBytes += serial_getc() << 8;
numBytes += serial_getc();
putInfoVal(104, "NumB:", numBytes);
if(numBytes <= 0x00100000)
{
draw_string(100,104,ACKTOKEN,3,DRAW_PUT);
ACK();
}
else
{
draw_string(100,104,NACKTOKEN,3,DRAW_PUT);
NACK();
}
}
else if(i==READ_CMD)
{
for(adr = 0x40000200; adr < 0x40000210; adr+=4)
{
putHexW((unsigned long)(*(volatile unsigned long *)(adr)));
serial_putc('\n');
}
for(adr = 0x80000000; adr < 0x80000010; adr+=4)
{
putHexW((unsigned long)(*(volatile unsigned long *)(adr)));
serial_putc('\n');
}
}
}
return 0;
}
/* Stubs for various interrupts (may be replaced later) */
/* ---------------------------------------------------- */
void IRQ_Routine (void) {
while (1) ;
}
void FIQ_Routine (void) {
while (1) ;
}
void SWI_Routine (void) {
while (1) ;
}
void UNDEF_Routine (void) {
while (1) ;
}

View file

@ -0,0 +1,247 @@
/*
* minor changes (c) 2007 ch.klippel
*
* (C) Copyright 2004
* DAVE Srl
* http://www.dave-tech.it
* http://www.wawnet.biz
* mailto:info@wawnet.biz
*
* (C) Copyright 2002-2004
* Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
*
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Marius Groeger <mgroeger@sysgo.de>
*
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Alex Zuepke <azu@sysgo.de>
*
* Copyright (C) 1999 2000 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "lpc2220.h"
#include "serial.h"
#include "lcd.h"
#include "../baudrate.h"
unsigned long timer;
/* flush serial input queue. returns 0 on success or negative error
* number otherwise
*/
int serial_flush_input(void)
{
volatile unsigned int tmp;
/* keep on reading as long as the receiver is not empty */
while(RX_DATA(U0LSR)) {
tmp = GET_CHAR(U0RBR);
}
return 0;
}
/* flush output queue. returns 0 on success or negative error number
* otherwise
*/
int serial_flush_output(void)
{
/* wait until the transmitter is no longer busy */
while(TX_READY(U0LSR)==0) {
}
return 0;
}
void serial_setbrg (unsigned int baudrate)
{
/* get correct divisor */
U0LCR = 0x83;
switch(baudrate) {
case 75:
U0DLL = 161;
U0DLM = 1;
U0FDR = (1 << 4) + 14;
break;
case 150:
U0DLL = 195;
U0DLM = 0;
U0FDR = (1 << 4) + 15;
break;
case 300:
U0DLL = 184;
U0DLM = 0;
U0FDR = (2 << 4) + 15;
break;
case 600:
U0DLL = 156;
U0DLM = 0;
U0FDR = (1 << 4) + 4;
break;
case 1200:
U0DLL = 130;
U0DLM = 0;
U0FDR = (7 << 4) + 14;
break;
case 2400:
U0DLL = 180;
U0DLM = 0;
U0FDR = (12 << 4) + 1;
break;
case 4800:
U0DLL = 90;
U0DLM = 0;
U0FDR = (1 << 4) + 4;
break;
case 9600:
U0DLL = 23;
U0DLM = 0;
U0FDR = (8 << 4) + 9;
break;
case 19200:
U0DLL = 11;
U0DLM = 0;
U0FDR = (9 << 4) + 11;
break;
case 38400:
U0DLL = 5;
U0DLM = 0;
U0FDR = (9 << 4) + 13;
break;
case 57600:
U0DLL = 6;
U0DLM = 0;
U0FDR = (14 << 4) + 5;
break;
case 115200:
U0DLL = 3;
U0DLM = 0;
U0FDR = (14 << 4) + 5;
break;
}
U0LCR = 0x03;
serial_flush_output();
serial_flush_input();
}
/*
* Initialise the serial port with the given baudrate. The settings
* are always 8 data bits, no parity, 1 stop bit, no start bits.
*
*/
int serial_init (void)
{
PINSEL0=0x05; // pin select -> tx, rx
serial_setbrg (TOOLBAUD);
U0FCR = 0x07; // enable fifo
timer = TIMEOUT+1;
return (0);
}
/*
* Output a single byte to the serial port.
*/
void serial_putc (const char c)
{
/* wait for room in the transmit FIFO */
while(TX_READY(U0LSR)==0);
PUT_CHAR(U0THR,c);
}
/*
* Read a single byte from the serial port. Returns 1 on success, 0
* otherwise. When the function is succesfull, the character read is
* written into its argument c.
*/
int serial_tstc (void)
{
return (RX_DATA(U0LSR));
}
/*
* Read a single byte from the serial port. Returns 1 on success, 0
* otherwise. When the function is succesfull, the character read is
* written into its argument c.
*/
int serial_getc (void)
{
while(((U0LSR) & USRRxData) <= 0)
{
if(timer == TIMEOUT)
{
clearStatus();
timer++;
}
else if(timer < TIMEOUT)
{
timer++;
}
}
return (U0RBR);
}
void serial_puts (const char *s)
{
while (*s != 0) {
serial_putc (*s++);
}
}
const char hval[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };
void putHexC(const unsigned char v)
{
serial_putc(hval[v>>4]);
serial_putc(hval[v & 0x0F]);
}
void putHexS(const unsigned short v)
{
putHexC(v >> 8);
putHexC(v & 0xFF);
}
void putHexW(const unsigned long v)
{
putHexS(v >> 16);
putHexS(v & 0xFFFF);
}

View file

@ -0,0 +1,24 @@
#ifndef BOOP_SERIAL_H
#define BOOP_SERIAL_H
#define USRRxData (1 << 0)
#define USRTxHoldEmpty (1 << 6)
#define GET_CHAR(p) p
#define PUT_CHAR(p,c) (p= (unsigned )(c))
#define TX_READY(s) ((s) & USRTxHoldEmpty)
#define RX_DATA(s) ((s) & USRRxData)
int serial_flush_input(void);
int serial_flush_output(void);
void serial_setbrg (unsigned int baudrate);
int serial_init (void);
void serial_putc (const char c);
int serial_tstc (void);
int serial_getc (void);
void serial_puts (const char *s);
void putHexC(const unsigned char v);
void putHexS(const unsigned short v);
void putHexW(const unsigned long v);
#endif /* BOOP_SERIAL_H */