preliminary interrupts. looks like it is entering the isr but isn't

leaving correctly.
This commit is contained in:
Mariano Alvira 2009-04-20 18:31:13 -04:00
parent 28c1ed2105
commit 09b15558a1
15 changed files with 89 additions and 26 deletions

View file

@ -58,12 +58,23 @@ ALL = $(TESTS:.c=.srec) $(TESTS:.c=.bin) $(TESTS:.c=.dis)
.PRECIOUS: $(COBJS) $(TARGETS) $(TESTS:.c=.obj) .PRECIOUS: $(COBJS) $(TARGETS) $(TESTS:.c=.obj)
all: src/start.o $(ALL) all: src/start.o src/isr.o $(ALL)
tests/nvm-read.obj: src/maca.o src/nvm.o tests/nvm-read.obj: src/maca.o src/nvm.o
tests/rftest-rx.obj: src/maca.o src/nvm.o tests/rftest-rx.obj: src/maca.o src/nvm.o
tests/rftest-tx.obj: src/maca.o src/nvm.o tests/rftest-tx.obj: src/maca.o src/nvm.o
tests/tmr-ints.c: src/interrupt-utils.o src/sys-interrupt.o tests/tmr-ints.obj: src/interrupt-utils.o src/sys-interrupt.o src/isr.o
NOTHUMB_CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \
-D__KERNEL__ -DTEXT_BASE=$(TEXT_BASE) \
-I$(TOPDIR)/include \
-fno-builtin -ffreestanding -nostdinc -isystem \
$(gccincdir) -pipe
NOTHUMB_CPPFLAGS_EXTRA = -march=armv4t -mlong-calls -mthumb-interwork -mtune=arm7tdmi-s -DCONFIG_ARM -D__ARM__
src/isr.o: src/isr.c
$(CC) $(NOTHUMB_CPPFLAGS) $(NOTHUMB_CPPFLAGS_EXTRA) -c -o $@ $<
%.srec: %.obj %.srec: %.obj
$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
@ -77,7 +88,7 @@ tests/tmr-ints.c: src/interrupt-utils.o src/sys-interrupt.o
%.dis: %.obj %.dis: %.obj
$(OBJDUMP) -SD $< > $@ $(OBJDUMP) -SD $< > $@
%.obj: $(LDSCRIPT) %.o %.obj: $(LDSCRIPT) %.o src/interrupt-utils.o
$(LD) $(LDFLAGS) $(AOBJS) \ $(LD) $(LDFLAGS) $(AOBJS) \
--start-group $(PLATFORM_LIBS) --end-group \ --start-group $(PLATFORM_LIBS) --end-group \
-Map $*.map $^ -o $@ -Map $*.map $^ -o $@

View file

@ -33,6 +33,7 @@ SECTIONS
.text : .text :
{ {
src/start.o (.text) src/start.o (.text)
src/isr.o (.text)
*(.text) *(.text)
} }

View file

@ -1,8 +1,7 @@
#ifndef __SYS_INTERRUPT_H__QIHZ66NP8K__ #ifndef __SYS_INTERRUPT_H
#define __SYS_INTERRUPT_H__QIHZ66NP8K__ #define __SYS_INTERRUPT_H
/* Returns true if it handled an active interrupt */
/* Returns true if it handled an activbe interrupt */
typedef int (*SystemInterruptFunc)(); typedef int (*SystemInterruptFunc)();
typedef struct _SystemInterruptHandler SystemInterruptHandler; typedef struct _SystemInterruptHandler SystemInterruptHandler;
@ -12,7 +11,6 @@ struct _SystemInterruptHandler
SystemInterruptFunc handler; SystemInterruptFunc handler;
}; };
void void
sys_interrupt_enable(); sys_interrupt_enable();
@ -28,4 +26,4 @@ sys_interrupt_prepend_handler(SystemInterruptHandler *handler);
void void
sys_interrupt_remove_handler(SystemInterruptHandler *handler); sys_interrupt_remove_handler(SystemInterruptHandler *handler);
#endif /* __SYS_INTERRUPT_H__QIHZ66NP8K__ */ #endif /* __SYS_INTERRUPT_H */

View file

@ -197,7 +197,7 @@ not_used:
.align 5 .align 5
irq: irq:
b isr
.align 5 .align 5
fiq: fiq:

View file

