X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=drv%2Fat91%2Fsysirq.c;h=d3991fddbec7c6bb2ba1911a7f171e6452010153;hb=7f390830190a03757e07e4ee8654021cc0adeee6;hp=fc9f687fc188ddd002de35d75d4f39bf1913bf21;hpb=1cd1b0fea245b38739d66bdcc4b0394422654595;p=bertos.git diff --git a/drv/at91/sysirq.c b/drv/at91/sysirq.c old mode 100755 new mode 100644 index fc9f687f..d3991fdd --- a/drv/at91/sysirq.c +++ b/drv/at91/sysirq.c @@ -1,8 +1,33 @@ /** * \file * * * \version $Id$ @@ -18,7 +43,7 @@ * independently. * However, there are a few sources called "system sources" that * share a common IRQ line and vector, called "system IRQ". - * So a unique system IRQ handler is implemented here. + * So a unique system IRQ dispatcher is implemented here. * This module also contains an interface to manage every source * independently. It is possible to assign to every system IRQ * a specific IRQ handler. @@ -28,16 +53,16 @@ */ #include "sysirq.h" -#include "at91.h" +#include "at91sam7s.h" #include - -#warning Very untested! +#include +#include /** * Enable/disable the Periodic Interrupt Timer * interrupt. */ -INLINE static void pit_setEnable(bool enable) +INLINE void pit_setEnable(bool enable) { if (enable) PIT_MR |= BV(PITIEN); @@ -72,7 +97,7 @@ STATIC_ASSERT(countof(sysirq_tab) == SYSIRQ_CNT); static void sysirq_dispatcher(void) { #warning TODO add IRQ prologue/epilogue - for (int i = 0; i < countof(sysirq_tab); i++) + for (unsigned i = 0; i < countof(sysirq_tab); i++) { if (sysirq_tab[i].enabled && sysirq_tab[i].handler) @@ -95,15 +120,17 @@ void sysirq_init(void) IRQ_SAVE_DISABLE(flags); /* Disable all system interrupts */ - for (int i = 0; i < countof(sysirq_tab); i++) + for (unsigned i = 0; i < countof(sysirq_tab); i++) sysirq_tab[i].setEnable(false); /* Set the vector. */ - AIC_SVR(SYSC_ID) = sysirq_handler; + AIC_SVR(SYSC_ID) = sysirq_dispatcher; /* Initialize to edge triggered with defined priority. */ - AIC_SMR(SYSC_ID) = BV(AIC_SRCTYPE_INT_EDGE_TRIGGERED) | SYSIRQ_PRIORITY; - /* Clear interrupt */ + AIC_SMR(SYSC_ID) = AIC_SRCTYPE_INT_EDGE_TRIGGERED | SYSIRQ_PRIORITY; + /* Clear pending interrupt */ AIC_ICCR = BV(SYSC_ID); + /* Enable the system IRQ */ + AIC_IECR = BV(SYSC_ID); IRQ_RESTORE(flags); MOD_INIT(sysirq); @@ -129,7 +156,7 @@ void sysirq_setEnable(sysirq_t irq, bool enable) ASSERT(irq < SYSIRQ_CNT); sysirq_tab[irq].setEnable(enable); - sysirq_enabled = enable; + sysirq_tab[irq].enabled = enable; } /** @@ -139,5 +166,6 @@ bool sysirq_enabled(sysirq_t irq) { ASSERT(irq >= 0); ASSERT(irq < SYSIRQ_CNT); + return sysirq_tab[irq].enabled; }