int main() {
+ /* variables */
t_button button;
u8 contrast;
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();
* functions
*/
+void interrupt_set_default_callback(t_interrupt *ir,void *callback) {
+
+ ir->default_callback=callback;
+}
+
+
+
/*
* the actual exception handlers (as defined in startup.s)
*/
void interrupt_handler_data_abort(void) {
}
-// irq
-void interrupt_handler_irq(void) {
-}
-
// fiq
void interrupt_handler_fiq(void) {
}
*
*/
+#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
.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_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
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
/*
* pinsel 1
*
- * no special function yet!
+ * p0.30: eint3
*
*/
- PINSEL1=0x00000000;
+ PINSEL1=0x20000000;
/*
* pin select 2
void mmap_init(u8 memtype) {
+ if(memtype==MEMTYPE_RESERVED)
+ return;
+
MEMMAP=memtype;
}
#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);