From: arighi Date: Tue, 6 Apr 2010 09:28:18 +0000 (+0000) Subject: CM3: introduce sysirq_setPriority(). X-Git-Tag: 2.5.0~515 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=a44c75542e3457749e084a2eb860b668af8d1d72;p=bertos.git CM3: introduce sysirq_setPriority(). git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3393 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/cortex-m3/drv/irq_lm3s.c b/bertos/cpu/cortex-m3/drv/irq_lm3s.c index 2ff83575..370fbab0 100644 --- a/bertos/cpu/cortex-m3/drv/irq_lm3s.c +++ b/bertos/cpu/cortex-m3/drv/irq_lm3s.c @@ -45,15 +45,38 @@ static void (*irq_table[NUM_INTERRUPTS])(void) __attribute__((section("vtable"))); /* Unhandled IRQ */ -static NORETURN NAKED void unhandled_isr(void) +static NAKED NORETURN void unhandled_isr(void) { - reg32_t reg; + register uint32_t reg; asm volatile ("mrs %0, ipsr" : "=r"(reg)); LOG_ERR("unhandled IRQ %lu\n", reg); - PAUSE; - UNREACHABLE(); - ASSERT(0); + while (1) + PAUSE; +} + +void sysirq_setPriority(sysirq_t irq, int prio) +{ + uint32_t pos = (irq & 3) * 8; + reg32_t reg; + + switch (irq >> 2) + { + case 1: + reg = NVIC_SYS_PRI1; + break; + case 2: + reg = NVIC_SYS_PRI2; + break; + case 3: + reg = NVIC_SYS_PRI3; + break; + default: + ASSERT(0); + return; + } + HWREG(reg) &= ~(0xff << pos); + HWREG(reg) |= prio << pos; } void sysirq_setHandler(sysirq_t irq, sysirq_handler_t handler) @@ -64,6 +87,7 @@ void sysirq_setHandler(sysirq_t irq, sysirq_handler_t handler) IRQ_SAVE_DISABLE(flags); irq_table[irq] = handler; + sysirq_setPriority(irq, IRQ_PRIO); IRQ_RESTORE(flags); } diff --git a/bertos/cpu/cortex-m3/drv/irq_lm3s.h b/bertos/cpu/cortex-m3/drv/irq_lm3s.h index 1770ed1f..8913183d 100644 --- a/bertos/cpu/cortex-m3/drv/irq_lm3s.h +++ b/bertos/cpu/cortex-m3/drv/irq_lm3s.h @@ -42,6 +42,7 @@ typedef void (*sysirq_handler_t)(void); typedef unsigned int sysirq_t; void sysirq_setHandler(sysirq_t irq, sysirq_handler_t handler); +void sysirq_setPriority(sysirq_t irq, int prio); void sysirq_freeHandler(sysirq_t irq); void sysirq_init(void);