#include "interrupt.h" #include "hwd_interrupt.h" static void defaultHandler(){}; // pointers to dedicated interrupt handlers void intInit( intrType_t intType, intHandler_t handler, uint8_t priority) { NVIC_SetPriority(interruptTypeIndexList[intType], priority); // TODO: add index ceck! intHandlerList[intType] = (uint32_t)handler; } void intEnableAll() { __enable_irq(); } void intDissableAll() { __disable_irq(); } void intEnable( intrType_t intType) { NVIC_EnableIRQ(interruptTypeIndexList[intType]); } void intDissable( intrType_t intType) { NVIC_DisableIRQ(interruptTypeIndexList[intType]); } // Interrupt service routines void TIM2_IRQHandler() { if(TIM2->SR & TIM_SR_UIF) { // clear flag TIM2-> SR &= ~TIM_SR_UIF; //TODO: call handler here ((intHandler_t)(intHandlerList[TIM2_UPDATE]))(); } if(TIM2->SR & TIM_SR_CC1IF) { TIM2-> SR &= ~TIM_SR_CC1IF; ((intHandler_t)(intHandlerList[TIM2_COUNTERCOMPARE_1]))(); } if(TIM2->SR & TIM_SR_CC2IF) { TIM2-> SR &= ~TIM_SR_CC2IF; ((intHandler_t)(intHandlerList[TIM2_COUNTERCOMPARE_2]))(); } if(TIM2->SR & TIM_SR_CC3IF) { TIM2-> SR &= ~TIM_SR_CC3IF; ((intHandler_t)(intHandlerList[TIM2_COUNTERCOMPARE_3]))(); } if(TIM2->SR & TIM_SR_CC4IF) { TIM2-> SR &= ~TIM_SR_CC4IF; ((intHandler_t)(intHandlerList[TIM2_COUNTERCOMPARE_4]))(); } if(TIM2->SR & TIM_SR_TIF) { TIM2-> SR &= ~TIM_SR_TIF; ((intHandler_t)(intHandlerList[TIM2_TRIGGER]))(); } if(TIM2->SR & TIM_SR_CC1OF) { TIM2-> SR &= ~TIM_SR_CC1OF; ((intHandler_t)(intHandlerList[TIM2_CAPTURECOMPARE_1]))(); } if(TIM2->SR & TIM_SR_CC2OF) { TIM2-> SR &= ~TIM_SR_CC2OF; ((intHandler_t)(intHandlerList[TIM2_CAPTURECOMPARE_2]))(); } if(TIM2->SR & TIM_SR_CC3OF) { TIM2-> SR &= ~TIM_SR_CC3OF; ((intHandler_t)(intHandlerList[TIM2_CAPTURECOMPARE_3]))(); } if(TIM2->SR & TIM_SR_CC4OF) { TIM2-> SR &= ~TIM_SR_CC4OF; ((intHandler_t)(intHandlerList[TIM2_CAPTURECOMAPRE_4]))(); } }