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
133 #if defined(__IAR_SYSTEMS_ICC__)
134 #pragma data_alignment=256
135 static __no_init void (*
g_pfnRAMVectors[NUM_INTERRUPTS])(void) @
".vtable_ram";
136 #elif defined(__TI_COMPILER_VERSION__) || defined(DOXYGEN)
137 #pragma DATA_ALIGN(g_pfnRAMVectors, 256)
138 #pragma DATA_SECTION(g_pfnRAMVectors, ".vtable_ram")
140 #elif defined (__CC_ARM)
141 static __attribute__((section(
"vtable_ram")))
142 void (*
g_pfnRAMVectors[NUM_INTERRUPTS])(
void) __attribute__((aligned(256),
145 static __attribute__((section(
"vtable_ram")))
146 void (*
g_pfnRAMVectors[NUM_INTERRUPTS])(
void) __attribute__((aligned(256)));
157 uint32_t ui32Idx, ui32Value;
162 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
178 ui32Value = HWREG(NVIC_VTABLE);
179 for(ui32Idx = 0; ui32Idx < NUM_INTERRUPTS; ui32Idx++)
181 g_pfnRAMVectors[ui32Idx] = (void (*)(void))HWREG((ui32Idx * 4) +
188 HWREG(NVIC_VTABLE) = (uint32_t)g_pfnRAMVectors;
194 g_pfnRAMVectors[ui32Interrupt] = pfnHandler;
208 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
227 ASSERT(ui32Bits < NUM_PRIORITY);
243 uint32_t ui32Loop, ui32Value;
248 ui32Value = HWREG(NVIC_APINT) & NVIC_APINT_PRIGROUP_M;
253 for(ui32Loop = 0; ui32Loop < NUM_PRIORITY; ui32Loop++)
283 ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
290 ui32Temp &= ~(0xFF << (8 * (ui32Interrupt & 3)));
291 ui32Temp |= ui8Priority << (8 * (ui32Interrupt & 3));
306 ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
311 return((HWREG(
g_pui32Regs[ui32Interrupt >> 2]) >> (8 * (ui32Interrupt & 3))) &
326 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
331 if(ui32Interrupt == FAULT_MPU)
336 HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_MEM;
338 else if(ui32Interrupt == FAULT_BUS)
343 HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_BUS;
345 else if(ui32Interrupt == FAULT_USAGE)
350 HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_USAGE;
352 else if(ui32Interrupt == FAULT_SYSTICK)
357 HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
359 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
364 HWREG(NVIC_EN0) = 1 << (ui32Interrupt - 16);
366 else if(ui32Interrupt >= 48)
371 HWREG(NVIC_EN1) = 1 << (ui32Interrupt - 48);
386 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
391 if(ui32Interrupt == FAULT_MPU)
396 HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_MEM);
398 else if(ui32Interrupt == FAULT_BUS)
403 HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_BUS);
405 else if(ui32Interrupt == FAULT_USAGE)
410 HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_USAGE);
412 else if(ui32Interrupt == FAULT_SYSTICK)
417 HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
419 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
424 HWREG(NVIC_DIS0) = 1 << (ui32Interrupt - 16);
426 else if(ui32Interrupt >= 48)
431 HWREG(NVIC_DIS1) = 1 << (ui32Interrupt - 48);
446 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
451 if(ui32Interrupt == FAULT_NMI)
456 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_NMI_SET;
458 else if(ui32Interrupt == FAULT_PENDSV)
463 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PEND_SV;
465 else if(ui32Interrupt == FAULT_SYSTICK)
470 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTSET;
472 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
477 HWREG(NVIC_PEND0) = 1 << (ui32Interrupt - 16);
479 else if(ui32Interrupt >= 48)
484 HWREG(NVIC_PEND1) = 1 << (ui32Interrupt - 48);
496 uint32_t ui32IntPending;
501 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
511 if (ui32Interrupt < 16)
525 ui32IntPending = HWREG(NVIC_PEND0 + (ui32Interrupt / 32));
526 ui32IntPending &= (1 << (ui32Interrupt & 31));
528 return ui32IntPending ?
true :
false;
542 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
547 if(ui32Interrupt == FAULT_PENDSV)
552 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_UNPEND_SV;
554 else if(ui32Interrupt == FAULT_SYSTICK)
559 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTCLR;
561 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
566 HWREG(NVIC_UNPEND0) = 1 << (ui32Interrupt - 16);
568 else if(ui32Interrupt >= 48)
573 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.