]> hackdaworld.org Git - my-code/arm.git/commitdiff
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 093232bcaeb1048cbaf3ab63b9ec61c2dc1f50d7..d10456e30b8a8290c310b4312b305d4d3dc13bdd 100644 (file)
@@ -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();
index fa1fcc1f82dccc54816d7d26ea12aad43692c795..61cf1afd93ebe88f03976f646736058486031eb7 100644 (file)
  * 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) {
 }
index 9c1b8aa7be45dae348f0e8542cfd9aad4e5653ed..20bb3332740c353d29c2a3c97cf2a56563e495f8 100644 (file)
@@ -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
index fb42ac7deecf00f97af2e2bf7053221bb53675b6..d393d32a35e0763ebc95a8b32f0401811829fcc7 100644 (file)
 .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
index 4204cddeca087f57a6359b5349c8d5a1ee5b5457..ef18b57926472842fb8ec180ccd64d305925798e 100644 (file)
@@ -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;
 }
 
index 9031725faee6dab8be96e7aaba4f98ccfc7fddd9..5fe98d98094b1cc6c2376807f72aa795bfe989ce 100644 (file)
 #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);