From d869766664cc75386c4bcc4e5ff4e28a684bbfe3 Mon Sep 17 00:00:00 2001 From: Mariano Alvira Date: Fri, 24 Apr 2009 16:04:04 -0400 Subject: [PATCH] using weak links for individual isrs --- include/isr.h | 6 +----- src/isr.c | 4 +++- tests/blink-blue.c | 2 -- tests/blink-green.c | 2 -- tests/blink-red.c | 2 -- tests/blink-white.c | 2 -- tests/nvm-read.c | 2 -- tests/rftest-rx.c | 4 +--- tests/rftest-tx.c | 4 +--- tests/romimg.c | 1 - tests/tmr.c | 2 -- tests/uart1-loopback.c | 2 -- 12 files changed, 6 insertions(+), 27 deletions(-) diff --git a/include/isr.h b/include/isr.h index 0583ffc7e..22e1772be 100644 --- a/include/isr.h +++ b/include/isr.h @@ -10,13 +10,9 @@ #define INTENNUM INTBASE + INTENNUM_OFF #define INTSRC INTBASE + INTSRC_OFF - -#define no_isrs() no_tmr_isr(); - #define enable_tmr_irq() *(volatile uint32_t *)(INTENNUM) = 5; -#define no_tmr_isr() void tmr_isr(void) { return; } -extern void tmr_isr(void); +extern void tmr_isr(void) __attribute__((weak)); #endif diff --git a/src/isr.c b/src/isr.c index 00d7c3207..323fd971f 100644 --- a/src/isr.c +++ b/src/isr.c @@ -10,7 +10,9 @@ void irq(void) { // ISR_ENTRY(); /* check for TMR0 interrupt */ - tmr_isr(); // led turns off if I have this, indicating that the isr does jump to tmr_isr + if(tmr_isr != NULL) { + tmr_isr(); // led turns off if I have this, indicating that the isr does jump to tmr_isr + } // if(reg32(INTSRC) & (1<<5)) { tmr_isr(); } // asm("SUBS PC,R14_IRQ,#4") // enableIRQ(); // I think this is necessary, but the LED never turns off when I have this diff --git a/tests/blink-blue.c b/tests/blink-blue.c index a0d59dee7..c732d9193 100644 --- a/tests/blink-blue.c +++ b/tests/blink-blue.c @@ -7,8 +7,6 @@ #include "embedded_types.h" #include "isr.h" -no_isrs(); - __attribute__ ((section ("startup"))) void main(void) { diff --git a/tests/blink-green.c b/tests/blink-green.c index c7bed04eb..3531ea4f5 100644 --- a/tests/blink-green.c +++ b/tests/blink-green.c @@ -7,8 +7,6 @@ #include "embedded_types.h" #include "isr.h" -no_isrs(); - __attribute__ ((section ("startup"))) void main(void) { diff --git a/tests/blink-red.c b/tests/blink-red.c index f1da55417..bdb9d44bf 100644 --- a/tests/blink-red.c +++ b/tests/blink-red.c @@ -7,8 +7,6 @@ #include "embedded_types.h" #include "isr.h" -no_isrs(); - __attribute__ ((section ("startup"))) void main(void) { *(volatile uint32_t *)GPIO_PAD_DIR0 = 0x00000100; diff --git a/tests/blink-white.c b/tests/blink-white.c index 18ba37308..87d456d12 100644 --- a/tests/blink-white.c +++ b/tests/blink-white.c @@ -7,8 +7,6 @@ #include "embedded_types.h" #include "isr.h" -no_isrs(); - __attribute__ ((section ("startup"))) void main(void) { diff --git a/tests/nvm-read.c b/tests/nvm-read.c index 12c2e44cc..54a912904 100644 --- a/tests/nvm-read.c +++ b/tests/nvm-read.c @@ -31,8 +31,6 @@ const uint8_t hex[16]={'0','1','2','3','4','5','6','7', #include "isr.h" -no_isrs(); - #define NBYTES 1024 __attribute__ ((section ("startup"))) void main(void) { diff --git a/tests/rftest-rx.c b/tests/rftest-rx.c index fb91e349e..e2c2a1491 100644 --- a/tests/rftest-rx.c +++ b/tests/rftest-rx.c @@ -14,6 +14,7 @@ #include "maca.h" #include "embedded_types.h" +#include "isr.h" #define reg(x) (*(volatile uint32_t *)(x)) @@ -77,9 +78,6 @@ void toggle_led(void) { } } -#include "isr.h" -no_isrs(); - __attribute__ ((section ("startup"))) void main(void) { uint8_t c; diff --git a/tests/rftest-tx.c b/tests/rftest-tx.c index b6f607934..485baaa5a 100644 --- a/tests/rftest-tx.c +++ b/tests/rftest-tx.c @@ -14,6 +14,7 @@ #include "maca.h" #include "embedded_types.h" +#include "isr.h" #define reg(x) (*(volatile uint32_t *)(x)) @@ -112,9 +113,6 @@ void fill_data(void) { } } -#include "isr.h" -no_isrs(); - __attribute__ ((section ("startup"))) void main(void) { uint8_t c; diff --git a/tests/romimg.c b/tests/romimg.c index 5b2d346eb..e29330e13 100644 --- a/tests/romimg.c +++ b/tests/romimg.c @@ -29,7 +29,6 @@ const uint8_t hex[16]={'0','1','2','3','4','5','6','7', //#define DUMP_LEN 16 #include "isr.h" -no_isrs(); __attribute__ ((section ("startup"))) void main(void) { diff --git a/tests/tmr.c b/tests/tmr.c index f83107acb..8e28ede74 100644 --- a/tests/tmr.c +++ b/tests/tmr.c @@ -47,9 +47,7 @@ #define reg16(x) (*(volatile uint16_t *)(x)) #include "embedded_types.h" - #include "isr.h" -no_isrs(); __attribute__ ((section ("startup"))) void main(void) { diff --git a/tests/uart1-loopback.c b/tests/uart1-loopback.c index b3eec3940..21a3bbcb5 100644 --- a/tests/uart1-loopback.c +++ b/tests/uart1-loopback.c @@ -10,9 +10,7 @@ #define UART1_BR 0x80005018 #include "embedded_types.h" - #include "isr.h" -no_isrs(); __attribute__ ((section ("startup"))) void main(void) {