#include "girouette.h" void MyGirouette_Init(TIM_TypeDef *TIMX) { //configuration gpiob6 et gpiob7 en entrées In_Floating imposer par le timer4 MyGPIO_Struct_TypeDef MyGPIO={GPIOB,6,In_Floating}; MyGPIO_Init(&MyGPIO); MyGPIO.GPIO_Pin=7; MyGPIO_Init(&MyGPIO); //config pa0 en entrées MyGPIO.GPIO_Pin=0; MyGPIO.GPIO=GPIOA; MyGPIO_Init(&MyGPIO); //configuration TIM4 reset a 360 MyTimer_Struct_Typedef MyTimerGirouette ={TIMX,1439,0}; MyTimer_Base_Init(&MyTimerGirouette); TIMX->SMCR &=~0x07; TIMX->SMCR |=TIM_SMCR_SMS_1; TIMX->CCMR1 &=~(0xF2F2); TIMX->CCMR1 |= TIM_CCMR1_CC1S_0; TIMX->CCMR1 |= TIM_CCMR1_CC2S_0; //CC2S dans CCMR1 et pas CCMR2 TIMX->CCER &=~TIM_CCER_CC1P; TIMX->CCER &=~TIM_CCER_CC2P; TIMX->CCMR1&=~(0x0F<<4); //IC1F TIMX->CCMR1&=~(0x0F<<12);//IC2F TIMX->CR1 |= 1; } int MyGirouette_Angle(TIM_TypeDef *TIMX) { return (TIMX->CNT)/4; } void MyGirouette_Init_IT_Z(uint8_t GPIO_Pin) { RCC->APB2ENR |=0x01; EXTI->IMR |= (0x01<RTSR|= (0x01<EXTICR[0] &= ~(0x0000000F);// L'interruption « EXTI0 » doit être provoquée par une modification PA0 NVIC->ISER[0] |= (1 << (6 & 0x1F)); // Autorisation de l'interruption « EXTI0 » NUMERO 6, } void EXTI0_IRQHandler(void) { TIM4->CNT=0; EXTI->PR|=0x01; }