From dbbb7d4ca12c21c84af2f72f7c75ce7a3559dcad Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 14 Sep 2007 16:17:42 +0200 Subject: [PATCH 01/16] display extended (untested!) --- betty/display.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++--- betty/display.h | 6 +++- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/betty/display.c b/betty/display.c index ce8fd7c..a439fcd 100644 --- a/betty/display.c +++ b/betty/display.c @@ -50,7 +50,7 @@ void display_fill_screen(u8 fill) { } for(page=0;pagey+h) rmax=y+h; for(col=x;col>1)&1)<>3);page<=((y+8)>>3);page++) { // page = y/8 + DISPLAY_SET_PAGE_ADDR(page); + rmax=(page+1)<<3; // row max + if(rmax>y+left) + rmax=y+left; + cf=0; + for(col=x;col>row)&1) { + c=(ca+cb)>>8; + d[0]&=~(1<>1)&1)<>3);page<=((y+h)>>3);page++) { + DISPLAY_SET_PAGE_ADDR(page); + for(col=x;col>4)) #define DISPLAY_SET_MASTER DISPLAY_CMD=0x18 #define DISPLAY_SET_SLAVE DISPLAY_CMD=0x19 @@ -94,6 +94,10 @@ DISPLAY_CMD=(c) #define DISPLAY_EXTENDED_FEATURES DISPLAY_CMD=0xf0 +/* experimental cmds */ +#define DISPLAY_SET_READ_MODIFY_WRITE DISPLAY_CMD=0xe0; +#define DISPLAY_UNSET_READ_MODIFY_WRITE DISPLAY_CMD=0xee; + /* display api specific defines */ #define DISPLAY_FILL_W 0x00 #define DISPLAY_FILL_LG 0x01 -- 2.20.1 From 1e22999d37f2a67dbbaa296c4b2af09affe07a15 Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 14 Sep 2007 23:13:21 +0200 Subject: [PATCH 02/16] get rid of overflow warning --- betty/fwflash.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/betty/fwflash.c b/betty/fwflash.c index 85a64fa..26a68a8 100644 --- a/betty/fwflash.c +++ b/betty/fwflash.c @@ -467,7 +467,8 @@ int main(void) { uart0_send_buf16((u16 *)addr,datalen); if((addr>=BANK2)&(addr+datalen<=BANK2+BANK_SIZE)) uart0_send_buf16((u16 *)addr,datalen); - if((addr>=BOOTLOADER)&(addr+datalen<=BOOTLOADER+BL_SIZE)) + if((addr>=BOOTLOADER)& + (addr+datalen Date: Sat, 15 Sep 2007 00:19:54 +0200 Subject: [PATCH 03/16] make the logo constant --- betty/bmp2b.c | 2 +- betty/default_logo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/betty/bmp2b.c b/betty/bmp2b.c index e006609..0010f15 100644 --- a/betty/bmp2b.c +++ b/betty/bmp2b.c @@ -92,7 +92,7 @@ int main(int argc,char **argv) { } if(stat==CHAR) - dprintf(fd,"unsigned char default_logo[%d]={\n",DX*PM*2); + dprintf(fd,"const unsigned char default_logo[%d]={\n",DX*PM*2); for(page=0;page Date: Sat, 15 Sep 2007 00:22:31 +0200 Subject: [PATCH 04/16] enhanced linker script and startup --- betty/Makefile | 6 ++-- betty/lpc2220_ram.ld | 9 ++++- betty/lpc2220_rom.ld | 19 ++++++++-- betty/startup.s | 84 ++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 110 insertions(+), 8 deletions(-) diff --git a/betty/Makefile b/betty/Makefile index f6d465f..28184c3 100644 --- a/betty/Makefile +++ b/betty/Makefile @@ -20,7 +20,7 @@ CROSS_TARGET = fwbc.hex fwflash.hex betty.hex # betty deps BETTY_DEPS = system.o uart.o buttons.o spi.o display.o flash.o functions.o -#BETTY_DEPS += pffs.o +BETTY_DEPS += interrupts.o #pffs.o # all projects all: $(HOST_TARGET) $(CROSS_TARGET) @@ -48,8 +48,8 @@ arm: arm_clean $(CROSS_TARGET) $(CROSS_AS) $(CROSS_ASLAGS) -o $@ $< # .elf out of .o -%.elf: %.o startup.o - $(CROSS_LD) $(CROSS_RAM_LDFLAGS) startup.o -o $@ $< +%.elf: %.o startup.o interrupts.o + $(CROSS_LD) $(CROSS_RAM_LDFLAGS) startup.o interrupts.o -o $@ $< # betty is special ;) betty.elf: betty.o startup.o $(BETTY_DEPS) diff --git a/betty/lpc2220_ram.ld b/betty/lpc2220_ram.ld index c6fd14d..7356893 100644 --- a/betty/lpc2220_ram.ld +++ b/betty/lpc2220_ram.ld @@ -20,7 +20,14 @@ SECTIONS { . = ALIGN(4); - .data : { *(.data) } /* initialized data */ + /* define end of text symbol */ + _etext = .; + + .data : { /* initialized data */ + _data = .; + *(.data) + _edata = .; + } . = ALIGN(4); diff --git a/betty/lpc2220_rom.ld b/betty/lpc2220_rom.ld index ab48644..92a99a0 100644 --- a/betty/lpc2220_rom.ld +++ b/betty/lpc2220_rom.ld @@ -32,12 +32,27 @@ SECTIONS { . = ALIGN(4); + /* define text end symbol */ + _etext = .; + PROVIDE(etext = .); + /* initialized data */ - .data : { *(.data) } > RAM AT FLASH_BANK0 + .data : { + _data = .; + *(.data) + } > RAM AT > FLASH_BANK0 . = ALIGN(4); + /* define data end symbol */ + _edata = .; + PROVIDE(edata = .); + /* uninitialized data */ - .bss : { *(.bss) } > RAM AT FLASH_BANK0 + .bss (NOLOAD) : { *(.bss) } > RAM + + /* define bss end symbol */ + _bss_end = .; + PROVIDE(bss_end = .); } diff --git a/betty/startup.s b/betty/startup.s index bc4ff41..af87f6e 100644 --- a/betty/startup.s +++ b/betty/startup.s @@ -16,10 +16,31 @@ # stack -.equ stack_size, (2*1024) +.equ stack_size, (4*1024) .equ stack_top, sram_top .equ stack_limit, (sram_top-stack_size) +.equ stack_size_fiq, 64 +.equ stack_size_irq, 256 +.equ stack_size_supervisor, 64 +.equ stack_size_abort, 64 +.equ stack_size_undefined, 64 +.equ stack_size_system, 1024 + +# arm modes - control bits of the program status register +# ref: chapter 2.8, arm7tdmi-s technical reference manual + +.equ mode_user, 0x10 +.equ mode_fiq, 0x11 +.equ mode_irq, 0x12 +.equ mode_supervisor, 0x13 +.equ mode_abort, 0x17 +.equ mode_undefined, 0x1b +.equ mode_system, 0x1f + +.equ fiq_disable, 0x40 +.equ irq_disable, 0x80 + # # the startup code # @@ -27,13 +48,72 @@ .text .arm - # init stack pointer + # exception handling must go to the very beginning + + b handler_reset + b handler_undef_instruction + b handler_soft_ir + b handler_prefetch_abort + b handler_data_abort + nop + b handler_irq + b handler_fiq + + handler_undef_instruction: .word interrupt_handler_undef_instruction + handler_soft_ir: .word interrupt_handler_soft_ir + handler_prefetch_abort: .word interrupt_handler_prefetch_abort + handler_data_abort: .word interrupt_handler_data_abort + handler_irq: .word interrupt_handler_irq + handler_fiq: .word interrupt_handler_fiq + + # reset handling goes here + +handler_reset: + + # init stack pointer for each mode + set stack limit ldr r0, =sram_top + + msr cpsr_c, #mode_undefined|irq_disable|fiq_disable mov sp, r0 + sub r0, r0, #stack_size_undefined + + msr cpsr_c, #mode_abort|irq_disable|fiq_disable + mov sp, r0 + sub r0, r0, #stack_size_abort + + msr cpsr_c, #mode_fiq|irq_disable|fiq_disable + mov sp, r0 + sub r0, r0, #stack_size_fiq + + msr cpsr_c, #mode_irq|irq_disable|fiq_disable + mov sp, r0 + sub r0, r0, #stack_size_irq + + msr cpsr_c, #mode_supervisor|irq_disable|fiq_disable + mov sp, r0 + sub r0, r0, #stack_size_supervisor + + msr cpsr_c, #mode_system|irq_disable|fiq_disable + mov sp, r0 + sub r0, r0, #stack_size_system + ldr r0, =stack_limit mov sl, r0 + # copy data section + + ldr r1, =_etext + ldr r2, =_data + ldr r3, =_edata + +copy_data_loop: + + cmp r2, r3 + ldrlo r0, [r1], #4 + strlo r0, [r2], #4 + blo copy_data_loop + # jump to c code adr lr, loop_forever -- 2.20.1 From 026d6884ee8185fe08296b31d4bb570662cf2add Mon Sep 17 00:00:00 2001 From: hackbard Date: Sat, 15 Sep 2007 01:03:06 +0200 Subject: [PATCH 05/16] interrupts --- betty/startup.s | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/betty/startup.s b/betty/startup.s index af87f6e..7cf1e10 100644 --- a/betty/startup.s +++ b/betty/startup.s @@ -51,20 +51,13 @@ # exception handling must go to the very beginning b handler_reset - b handler_undef_instruction - b handler_soft_ir - b handler_prefetch_abort - b handler_data_abort + b interrupt_handler_undef_instruction + b interrupt_handler_soft_ir + b interrupt_handler_prefetch_abort + b interrupt_handler_data_abort nop - b handler_irq - b handler_fiq - - handler_undef_instruction: .word interrupt_handler_undef_instruction - handler_soft_ir: .word interrupt_handler_soft_ir - handler_prefetch_abort: .word interrupt_handler_prefetch_abort - handler_data_abort: .word interrupt_handler_data_abort - handler_irq: .word interrupt_handler_irq - handler_fiq: .word interrupt_handler_fiq + b interrupt_handler_irq + b interrupt_handler_fiq # reset handling goes here -- 2.20.1 From 6543545b048b7059941b0f6680227ec4ce26535e Mon Sep 17 00:00:00 2001 From: hackbard Date: Sat, 15 Sep 2007 02:58:42 +0200 Subject: [PATCH 06/16] the interrupt routines --- betty/interrupts.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ betty/interrupts.h | 20 ++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 betty/interrupts.c create mode 100644 betty/interrupts.h diff --git a/betty/interrupts.c b/betty/interrupts.c new file mode 100644 index 0000000..fa1fcc1 --- /dev/null +++ b/betty/interrupts.c @@ -0,0 +1,45 @@ +/* + * interrupts.c - arm exception handling + * + * author: hackbard@hackdaworld.org + * + */ + +#include "interrupts.h" + +/* + * functions + */ + +/* + * the actual exception handlers (as defined in startup.s) + */ + +// reset +void interrupt_handler_reset(void) { +} + +// undefined instruction +void interrupt_handler_undef_instruction(void) { +} + +// software interrupt +void interrupt_handler_soft_ir(void) { +} + +// prefetch abort +void interrupt_handler_prefetch_abort(void) { +} + +// data abort +void interrupt_handler_data_abort(void) { +} + +// irq +void interrupt_handler_irq(void) { +} + +// fiq +void interrupt_handler_fiq(void) { +} + diff --git a/betty/interrupts.h b/betty/interrupts.h new file mode 100644 index 0000000..9c1b8aa --- /dev/null +++ b/betty/interrupts.h @@ -0,0 +1,20 @@ +/* + * interrupts.h - arm exception handling header file + * + * author: hackbard@hackdaworld.org + * + */ + +#include "lpc2xxx.h" +#include "types.h" + +/* function prototypes */ + +void interrupt_handler_reset(void); +void interrupt_handler_undef_instruction(void); +void interrupt_handler_soft_ir(void); +void interrupt_handler_prefetch_abort(void); +void interrupt_handler_data_abort(void); +void interrupt_handler_irq(void); +void interrupt_handler_fiq(void); + -- 2.20.1 From ac35214abd7d42a7294047d1c8b7ce7552a38fbf Mon Sep 17 00:00:00 2001 From: hackbard Date: Sat, 15 Sep 2007 04:31:01 +0200 Subject: [PATCH 07/16] decreased available ram size due to stack usage, working interrupt vectors --- betty/lpc2220_rom.ld | 2 +- betty/startup.s | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/betty/lpc2220_rom.ld b/betty/lpc2220_rom.ld index 92a99a0..40ed2ab 100644 --- a/betty/lpc2220_rom.ld +++ b/betty/lpc2220_rom.ld @@ -10,7 +10,7 @@ MEMORY { FLASH_BANK0 (rx) : ORIGIN = 0x80000000, LENGTH = 0x00100000 FLASH_BANK2 (rx) : ORIGIN = 0x82000000, LENGTH = 0x00100000 - RAM (rw) : ORIGIN = 0x40000000, LENGTH = 0x00010000 + RAM (rw) : ORIGIN = 0x40000000, LENGTH = 0x00010000 - (4 * 1024) } /* section definitions */ diff --git a/betty/startup.s b/betty/startup.s index 7cf1e10..d6b0184 100644 --- a/betty/startup.s +++ b/betty/startup.s @@ -50,18 +50,26 @@ # exception handling must go to the very beginning - b handler_reset - b interrupt_handler_undef_instruction - b interrupt_handler_soft_ir - b interrupt_handler_prefetch_abort - b interrupt_handler_data_abort + ldr pc, handler_reset + ldr pc, handler_undef_instruction + ldr pc, handler_soft_ir + ldr pc, handler_prefetch_abort + ldr pc, handler_data_abort nop - b interrupt_handler_irq - b interrupt_handler_fiq + ldr pc, handler_irq + ldr pc, handler_fiq + +handler_reset: .word handle_reset +handler_undef_instruction: .word interrupt_handler_undef_instruction +handler_soft_ir: .word interrupt_handler_soft_ir +handler_prefetch_abort: .word interrupt_handler_prefetch_abort +handler_data_abort: .word interrupt_handler_data_abort +handler_irq: .word interrupt_handler_irq +handler_fiq: .word interrupt_handler_fiq # reset handling goes here -handler_reset: +handle_reset: # init stack pointer for each mode + set stack limit -- 2.20.1 From 8d3d33c4904bfbdc95b290c5e5e6e60c92e30d7a Mon Sep 17 00:00:00 2001 From: hackbard Date: Sat, 15 Sep 2007 04:36:18 +0200 Subject: [PATCH 08/16] pause values somehow reasonable for flash and ram usage --- betty/betty.c | 22 ++++++++++++---------- betty/betty.h | 4 ++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/betty/betty.c b/betty/betty.c index c2aaa38..427d32b 100644 --- a/betty/betty.c +++ b/betty/betty.c @@ -46,13 +46,10 @@ int main() { * start it ... */ - /* pause - seems to not work if running from flash! (?) */ - pause(0xffffff); - /* display init */ display_bl_toggle(); display_init(); - contrast=0x32; + contrast=0x38; /* pasue again */ @@ -61,15 +58,14 @@ int main() { while(1) { - pause(0x0fffff); + pause(0x05ffff); /* button test! */ if(button_get_event(&button)) { - //uart0_send_string(announce); - uart0_send_byte(contrast); + uart0_send_string(announce); switch(button.key[0]) { case BUTTON_POWER: - display_load_logo(0); + display_logo((u8 *)default_logo); break; case BUTTON_DOWN: if(contrast>0x00) @@ -96,12 +92,18 @@ int main() { case BUTTON_1: display_draw_rectangle(20,20,40,40, DISPLAY_FILL_B, - 0); + 0xff); break; case BUTTON_2: display_draw_rectangle(50,50,40,40, DISPLAY_FILL_LG, - 0); + 0x7f); + break; + case BUTTON_3: + display_draw_font(70,70, + (u8 *)default_font+(0x33>>3), + DISPLAY_FILL_LG, + 0xff); break; default: display_clear_screen(); diff --git a/betty/betty.h b/betty/betty.h index 761f74d..f21d092 100644 --- a/betty/betty.h +++ b/betty/betty.h @@ -27,6 +27,10 @@ #include "flash.h" #include "pffs.h" +// font/logo +#include "default_font.h" +#include "default_logo.h" + /* * defines */ -- 2.20.1 From 4018a282d71b67d91e37b81edee111ff028d66c2 Mon Sep 17 00:00:00 2001 From: hackbard Date: Sun, 16 Sep 2007 02:06:57 +0200 Subject: [PATCH 09/16] basical alpha blending working (modulo minor pits) --- betty/betty.c | 33 ++++++++++++-- betty/display.c | 113 +++++++++++++++++++++++++++++++++--------------- betty/display.h | 7 ++- 3 files changed, 112 insertions(+), 41 deletions(-) diff --git a/betty/betty.c b/betty/betty.c index 427d32b..8d7ce84 100644 --- a/betty/betty.c +++ b/betty/betty.c @@ -58,11 +58,11 @@ int main() { while(1) { - pause(0x05ffff); + pause(0x0fffff); /* button test! */ if(button_get_event(&button)) { - uart0_send_string(announce); + //uart0_send_string(announce); switch(button.key[0]) { case BUTTON_POWER: display_logo((u8 *)default_logo); @@ -101,10 +101,37 @@ int main() { break; case BUTTON_3: display_draw_font(70,70, - (u8 *)default_font+(0x33>>3), + (u8 *)default_font+(0x33<<3), DISPLAY_FILL_LG, 0xff); break; + case BUTTON_4: + display_font_page(23,19,(u8 *)default_font+(0x34<<3),DISPLAY_FILL_B); + break; + case BUTTON_5: + display_font_page(10,19,(u8 *)default_font+(0x35<<3),DISPLAY_FILL_DG); + break; + case BUTTON_6: + display_font_page(2,19,(u8 *)default_font+(0x36<<3),DISPLAY_FILL_LG); + break; + case BUTTON_7: + display_draw_rectangle(2,2,4,4, + DISPLAY_FILL_B, + 0xff); + break; + case BUTTON_8: + display_draw_rectangle(8,8,4,4, + DISPLAY_FILL_DG, + 0xff); + break; + case BUTTON_BETTY: + display_rectangle_page(80,15,16,2,DISPLAY_FILL_B,0x7f); + uart0_send_byte('b'); + break; + case BUTTON_EXIT: + display_rectangle_page(90,16,16,2,DISPLAY_FILL_LG,0x7f); + uart0_send_byte('e'); + break; default: display_clear_screen(); break; diff --git a/betty/display.c b/betty/display.c index a439fcd..bb74241 100644 --- a/betty/display.c +++ b/betty/display.c @@ -17,8 +17,8 @@ */ #include "display.h" -#include "system.h" -#include "default_logo.h" + +// debug #include "uart.h" /* @@ -89,21 +89,16 @@ void display_init(void) { DISPLAY_SET_ON; } -void display_load_logo(u8 *src) { +void display_logo(u8 *src) { - u8 *s; u8 page,width; - s=src; - if(s==0) - s=default_logo; - for(page=0;page>8; + buf[0]&=~(1<>1]>>row)&1) { + c[cnt]&=~(1<>1)&1)<>3);page<=((y+h)>>3);page++) { - DISPLAY_SET_PAGE_ADDR(page); - for(col=x;col Date: Sun, 16 Sep 2007 16:19:55 +0200 Subject: [PATCH 10/16] alpha blending --- betty/Makefile | 2 +- betty/betty.c | 54 +++++++++++++++++++++++++---------------------- betty/display.c | 2 +- betty/functions.c | 23 ++++++++++++++++++-- betty/functions.h | 2 ++ 5 files changed, 54 insertions(+), 29 deletions(-) diff --git a/betty/Makefile b/betty/Makefile index 28184c3..4d2a1aa 100644 --- a/betty/Makefile +++ b/betty/Makefile @@ -11,7 +11,7 @@ CROSS_OBJCOPY = $(ARCH)-objcopy CROSS_OPTS = -mcpu=arm7tdmi-s CROSS_CFLAGS = $(CROSS_OPTS) -Wall -Os CROSS_ASLAGS = $(CROSS_OPTS) --gstabs -CROSS_RAM_LDFLAGS = -Tlpc2220_ram.ld -nostartfiles -nostdlib +CROSS_RAM_LDFLAGS = -Tlpc2220_ram.ld -nostartfiles -nostdlib CROSS_ROM_LDFLAGS = -Tlpc2220_rom.ld -nostartfiles -nostdlib # build objects diff --git a/betty/betty.c b/betty/betty.c index 8d7ce84..093232b 100644 --- a/betty/betty.c +++ b/betty/betty.c @@ -14,13 +14,33 @@ #define cc1100_init spi1_init(8,SPI_MASTER,8) +void display_string_page(u8 x,u8 p,u8 *s,u8 f,u8 o,u8 sp) { + + while(*(s)) { + if(x==DISPLAY_DIMX) { + p+=1; + x=o; + } + display_font_page(x,p,(u8 *)default_font+(*(s)<<3),f); + x+=sp; + s++; + } +} + +/* + * global variables + */ + +const char announce[]="betty - live from flash at 0x80000000! ;)\r\n"; +const char d1_txt[]="betty"; +const char d2_txt[]="- alphablend -"; + /* * main function */ int main() { - char announce[]="betty - live from flash at 0x80000000! ;)\r\n"; t_button button; u8 contrast; @@ -54,7 +74,7 @@ int main() { /* pasue again */ /* announce */ - uart0_send_string(announce); + uart0_send_string((char *)announce); while(1) { @@ -90,47 +110,31 @@ int main() { display_fill_screen(DISPLAY_FILL_B); break; case BUTTON_1: - display_draw_rectangle(20,20,40,40, - DISPLAY_FILL_B, - 0xff); + display_rectangle_page(4,2,60,5,DISPLAY_FILL_B,0xff); break; case BUTTON_2: - display_draw_rectangle(50,50,40,40, - DISPLAY_FILL_LG, - 0x7f); + display_rectangle_page(40,5,50,5,DISPLAY_FILL_LG,0x7f); break; case BUTTON_3: - display_draw_font(70,70, - (u8 *)default_font+(0x33<<3), - DISPLAY_FILL_LG, - 0xff); break; case BUTTON_4: - display_font_page(23,19,(u8 *)default_font+(0x34<<3),DISPLAY_FILL_B); + display_font_page(42,18,(u8 *)default_font+(0x34<<3),DISPLAY_FILL_B); break; case BUTTON_5: - display_font_page(10,19,(u8 *)default_font+(0x35<<3),DISPLAY_FILL_DG); + display_font_page(50,18,(u8 *)default_font+(0x35<<3),DISPLAY_FILL_DG); break; case BUTTON_6: - display_font_page(2,19,(u8 *)default_font+(0x36<<3),DISPLAY_FILL_LG); + display_font_page(58,18,(u8 *)default_font+(0x36<<3),DISPLAY_FILL_W); break; case BUTTON_7: - display_draw_rectangle(2,2,4,4, - DISPLAY_FILL_B, - 0xff); break; case BUTTON_8: - display_draw_rectangle(8,8,4,4, - DISPLAY_FILL_DG, - 0xff); break; case BUTTON_BETTY: - display_rectangle_page(80,15,16,2,DISPLAY_FILL_B,0x7f); - uart0_send_byte('b'); + display_string_page(50,13,(u8 *)d1_txt,DISPLAY_FILL_B,0,8); break; case BUTTON_EXIT: - display_rectangle_page(90,16,16,2,DISPLAY_FILL_LG,0x7f); - uart0_send_byte('e'); + display_string_page(10,8,(u8 *)d2_txt,DISPLAY_FILL_B,0,8); break; default: display_clear_screen(); diff --git a/betty/display.c b/betty/display.c index bb74241..46e8480 100644 --- a/betty/display.c +++ b/betty/display.c @@ -166,7 +166,7 @@ void display_rectangle_page(u8 x,u8 p,u8 w,u8 h,u8 fill,u8 alpha) { row=DISPLAY_DATA; // aligne dummy read for(row=0;row<8;row++) { b=display_m2i(buf,row); - c=(b*(255-alpha)+fill*255)>>8; + c=(b*(255-alpha)+fill*alpha)>>8; buf[0]&=~(1< Date: Mon, 17 Sep 2007 16:05:58 +0200 Subject: [PATCH 11/16] only copy the data section if code resides in flash --- betty/startup.s | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/betty/startup.s b/betty/startup.s index d6b0184..dc43ab6 100644 --- a/betty/startup.s +++ b/betty/startup.s @@ -102,12 +102,15 @@ handle_reset: ldr r0, =stack_limit mov sl, r0 - # copy data section + # copy data section (only if we are in flash <=> _etext = _data) ldr r1, =_etext ldr r2, =_data ldr r3, =_edata + cmp r1, r2 + beq start_of_c_code + copy_data_loop: cmp r2, r3 @@ -117,6 +120,8 @@ copy_data_loop: # jump to c code +start_of_c_code: + adr lr, loop_forever mov r0, #0 mov r1, #0 -- 2.20.1 From fc297929bc25cb94ebe79ccd34f26e4ca97b0753 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 17 Sep 2007 16:35:45 +0200 Subject: [PATCH 12/16] comment corrected ... --- betty/startup.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/betty/startup.s b/betty/startup.s index dc43ab6..fb42ac7 100644 --- a/betty/startup.s +++ b/betty/startup.s @@ -102,7 +102,7 @@ handle_reset: ldr r0, =stack_limit mov sl, r0 - # copy data section (only if we are in flash <=> _etext = _data) + # copy data section (only if we are in flash <=> _etext != _data) ldr r1, =_etext ldr r2, =_data -- 2.20.1 From e5528a813600916042130b81214cd72dcf289ed5 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 17 Sep 2007 18:29:59 +0200 Subject: [PATCH 13/16] dec n counter --- betty/functions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/betty/functions.c b/betty/functions.c index 732e76f..79612b3 100644 --- a/betty/functions.c +++ b/betty/functions.c @@ -62,7 +62,7 @@ int mset(u8 *d,u8 v,int n) { int mcpy(u8 *d,u8 *s,int n) { - while(n) + while(n--) *d++=*s++; return n; -- 2.20.1 From 6292cc9190f6e7f36a3634057740e770d58d7460 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 17 Sep 2007 22:54:53 +0200 Subject: [PATCH 14/16] supplied memcpy and memset now (gcc built-in functions) --- betty/functions.c | 4 ++-- betty/functions.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/betty/functions.c b/betty/functions.c index 79612b3..9e12c86 100644 --- a/betty/functions.c +++ b/betty/functions.c @@ -52,7 +52,7 @@ int strncpy(char *d,char *s,int n) { return 0; } -int mset(u8 *d,u8 v,int n) { +int memset(u8 *d,int v,int n) { while(n) d[--n]=v; @@ -60,7 +60,7 @@ int mset(u8 *d,u8 v,int n) { return 0; } -int mcpy(u8 *d,u8 *s,int n) { +int memcpy(u8 *d,u8 *s,int n) { while(n--) *d++=*s++; diff --git a/betty/functions.h b/betty/functions.h index aa9c11a..f8e8e1d 100644 --- a/betty/functions.h +++ b/betty/functions.h @@ -18,8 +18,8 @@ int strlen(char *string); int strncmp(char *a,char *b,int n); int strncpy(char *d,char *s,int n); -int mset(u8 *s,u8 v,int n); -int mcpy(u8 *d,u8 *s,int n); +int memset(u8 *s,int v,int n); +int memcpy(u8 *d,u8 *s,int n); int counttok(u8 *s,u8 delim); #endif -- 2.20.1 From 916c8dd1dfa2414ae8b58ab1e3d477b24c553815 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 18 Sep 2007 02:09:02 +0200 Subject: [PATCH 15/16] prepare for interrupt support in the next few days --- betty/betty.c | 7 +++++++ betty/interrupts.c | 11 +++++++---- betty/interrupts.h | 28 +++++++++++++++++++++++++++- betty/startup.s | 10 ++++++++-- betty/system.c | 7 +++++-- betty/system.h | 7 +++++++ 6 files changed, 61 insertions(+), 9 deletions(-) diff --git a/betty/betty.c b/betty/betty.c index 093232b..d10456e 100644 --- a/betty/betty.c +++ b/betty/betty.c @@ -41,6 +41,7 @@ const char d2_txt[]="- alphablend -"; int main() { + /* variables */ t_button button; u8 contrast; @@ -48,6 +49,12 @@ int main() { pll_init(); pin_init(); ext_mem_init(); + + /* memory mapping - dirty! */ + if((void *)announce<(void *)FLASH_BANK0) + mmap_init(MEMTYPE_RAM); + else + mmap_init(MEMTYPE_EXT); /* uart init */ uart0_init(); diff --git a/betty/interrupts.c b/betty/interrupts.c index fa1fcc1..61cf1af 100644 --- a/betty/interrupts.c +++ b/betty/interrupts.c @@ -11,6 +11,13 @@ * functions */ +void interrupt_set_default_callback(t_interrupt *ir,void *callback) { + + ir->default_callback=callback; +} + + + /* * the actual exception handlers (as defined in startup.s) */ @@ -35,10 +42,6 @@ void interrupt_handler_prefetch_abort(void) { void interrupt_handler_data_abort(void) { } -// irq -void interrupt_handler_irq(void) { -} - // fiq void interrupt_handler_fiq(void) { } diff --git a/betty/interrupts.h b/betty/interrupts.h index 9c1b8aa..20bb333 100644 --- a/betty/interrupts.h +++ b/betty/interrupts.h @@ -5,16 +5,42 @@ * */ +#ifndef INTERRUPTS_H +#define INTERRUPTS_H + #include "lpc2xxx.h" #include "types.h" +/* defines */ + +#define INTERRUPT_MAX_VIC 16 + +#define INTERRUPT_EXT_MODE_EDGE 0 +#define INTERRUPT_EXT_MODE_LEVEL 1 +#define INTERRUPT_EXT_POLAR_LOW 0 +#define INTERRUPT_EXT_POLAR_HIGH 1 + +/* type definitions */ + +typedef struct s_interrupt { + void *default_callback; + u8 default_mode; + void *callback[INTERRUPT_MAX_VIC]; + u8 mode[INTERRUPT_MAX_VIC]; +} t_interrupt; + /* function prototypes */ +void interrupt_set_default_callback(t_interrupt *ir,void *callback); + +void interrupt_ext_ir_conf(u8 pin,u8 mode,u8 polar, + void (*ext_ir_callback)(t_interrupt *ir)); + void interrupt_handler_reset(void); void interrupt_handler_undef_instruction(void); void interrupt_handler_soft_ir(void); void interrupt_handler_prefetch_abort(void); void interrupt_handler_data_abort(void); -void interrupt_handler_irq(void); void interrupt_handler_fiq(void); +#endif diff --git a/betty/startup.s b/betty/startup.s index fb42ac7..d393d32 100644 --- a/betty/startup.s +++ b/betty/startup.s @@ -49,6 +49,13 @@ .arm # exception handling must go to the very beginning + # + # concerning irq: + # - the ldr is at 0x18 + # - pc will be 0x18 + 8 at the moment of ldr (pipeline) + # - substract 0xff0 => 0xfffff030 + # - that's the vectored address register + # - the vic put in there the address of our service routine ldr pc, handler_reset ldr pc, handler_undef_instruction @@ -56,7 +63,7 @@ ldr pc, handler_prefetch_abort ldr pc, handler_data_abort nop - ldr pc, handler_irq + ldr pc, [pc, #-0xff0] ldr pc, handler_fiq handler_reset: .word handle_reset @@ -64,7 +71,6 @@ handler_undef_instruction: .word interrupt_handler_undef_instruction handler_soft_ir: .word interrupt_handler_soft_ir handler_prefetch_abort: .word interrupt_handler_prefetch_abort handler_data_abort: .word interrupt_handler_data_abort -handler_irq: .word interrupt_handler_irq handler_fiq: .word interrupt_handler_fiq # reset handling goes here diff --git a/betty/system.c b/betty/system.c index 4204cdd..ef18b57 100644 --- a/betty/system.c +++ b/betty/system.c @@ -72,11 +72,11 @@ void pin_init(void) { /* * pinsel 1 * - * no special function yet! + * p0.30: eint3 * */ - PINSEL1=0x00000000; + PINSEL1=0x20000000; /* * pin select 2 @@ -116,6 +116,9 @@ void pin_init(void) { void mmap_init(u8 memtype) { + if(memtype==MEMTYPE_RESERVED) + return; + MEMMAP=memtype; } diff --git a/betty/system.h b/betty/system.h index 9031725..5fe98d9 100644 --- a/betty/system.h +++ b/betty/system.h @@ -11,6 +11,13 @@ #include "lpc2xxx.h" #include "types.h" +/* defines */ + +#define MEMTYPE_BOOT 0x00 +#define MEMTYPE_RESERVED 0x01 +#define MEMTYPE_RAM 0x02 +#define MEMTYPE_EXT 0x03 + /* function prototypes */ void pll_init(void); void ext_mem_init(void); -- 2.20.1 From d01b3bb1e7565638e2275e6081dcb106c1fcdb41 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 18 Sep 2007 17:47:58 +0200 Subject: [PATCH 16/16] some interrupt stuff, now basketball ... --- betty/interrupts.c | 29 +++++++++++++++++++++++++++-- betty/interrupts.h | 26 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/betty/interrupts.c b/betty/interrupts.c index 61cf1af..41945cf 100644 --- a/betty/interrupts.c +++ b/betty/interrupts.c @@ -11,12 +11,37 @@ * functions */ -void interrupt_set_default_callback(t_interrupt *ir,void *callback) { +void interrupt_set_default_callback(void *callback) { - ir->default_callback=callback; + VICDefVectAddr=(u32)callback; + } +void interrupt_clear(u8 src_number) { +} + +int interrupt_set(u8 src_number,u8 mode,u8 priority,void *callback) { + + /* check whether this ir source is allready assigned */ + if(VICSoftInt&(1<