From: arighi Date: Fri, 26 Mar 2010 16:12:42 +0000 (+0000) Subject: lm3s1968: implement the IRQ manager. X-Git-Tag: 2.5.0~626 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=4cedc580e66cca972b055b9002ccadada6d5da75;p=bertos.git lm3s1968: implement the IRQ manager. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3277 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/cortex-m3/drv/irq.c b/bertos/cpu/cortex-m3/drv/irq.c new file mode 100644 index 00000000..0da77c85 --- /dev/null +++ b/bertos/cpu/cortex-m3/drv/irq.c @@ -0,0 +1,86 @@ +/** + * \file + * + * + * \brief Cortex-M3 IRQ management. + * + * \author Andrea Righi + */ + +#include +#include +#include "io/lm3s.h" +#include "irq.h" + +static void (*irq_table[NUM_INTERRUPTS])(void) + __attribute__((section("vtable"))); + +static void unhandled_isr(void) +{ + /* Unhandled IRQ */ + ASSERT(0); +} + +void sysirq_setHandler(sysirq_t irq, sysirq_handler_t handler) +{ + cpu_flags_t flags; + + ASSERT(irq < NUM_INTERRUPTS); + + IRQ_SAVE_DISABLE(flags); + irq_table[irq] = handler; + IRQ_RESTORE(flags); +} + +void sysirq_freeHandler(sysirq_t irq) +{ + cpu_flags_t flags; + + ASSERT(irq < NUM_INTERRUPTS); + + IRQ_SAVE_DISABLE(flags); + irq_table[irq] = unhandled_isr; + IRQ_RESTORE(flags); +} + +void sysirq_init(void) +{ + cpu_flags_t flags; + int i; + + IRQ_SAVE_DISABLE(flags); + for (i = 0; i < NUM_INTERRUPTS; i++) + irq_table[i] = unhandled_isr; + + /* Update NVIC to point to the new vector table */ + HWREG(NVIC_VTABLE) = (size_t)irq_table; + IRQ_RESTORE(flags); +} diff --git a/bertos/cpu/cortex-m3/drv/irq.h b/bertos/cpu/cortex-m3/drv/irq.h new file mode 100644 index 00000000..1770ed1f --- /dev/null +++ b/bertos/cpu/cortex-m3/drv/irq.h @@ -0,0 +1,49 @@ +/** + * \file + * + * + * \brief IRQ management for the Cortex M3 processor. + * + * \author Andrea Righi + */ + +#ifndef DRV_CORTEX_M3_SYSIRQ_H +#define DRV_CORTEX_M3_SYSIRQ_H + +typedef void (*sysirq_handler_t)(void); +typedef unsigned int sysirq_t; + +void sysirq_setHandler(sysirq_t irq, sysirq_handler_t handler); +void sysirq_freeHandler(sysirq_t irq); + +void sysirq_init(void); + +#endif /* DRV_CORTEX_M3_SYSIRQ_H */