#include #include #include #include void (*Ptr_fct_girouette) (void); void Timer_Counter (TIM_TypeDef *Timer) { Timer->CCMR1 |= TIM_CCMR1_CC1S_0; Timer->CCMR1 |= TIM_CCMR1_CC2S_0; Timer->CCER &= ~(TIM_CCER_CC1P); Timer->CCER &= ~(TIM_CCER_CC1NP); Timer->CCMR1 &= ~(TIM_CCMR1_IC1F); Timer->CCER &= ~(TIM_CCER_CC2P); Timer->CCER &= ~(TIM_CCER_CC2NP); Timer->CCMR1 &= ~(TIM_CCMR1_IC2F); Timer->SMCR |= 0x0003; Timer->CR1 |= TIM_CR1_CEN; } void Init_girouette (){ MyTimer_Init(TIM4, 1440, 1); MyTimer_Base_Start(TIM4); MyGPIO_Init(GPIOB, 6, In_Floating); MyGPIO_Init(GPIOB, 7, In_Floating); MyGPIO_Init(GPIOA, 12, In_Floating); Init_Interrupt(3, LafonctGirouette); Timer_Counter(TIM4); } //Fonctio girouette appeler pour l'interruption void LafonctGirouette(){ TIM4->CNT = 0; } void Init_Interrupt(char Prio, void (*IT_function) (void)){ RCC->APB2ENR |= RCC_APB2ENR_AFIOEN; AFIO->EXTICR[3] &= ~(0xF); EXTI->IMR |= 1<<12; EXTI->RTSR |= 1<<12; NVIC->ISER[1] |= NVIC_ISER_SETENA_8; // exti 12 on s'est trompé mais normalement c'est bo mtn Ptr_fct_girouette = IT_function; NVIC->IPR[40] = Prio<<4; } void EXTI15_10_IRQHandler (){ EXTI->PR |= 1 << 12; Ptr_fct_girouette(); }