From: hackbard Date: Tue, 18 Sep 2007 00:09:02 +0000 (+0200) Subject: prepare for interrupt support in the next few days X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=916c8dd1dfa2414ae8b58ab1e3d477b24c553815;p=my-code%2Farm.git prepare for interrupt support in the next few days --- 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);