#include "timerdriver.h" #include "gpiodriver.h" void (* pFnc) (void); /* déclaration d’un pointeur de fonction */ void Init_Periph (void (* ptrFonction)(void)) { pFnc = ptrFonction; /* affectation du pointeur */ } void MyTimer_Base_Init(MyTimer_Struct_TypeDef * Timer) { //TIM1 uses the APB2ENR register from RCC. The others uses the APB1ENR, so we check this value. if(Timer->Timer == TIM1) { RCC->APB2ENR |= TimerX2Int(Timer->Timer); } else { RCC->APB1ENR |= TimerX2Int(Timer->Timer); } Timer->Timer->ARR = Timer->ARR; Timer->Timer->PSC = Timer->PSC; } void MyTimer_ActiveIT(TIM_TypeDef * TimerX, uint8_t Prio) { uint8_t positionTimerIT = TimerIT2UInt(TimerX); TimerX->DIER |= (0x1<IP[positionTimerIT] |= (Prio << 0x4); NVIC->ISER[0] |= (0x1< 4 return (0x01 << 19); } else if (TimerX == TIM10){ return (0x01 << 20); } else if (TimerX == TIM11){ return (0x01 << 21); } else if (TimerX == TIM12){ return (0x01 << 6); } else if (TimerX == TIM13){ return (0x01 << 7); } else if (TimerX == TIM14){ return (0x01 << 8); }*/ else { return -1; }; } uint8_t TimerIT2UInt(TIM_TypeDef * TimerX) { if(TimerX == TIM1) { return TIM1_CC_IRQn; } else if(TimerX == TIM2) { return TIM2_IRQn; } else if(TimerX == TIM3) { return TIM3_IRQn; } else if(TimerX == TIM4) { return 30; } else { return 0; } } void TIM1_CC_IRQHandler(void) { if (pFnc != 0) (*pFnc) (); /* appel indirect de la fonction */ TIM1->SR &= ~(0x1<SR &= ~(0x1<SR &= ~(0x1<SR &= ~(0x1<