/*---------------------------------------------------------------------------* * Routine: InterruptDisable *---------------------------------------------------------------------------* * Description: * Disable an existing interrupt. * Inputs: * T_irqChannel aChannel -- Handle of registered interrupt to * disable. *---------------------------------------------------------------------------*/ void InterruptDisable(T_irqChannel aChannel) { if (aChannel >= UEZ_MAX_IRQ_CHANNELS) InterruptFatalError(); NVIC_DisableIRQ((IRQn_Type)aChannel); }
/*---------------------------------------------------------------------------* * Routine: InterruptUnregister *---------------------------------------------------------------------------* * Description: * The interrupt is no longer needed. Disable and remove it. * Inputs: * TUInt32 aInterruptChannel -- Channel of interrupt to unregister *---------------------------------------------------------------------------*/ void InterruptUnregister(TUInt32 aInterruptChannel) { T_irqHandleStruct *p; if (aInterruptChannel >= UEZ_MAX_IRQ_CHANNELS) InterruptFatalError(); // Look up the channel p = G_isrArray+aInterruptChannel; // Is there an interrupt here? if (p->iISR == 0) InterruptFatalError(); NVIC_DisableIRQ((IRQn_Type)aInterruptChannel); // Mark it as freed p->iISR = 0; }
/*---------------------------------------------------------------------------* * Routine: InterruptUnregister *---------------------------------------------------------------------------* * Description: * The interrupt is no longer needed. Disable and remove it. * Inputs: * TUInt32 aInterruptChannel -- Channel of interrupt to unregister *---------------------------------------------------------------------------*/ void InterruptUnregister(TUInt32 aInterruptChannel) { T_irqHandleStruct *p; if (aInterruptChannel >= UEZ_MAX_IRQ_CHANNELS) InterruptFatalError(); // Ensure interrupt is turned off InterruptDisable(aInterruptChannel); // Look up the channel p = G_isrArray+aInterruptChannel; // Is there an interrupt here? if (p->iISR == InterruptFatalError) InterruptFatalError(); // Mark it as freed p->iISR = InterruptFatalError; }
/*---------------------------------------------------------------------------* * Routine: InterruptRegister *---------------------------------------------------------------------------* * Description: * Register an interrupt. * Inputs: * TUInt32 aInterruptChannel -- Channel of interrupt to register * TFPtr aISR -- Pointer to interrupt service routine. * T_irqPriority aPriority -- Priority of interrupt. * const char *aName -- Name/descriptor of interrupt. *---------------------------------------------------------------------------*/ void InterruptRegister( TUInt32 aInterruptChannel, TISRFPtr aISR, T_irqPriority aPriority, const char * const aName) { T_irqHandleStruct *p; // Reject attempts to allocate more ISRs than available if (aInterruptChannel >= UEZ_MAX_IRQ_CHANNELS) InterruptFatalError(); // Create a new entry and return the handle p = G_isrArray+aInterruptChannel; // Interrupt already exists for this one! if (p->iISR != 0) InterruptFatalError(); p->iInterruptChannel = aInterruptChannel; p->iISR = aISR; #if LPC17xx_40xx_INTERRUPT_TRACK_NAMES p->iName = aName; #endif // Set the interrupt priority. #if (RTOS == SafeRTOS) /* <<< WHIS >>> Assignment of interrupt levels is critical to the correct operation of UEZ and SafeRTOS. Interrupt.h defines levels between 0-15, whereas the LPC17xx_40xx has 32 interrupt levels. However all UEZ interrupts use the semaphore release and therefore need to be greater than configSYSTEM_INTERRUPT_PRIORITY_LVL. configSYSTEM_INTERRUPT_PRIORITY_LVL is defined as 16 so we can just add the uEZ priority to the RTOS threshold to arrive a legal priority between 16 and 31. */ NVIC_SetPriority((IRQn_Type)aInterruptChannel, configSYSTEM_INTERRUPT_PRIORITY_LVL + aPriority); #else NVIC_SetPriority((IRQn_Type)aInterruptChannel, 6+aPriority); #endif //NVIC_EnableIRQ((IRQn_Type)aInterruptChannel); }
/*---------------------------------------------------------------------------* * Routine: InterruptRegister *---------------------------------------------------------------------------* * Description: * Register an interrupt. * Inputs: * TUInt32 aInterruptChannel -- Channel of interrupt to register * TFPtr aISR -- Pointer to interrupt service routine. * T_irqPriority aPriority -- Priority of interrupt. * const char *aName -- Name/descriptor of interrupt. *---------------------------------------------------------------------------*/ void InterruptRegister( TUInt32 aInterruptChannel, TFPtr aISR, T_irqPriority aPriority, const char * const aName) { T_irqHandleStruct *p; // Reject attempts to allocate more ISRs than available if (aInterruptChannel >= UEZ_MAX_IRQ_CHANNELS) InterruptFatalError(); // Create a new entry and return the handle p = G_isrArray+aInterruptChannel; // Interrupt already exists for this one! if (p->iISR != InterruptFatalError) InterruptFatalError(); p->iISR = aISR; p->iName = aName; // Set the priority ICU.IPR[G_IPRTable[aInterruptChannel]].BIT.IPR = 15-aPriority; }