47 #ifndef DRIVERLIB_GENERATE_ROM
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
78 static const uint32_t g_pui32Priority[] =
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
91 static const uint32_t g_pui32Regs[] =
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
112 IntDefaultHandler(
void)
135 #if defined(__IAR_SYSTEMS_ICC__)
136 #pragma data_alignment=256
137 static __no_init void (*
g_pfnRAMVectors[NUM_INTERRUPTS])(void) @
".vtable_ram";
138 #elif defined(__TI_COMPILER_VERSION__) || defined(DOXYGEN)
139 #pragma DATA_ALIGN(g_pfnRAMVectors, 256)
140 #pragma DATA_SECTION(g_pfnRAMVectors, ".vtable_ram")
142 #elif defined (rvmdk)
143 static __attribute__((section(
"vtable_ram")))
144 void (*
g_pfnRAMVectors[NUM_INTERRUPTS])(
void) __attribute__((aligned(256),
147 static __attribute__((section(
"vtable_ram")))
148 void (*
g_pfnRAMVectors[NUM_INTERRUPTS])(
void) __attribute__((aligned(256)));
159 uint32_t ui32Idx, ui32Value;
164 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
180 ui32Value = HWREG(NVIC_VTABLE);
181 for(ui32Idx = 0; ui32Idx < NUM_INTERRUPTS; ui32Idx++)
183 g_pfnRAMVectors[ui32Idx] = (void (*)(void))HWREG((ui32Idx * 4) +
190 HWREG(NVIC_VTABLE) = (uint32_t)g_pfnRAMVectors;
196 g_pfnRAMVectors[ui32Interrupt] = pfnHandler;
210 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
229 ASSERT(ui32Bits < NUM_PRIORITY);
234 HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | g_pui32Priority[ui32Bits];
245 uint32_t ui32Loop, ui32Value;
250 ui32Value = HWREG(NVIC_APINT) & NVIC_APINT_PRIGROUP_M;
255 for(ui32Loop = 0; ui32Loop < NUM_PRIORITY; ui32Loop++)
260 if(ui32Value == g_pui32Priority[ui32Loop])
285 ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
291 ui32Temp = HWREG(g_pui32Regs[ui32Interrupt >> 2]);
292 ui32Temp &= ~(0xFF << (8 * (ui32Interrupt & 3)));
293 ui32Temp |= ui8Priority << (8 * (ui32Interrupt & 3));
294 HWREG(g_pui32Regs[ui32Interrupt >> 2]) = ui32Temp;
308 ASSERT((ui32Interrupt >= 4) && (ui32Interrupt < NUM_INTERRUPTS));
313 return((HWREG(g_pui32Regs[ui32Interrupt >> 2]) >> (8 * (ui32Interrupt & 3))) &
328 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
333 if(ui32Interrupt == FAULT_MPU)
338 HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_MEM;
340 else if(ui32Interrupt == FAULT_BUS)
345 HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_BUS;
347 else if(ui32Interrupt == FAULT_USAGE)
352 HWREG(NVIC_SYS_HND_CTRL) |= NVIC_SYS_HND_CTRL_USAGE;
354 else if(ui32Interrupt == FAULT_SYSTICK)
359 HWREG(NVIC_ST_CTRL) |= NVIC_ST_CTRL_INTEN;
361 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
366 HWREG(NVIC_EN0) = 1 << (ui32Interrupt - 16);
368 else if(ui32Interrupt >= 48)
373 HWREG(NVIC_EN1) = 1 << (ui32Interrupt - 48);
388 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
393 if(ui32Interrupt == FAULT_MPU)
398 HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_MEM);
400 else if(ui32Interrupt == FAULT_BUS)
405 HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_BUS);
407 else if(ui32Interrupt == FAULT_USAGE)
412 HWREG(NVIC_SYS_HND_CTRL) &= ~(NVIC_SYS_HND_CTRL_USAGE);
414 else if(ui32Interrupt == FAULT_SYSTICK)
419 HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_INTEN);
421 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
426 HWREG(NVIC_DIS0) = 1 << (ui32Interrupt - 16);
428 else if(ui32Interrupt >= 48)
433 HWREG(NVIC_DIS1) = 1 << (ui32Interrupt - 48);
448 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
453 if(ui32Interrupt == FAULT_NMI)
458 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_NMI_SET;
460 else if(ui32Interrupt == FAULT_PENDSV)
465 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PEND_SV;
467 else if(ui32Interrupt == FAULT_SYSTICK)
472 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTSET;
474 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
479 HWREG(NVIC_PEND0) = 1 << (ui32Interrupt - 16);
481 else if(ui32Interrupt >= 48)
486 HWREG(NVIC_PEND1) = 1 << (ui32Interrupt - 48);
498 uint32_t ui32IntPending;
503 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
513 if (ui32Interrupt < 16)
527 ui32IntPending = HWREG(NVIC_PEND0 + (ui32Interrupt / 32));
528 ui32IntPending &= (1 << (ui32Interrupt & 31));
530 return ui32IntPending ?
true :
false;
544 ASSERT(ui32Interrupt < NUM_INTERRUPTS);
549 if(ui32Interrupt == FAULT_PENDSV)
554 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_UNPEND_SV;
556 else if(ui32Interrupt == FAULT_SYSTICK)
561 HWREG(NVIC_INT_CTRL) |= NVIC_INT_CTRL_PENDSTCLR;
563 else if((ui32Interrupt >= 16) && (ui32Interrupt <= 47))
568 HWREG(NVIC_UNPEND0) = 1 << (ui32Interrupt - 16);
570 else if(ui32Interrupt >= 48)
575 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.
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.
bool IntPendGet(uint32_t ui32Interrupt)
Query whether an interrupt is pending.
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.