void Interrupt_unpendInterrupt(uint32_t interruptNumber) { // // Check the arguments. // ASSERT(interruptNumber < (NUM_INTERRUPTS+1)); // // Determine the interrupt to unpend. // if (interruptNumber == FAULT_PENDSV) { // // Unpend the PendSV interrupt. // SCB->ICSR |= SCB_ICSR_PENDSVCLR; } else if (interruptNumber == FAULT_SYSTICK) { // // Unpend the SysTick interrupt. // SCB->ICSR |= SCB_ICSR_PENDSTCLR; } else if (interruptNumber >= 16) { // // Unpend the general interrupt. // HWREG32 (g_pulUnpendRegs[(interruptNumber - 16) / 32]) = 1 << ((interruptNumber - 16) & 31); } }
//***************************************************************************** // // This is the code that gets called when the processor first starts execution // following a reset event. Only the absolutely necessary set is performed, // after which the application supplied entry() routine is called. Any fancy // actions (such as making decisions based on the reset cause register, and // resetting the bits in that register) are left solely in the hands of the // application. // //***************************************************************************** void ResetISR(void) { uint32_t *src, *dest; // // Copy the data segment initializers from flash to SRAM. // src = &_etext; for(dest = &_data; dest < &_edata; ) { *dest++ = *src++; } // // Zero fill the bss segment. // __asm(" ldr r0, =_bss\n" " ldr r1, =_ebss\n" " mov r2, #0\n" " .thumb_func\n" "zero_loop:\n" " cmp r0, r1\n" " it lt\n" " strlt r2, [r0], #4\n" " blt zero_loop"); // // Enable the floating-point unit. This must be done here to handle the // case where main() uses floating-point and the function prologue saves // floating-point registers (which will fault if floating-point is not // enabled). Any configuration of the floating-point unit using DriverLib // APIs must be done here prior to the floating-point unit being enabled. // // Note that this does not use DriverLib since it might not be included in // this project. // HWREG32(SCS_BASE + OFS_SCB_CPACR) = ((HWREG32(SCS_BASE + OFS_SCB_CPACR) & ~(SCB_CPACR_CP11_M | SCB_CPACR_CP10_M)) | SCB_CPACR_CP11_M | SCB_CPACR_CP10_M); // // Call the application's entry point. // main(); }
bool Interrupt_isEnabled(uint32_t interruptNumber) { uint32_t ulRet; // // Check the arguments. // ASSERT(interruptNumber < (NUM_INTERRUPTS+1)); // // Initialize the return value. // ulRet = 0; // // Determine the interrupt to disable. // if (interruptNumber == FAULT_MPU) { // // Check the MemManage interrupt. // ulRet = SCB->SHCSR & SCB_SHCSR_MEMFAULTENA; } else if (interruptNumber == FAULT_BUS) { // // Check the bus fault interrupt. // ulRet = SCB->SHCSR & SCB_SHCSR_BUSFAULTENA; } else if (interruptNumber == FAULT_USAGE) { // // Check the usage fault interrupt. // ulRet = SCB->SHCSR & SCB_SHCSR_USGFAULTENA; } else if (interruptNumber == FAULT_SYSTICK) { // // Check the System Tick interrupt. // ulRet = SysTick->CTRL & SysTick_CTRL_ENABLE_Msk; } else if (interruptNumber >= 16) { // // Check the general interrupt. // ulRet = HWREG32(g_pulEnRegs[(interruptNumber - 16) / 32]) & (1 << ((interruptNumber - 16) & 31)); } return (ulRet); }
//***************************************************************************** // // This is the code that gets called when the processor first starts execution // following a reset event. Only the absolutely necessary set is performed, // after which the application supplied entry() routine is called. Any fancy // actions (such as making decisions based on the reset cause register, and // resetting the bits in that register) are left solely in the hands of the // application. // //***************************************************************************** void ResetISR(void) { // // Enable the floating-point unit. This must be done here to handle the // case where main() uses floating-point and the function prologue saves // floating-point registers (which will fault if floating-point is not // enabled). Any configuration of the floating-point unit using DriverLib // APIs must be done here prior to the floating-point unit being enabled. // // Note that this does not use DriverLib since it might not be included in // this project. // HWREG32(SCS_BASE + OFS_SCB_CPACR) = ((HWREG32(SCS_BASE + OFS_SCB_CPACR) & ~(SCB_CPACR_CP11_M | SCB_CPACR_CP10_M)) | SCB_CPACR_CP11_M | SCB_CPACR_CP10_M); // // Call the application's entry point. // __iar_program_start(); }
void Interrupt_disableInterrupt(uint32_t interruptNumber) { // // Check the arguments. // ASSERT(interruptNumber < (NUM_INTERRUPTS+1)); // // Determine the interrupt to disable. // if (interruptNumber == FAULT_MPU) { // // Disable the MemManage interrupt. // SCB->SHCSR &= ~(SCB_SHCSR_MEMFAULTENA); } else if (interruptNumber == FAULT_BUS) { // // Disable the bus fault interrupt. // SCB->SHCSR &= ~(SCB_SHCSR_BUSFAULTENA); } else if (interruptNumber == FAULT_USAGE) { // // Disable the usage fault interrupt. // SCB->SHCSR &= ~(SCB_SHCSR_USGFAULTENA); } else if (interruptNumber == FAULT_SYSTICK) { // // Disable the System Tick interrupt. // SysTick->CTRL &= ~(SysTick_CTRL_ENABLE_Msk); } else if (interruptNumber >= 16) { // // Disable the general interrupt. // HWREG32 (g_pulDisRegs[(interruptNumber - 16) / 32]) = 1 << ((interruptNumber - 16) & 31); } }
void Interrupt_registerInterrupt(uint32_t interruptNumber, void (*intHandler)(void)) { uint32_t ulIdx, ulValue; // // Check the arguments. // ASSERT(interruptNumber < (NUM_INTERRUPTS+1)); // // Make sure that the RAM vector table is correctly aligned. // ASSERT(((uint32_t) g_pfnRAMVectors & 0x000000ff) == 0); // // See if the RAM vector table has been initialized. // if (SCB->VTOR != (uint32_t) g_pfnRAMVectors) { // // Copy the vector table from the beginning of FLASH to the RAM vector // table. // ulValue = SCB->VTOR; for (ulIdx = 0; ulIdx < (NUM_INTERRUPTS + 1); ulIdx++) { g_pfnRAMVectors[ulIdx] = (void (*)(void)) HWREG32( (ulIdx * 4) + ulValue); } // // Point the NVIC at the RAM vector table. Doesn't point // the NVIC. In the core processor, not the NVIC. // SCB->VTOR = (uint32_t) g_pfnRAMVectors; } // // Save the interrupt handler. // g_pfnRAMVectors[interruptNumber] = intHandler; }