prepare for interrupt support in the next few days
authorhackbard <hackbard@staubsauger.localdomain>
Tue, 18 Sep 2007 00:09:02 +0000 (02:09 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Tue, 18 Sep 2007 00:09:02 +0000 (02:09 +0200)
betty/betty.c
betty/interrupts.c
betty/interrupts.h
betty/startup.s
betty/system.c
betty/system.h

index 093232b..d10456e 100644 (file)
@@ -41,6 +41,7 @@ const char d2_txt[]="- alphablend -";
 
 int main() {
 
 
 int main() {
 
+       /* variables */
        t_button button;
        u8 contrast;
 
        t_button button;
        u8 contrast;
 
@@ -48,6 +49,12 @@ int main() {
        pll_init();
        pin_init();
        ext_mem_init();
        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();
        
        /* uart init */
        uart0_init();
index fa1fcc1..61cf1af 100644 (file)
  * functions
  */
 
  * functions
  */
 
+void interrupt_set_default_callback(t_interrupt *ir,void *callback) {
+
+       ir->default_callback=callback;
+}
+
+
+
 /*
  * the actual exception handlers (as defined in startup.s)
  */
 /*
  * 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) {
 }
 
 void interrupt_handler_data_abort(void) {
 }
 
-// irq
-void interrupt_handler_irq(void) {
-}
-
 // fiq
 void interrupt_handler_fiq(void) {
 }
 // fiq
 void interrupt_handler_fiq(void) {
 }
index 9c1b8aa..20bb333 100644 (file)
@@ -5,16 +5,42 @@
  *
  */
 
  *
  */
 
+#ifndef INTERRUPTS_H
+#define INTERRUPTS_H
+
 #include "lpc2xxx.h"
 #include "types.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 */
 
 /* 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_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);
 
 void interrupt_handler_fiq(void);
 
+#endif
index fb42ac7..d393d32 100644 (file)
 .arm
 
        # exception handling must go to the very beginning
 .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
 
        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_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
        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_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_fiq: .word interrupt_handler_fiq
 
        # reset handling goes here
index 4204cdd..ef18b57 100644 (file)
@@ -72,11 +72,11 @@ void pin_init(void) {
        /*
         * pinsel 1
         *
        /*
         * pinsel 1
         *
-        * no special function yet!
+        * p0.30: eint3
         *
         */
 
         *
         */
 
-       PINSEL1=0x00000000;
+       PINSEL1=0x20000000;
 
        /*
         * pin select 2
 
        /*
         * pin select 2
@@ -116,6 +116,9 @@ void pin_init(void) {
 
 void mmap_init(u8 memtype) {
 
 
 void mmap_init(u8 memtype) {
 
+       if(memtype==MEMTYPE_RESERVED)
+               return;
+
        MEMMAP=memtype;
 }
 
        MEMMAP=memtype;
 }
 
index 9031725..5fe98d9 100644 (file)
 #include "lpc2xxx.h"
 #include "types.h"
 
 #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);
 /* function prototypes */
 void pll_init(void);
 void ext_mem_init(void);