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

@ -42,7 +42,7 @@ include $(TOPDIR)/config.mk
#########################################################################
# blink objects....order is important (i.e. start must be first)
AOBJS =
AOBJS =
COBJS = $(patsubst %.c,%.o,$(wildcard src/*.c))
TESTS = $(wildcard tests/*.c)
TARGETS = $(patsubst %.c,%.o,$(TESTS))
@ -58,12 +58,23 @@ ALL = $(TESTS:.c=.srec) $(TESTS:.c=.bin) $(TESTS:.c=.dis)
.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/rftest-rx.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
$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@
@ -77,7 +88,7 @@ tests/tmr-ints.c: src/interrupt-utils.o src/sys-interrupt.o
%.dis: %.obj
$(OBJDUMP) -SD $< > $@
%.obj: $(LDSCRIPT) %.o
%.obj: $(LDSCRIPT) %.o src/interrupt-utils.o
$(LD) $(LDFLAGS) $(AOBJS) \
--start-group $(PLATFORM_LIBS) --end-group \
-Map $*.map $^ -o $@

View File

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

View File

@ -1,8 +1,7 @@
#ifndef __SYS_INTERRUPT_H__QIHZ66NP8K__
#define __SYS_INTERRUPT_H__QIHZ66NP8K__
#ifndef __SYS_INTERRUPT_H
#define __SYS_INTERRUPT_H
/* Returns true if it handled an activbe interrupt */
/* Returns true if it handled an active interrupt */
typedef int (*SystemInterruptFunc)();
typedef struct _SystemInterruptHandler SystemInterruptHandler;
@ -12,7 +11,6 @@ struct _SystemInterruptHandler
SystemInterruptFunc handler;
};
void
sys_interrupt_enable();
@ -28,4 +26,4 @@ sys_interrupt_prepend_handler(SystemInterruptHandler *handler);
void
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
irq:
b isr
.align 5
fiq:

View File

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

View File

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

View File

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

View File

@ -5,6 +5,9 @@
#define DELAY 400000
#include "embedded_types.h"
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup")))
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',
'8','9','a','b','c','d','e','f'};
#include "isr.h"
no_isrs();
#define NBYTES 1024
__attribute__ ((section ("startup")))
void main(void) {

View File

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

View File

@ -112,6 +112,9 @@ void fill_data(void) {
}
}
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup")))
void main(void) {
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 16
#include "isr.h"
no_isrs();
__attribute__ ((section ("startup")))
void main(void) {
volatile uint32_t i;

View File

@ -47,12 +47,40 @@
#define reg16(x) (*(volatile uint16_t *)(x))
#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")))
void main(void) {
/* pin direction */
reg32(GPIO_PAD_DIR0) = 0x00000400;
led_init();
/* timer setup */
/* CTRL */
@ -66,7 +94,8 @@ void main(void) {
#define OUT_MODE 0 /* OFLAG is asserted while counter is active */
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_COMP_UP) = 18750; /* trigger a reload at the end */
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(TMR_ENBL) = 0xf; /* enable all the timers --- why not? */
led_on();
enable_tmr_irq();
enableIRQ();
while(1) {
/* 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" */
/* sit here and let the interrupts do the work */
};
}

View File

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

View File

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