CM3: introduce sysirq_setPriority().
authorarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 6 Apr 2010 09:28:18 +0000 (09:28 +0000)
committerarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 6 Apr 2010 09:28:18 +0000 (09:28 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3393 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/cortex-m3/drv/irq_lm3s.c
bertos/cpu/cortex-m3/drv/irq_lm3s.h

index 2ff83575fd699c2f8fb31e81e34149e8c297cb7a..370fbab01ac92a6216f8693504101743ea5106c1 100644 (file)
@@ -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);
 }
 
index 1770ed1f5cc59f451178d8afb94031db79f784ba..8913183d65dff900ad5ba6d6b527c07d1c50860f 100644 (file)
@@ -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);