49 #define IntRegister NOROM_IntRegister
51 #define IntUnregister NOROM_IntUnregister
52 #undef IntPriorityGroupingSet
53 #define IntPriorityGroupingSet NOROM_IntPriorityGroupingSet
54 #undef IntPriorityGroupingGet
55 #define IntPriorityGroupingGet NOROM_IntPriorityGroupingGet
57 #define IntPrioritySet NOROM_IntPrioritySet
59 #define IntPriorityGet NOROM_IntPriorityGet
61 #define IntEnable NOROM_IntEnable
63 #define IntDisable NOROM_IntDisable
65 #define IntPendSet NOROM_IntPendSet
67 #define IntPendGet NOROM_IntPendGet
69 #define IntPendClear NOROM_IntPendClear
80 NVIC_APINT_PRIGROUP_0_8, NVIC_APINT_PRIGROUP_1_7, NVIC_APINT_PRIGROUP_2_6,
81 NVIC_APINT_PRIGROUP_3_5, NVIC_APINT_PRIGROUP_4_4, NVIC_APINT_PRIGROUP_5_3,
82 NVIC_APINT_PRIGROUP_6_2, NVIC_APINT_PRIGROUP_7_1
93 0, NVIC_SYS_PRI1, NVIC_SYS_PRI2, NVIC_SYS_PRI3, NVIC_PRI0, NVIC_PRI1,
94 NVIC_PRI2, NVIC_PRI3, NVIC_PRI4, NVIC_PRI5, NVIC_PRI6, NVIC_PRI7,
95 NVIC_PRI8, NVIC_PRI9, NVIC_PRI10, NVIC_PRI11, NVIC_PRI12, NVIC_PRI13
131 #if defined(__IAR_SYSTEMS_ICC__)
132 #pragma data_alignment=256
133 static __no_init void (*
g_pfnRAMVectors[NUM_INTERRUPTS])(void) @
".vtable_ram";
134 #elif defined(__TI_COMPILER_VERSION__) || defined(DOXYGEN)
135 #pragma DATA_ALIGN(g_pfnRAMVectors, 256)
136 #pragma DATA_SECTION(g_pfnRAMVectors, ".vtable_ram")
138 #elif defined (__CC_ARM)
139 static __attribute__((section(
"vtable_ram")))
140 void (*
g_pfnRAMVectors[NUM_INTERRUPTS])(
void) __attribute__((aligned(256)));
142 static __attribute__((section(
"vtable_ram")))
143 void (*
g_pfnRAMVectors[NUM_INTERRUPTS])(
void) __attribute__((aligned(256)));
154 uint32_t ui32Idx, ui32Value;
159 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
175 ui32Value = HWREG(NVIC_VTABLE);
176 for(ui32Idx = 0; ui32Idx < NUM_INTERRUPTS; ui32Idx++)
178 g_pfnRAMVectors[ui32Idx] = (void (*)(void))HWREG((ui32Idx * 4) +
185 HWREG(NVIC_VTABLE) = (uint32_t)g_pfnRAMVectors;
191 g_pfnRAMVectors[ui32Interrupt] = pfnHandler;
205 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
224 ASSERT(ui32Bits < NUM_PRIORITY);
240 uint32_t ui32Loop, ui32Value;
245 ui32Value = HWREG(NVIC_APINT) & NVIC_APINT_PRIGROUP_M;
250 for(ui32Loop = 0; ui32Loop < NUM_PRIORITY; ui32Loop++)
280 ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
287 ui32Temp &= ~(0xFF << (8 * (ui32Interrupt & 3)));
288 ui32Temp |= ui8Priority << (8 * (ui32Interrupt & 3));
303 ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
308 return((HWREG(
g_pui32Regs[ui32Interrupt >> 2]) >> (8 * (ui32Interrupt & 3))) &
323 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
328 if(ui32Interrupt == FAULT_MPU)
333 HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_MEM;
335 else if(ui32Interrupt == FAULT_BUS)
340 HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_BUS;
342 else if(ui32Interrupt == FAULT_USAGE)
347 HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_USAGE;
349 else if(ui32Interrupt == FAULT_SYSTICK)
354 HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
356 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
361 HWREG(NVIC_EN0) = 1 << (ui32Interrupt - 16);
363 else if(ui32Interrupt >= 48)
368 HWREG(NVIC_EN1) = 1 << (ui32Interrupt - 48);
383 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
388 if(ui32Interrupt == FAULT_MPU)
393 HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_MEM);
395 else if(ui32Interrupt == FAULT_BUS)
400 HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_BUS);
402 else if(ui32Interrupt == FAULT_USAGE)
407 HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_USAGE);
409 else if(ui32Interrupt == FAULT_SYSTICK)
414 HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
416 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
421 HWREG(NVIC_DIS0) = 1 << (ui32Interrupt - 16);
423 else if(ui32Interrupt >= 48)
428 HWREG(NVIC_DIS1) = 1 << (ui32Interrupt - 48);
443 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
448 if(ui32Interrupt == FAULT_NMI)
453 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_NMI_SET;
455 else if(ui32Interrupt == FAULT_PENDSV)
460 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PEND_SV;
462 else if(ui32Interrupt == FAULT_SYSTICK)
467 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTSET;
469 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
474 HWREG(NVIC_PEND0) = 1 << (ui32Interrupt - 16);
476 else if(ui32Interrupt >= 48)
481 HWREG(NVIC_PEND1) = 1 << (ui32Interrupt - 48);
493 uint32_t ui32IntPending;
498 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
508 if (ui32Interrupt < 16)
522 ui32IntPending = HWREG(NVIC_PEND0 + (ui32Interrupt / 32));
523 ui32IntPending &= (1 << (ui32Interrupt & 31));
525 return ui32IntPending ?
true :
false;
539 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
544 if(ui32Interrupt == FAULT_PENDSV)
549 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_UNPEND_SV;
551 else if(ui32Interrupt == FAULT_SYSTICK)
556 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTCLR;
558 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
563 HWREG(NVIC_UNPEND0) = 1 << (ui32Interrupt - 16);
565 else if(ui32Interrupt >= 48)
570 HWREG(NVIC_UNPEND1) = 1 << (ui32Interrupt - 48);
int32_t IntPriorityGet(uint32_t ui32Interrupt)
Gets the priority of an interrupt.
void(* g_pfnRAMVectors[NUM_INTERRUPTS])(void)
void IntPendClear(uint32_t ui32Interrupt)
Unpends an interrupt.
static const uint32_t g_pui32Regs[]
void IntPriorityGroupingSet(uint32_t ui32Bits)
Sets the priority grouping of the interrupt controller.
uint32_t IntPriorityGroupingGet(void)
Gets the priority grouping of the interrupt controller.
void IntPendSet(uint32_t ui32Interrupt)
Pends an interrupt.
void IntUnregister(uint32_t ui32Interrupt)
Unregisters the function to be called when an interrupt occurs.
void IntPrioritySet(uint32_t ui32Interrupt, uint8_t ui8Priority)
Sets the priority of an interrupt.
static void IntDefaultHandler(void)
The default interrupt handler.
bool IntPendGet(uint32_t ui32Interrupt)
Query whether an interrupt is pending.
static const uint32_t g_pui32Priority[]
void IntDisable(uint32_t ui32Interrupt)
Disables an interrupt.
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Registers a function to be called when an interrupt occurs.
void IntEnable(uint32_t ui32Interrupt)
Enables an interrupt.