@ -5,6 +5,9 @@
#define DELAY 400000 #define DELAY 400000
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {

View file

@ -5,6 +5,9 @@
#define DELAY 400000 #define DELAY 400000
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {

View file

@ -5,6 +5,9 @@
#define DELAY 400000 #define DELAY 400000
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup"))) void main(void) { __attribute__ ((section ("startup"))) void main(void) {
*(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000100; *(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000100;

View file

@ -5,6 +5,9 @@
#define DELAY 400000 #define DELAY 400000
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {

View file

@ -29,6 +29,10 @@ void put_hex32(uint32_t x);
const uint8_t hex[16]={'0','1','2','3','4','5','6','7', const uint8_t hex[16]={'0','1','2','3','4','5','6','7',
'8','9','a','b','c','d','e','f'}; '8','9','a','b','c','d','e','f'};
#include "isr.h"
no_isrs();
#define NBYTES 1024 #define NBYTES 1024
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {

View file

@ -77,6 +77,9 @@ void toggle_led(void) {
} }
} }
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
uint8_t c; uint8_t c;

View file

@ -112,6 +112,9 @@ void fill_data(void) {
} }
} }
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
uint8_t c; uint8_t c;

View file

@ -28,6 +28,9 @@ const uint8_t hex[16]={'0','1','2','3','4','5','6','7',
#define DUMP_LEN 0x00014000 #define DUMP_LEN 0x00014000
//#define DUMP_LEN 16 //#define DUMP_LEN 16
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
volatile uint32_t i; volatile uint32_t i;

View file

@ -47,12 +47,40 @@
#define reg16(x) (*(volatile uint16_t *)(x)) #define reg16(x) (*(volatile uint16_t *)(x))
#include "embedded_types.h" #include "embedded_types.h"
#include "sys-interrupt.h"
#include "isr.h"
volatile uint8_t led;
#define LED_VAL 0x00000300
#define led_init() do { reg32(GPIO_PAD_DIR0) = LED_VAL; } while(0);
#define led_on() do { led = 1; reg32(GPIO_DATA0) = LED_VAL; } while(0);
#define led_off() do { led = 0; reg32(GPIO_DATA0) = 0x00000000; } while(0);
void toggle_led(void) {
if(0 == led) {
led_on();
led = 1;
} else {
led_off();
}
}
void tmr_isr(void) {
toggle_led();
reg16(TMR0_SCTRL) = 0;
reg16(TMR0_CSCTRL) = 0x0040; /* clear compare flag */
}
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
/* pin direction */ /* pin direction */
reg32(GPIO_PAD_DIR0) = 0x00000400; led_init();
/* timer setup */ /* timer setup */
/* CTRL */ /* CTRL */
@ -67,6 +95,7 @@ void main(void) {
reg16(TMR_ENBL) = 0; /* tmrs reset to enabled */ reg16(TMR_ENBL) = 0; /* tmrs reset to enabled */
reg16(TMR0_SCTRL) = 0; reg16(TMR0_SCTRL) = 0;
reg16(TMR0_CSCTRL) =0x0040;
reg16(TMR0_LOAD) = 0; /* reload to zero */ reg16(TMR0_LOAD) = 0; /* reload to zero */
reg16(TMR0_COMP_UP) = 18750; /* trigger a reload at the end */ reg16(TMR0_COMP_UP) = 18750; /* trigger a reload at the end */
reg16(TMR0_CMPLD1) = 18750; /* compare 1 triggered reload level, 10HZ maybe? */ reg16(TMR0_CMPLD1) = 18750; /* compare 1 triggered reload level, 10HZ maybe? */
@ -74,19 +103,12 @@ void main(void) {
reg16(TMR0_CTRL) = (COUNT_MODE<<13) | (PRIME_SRC<<9) | (SEC_SRC<<7) | (ONCE<<6) | (LEN<<5) | (DIR<<4) | (CO_INIT<<3) | (OUT_MODE); reg16(TMR0_CTRL) = (COUNT_MODE<<13) | (PRIME_SRC<<9) | (SEC_SRC<<7) | (ONCE<<6) | (LEN<<5) | (DIR<<4) | (CO_INIT<<3) | (OUT_MODE);
reg16(TMR_ENBL) = 0xf; /* enable all the timers --- why not? */ reg16(TMR_ENBL) = 0xf; /* enable all the timers --- why not? */
led_on();
enable_tmr_irq();
enableIRQ();
while(1) { while(1) {
/* sit here and let the interrupts do the work */
/* blink on */
reg32(GPIO_DATA0) = 0x00000400;
while((reg16(TMR0_SCTRL)>>15) == 0) { continue; }
reg16(TMR0_SCTRL) = 0; /*clear bit 15, and all the others --- should be ok, but clearly not "the right thing to do" */
/* blink off */
reg32(GPIO_DATA0) = 0x00000000;
while((reg16(TMR0_SCTRL)>>15) == 0) { continue; }
reg16(TMR0_SCTRL) = 0; /*clear bit 15, and all the others --- should be ok, but clearly not "the right thing to do" */
}; };
} }

View file

@ -48,6 +48,9 @@
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {

View file

@ -11,6 +11,9 @@
#include "embedded_types.h" #include "embedded_types.h"
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup"))) __attribute__ ((section ("startup")))
void main(void) { void main(void) {
/* Restore UART regs. to default */ /* Restore UART regs. to default */