37 lines
717 B
C
37 lines
717 B
C
#include "MyGirouette.h"
|
|
#include "Driver_GPIO.h"
|
|
#include "MyTimer.h"
|
|
void Init_Girouette(void){
|
|
|
|
MyGPIO_Struct_TypeDef GPIOA0={
|
|
GPIOA,
|
|
0,
|
|
In_Floating
|
|
};
|
|
MyGPIO_Struct_TypeDef GPIOA1={
|
|
GPIOA,
|
|
1,
|
|
In_Floating
|
|
};
|
|
|
|
// Configuration du timer
|
|
MyTimer_Struct_TypeDef TIM;
|
|
TIM.Timer = TIM2;
|
|
TIM.ARR = 360*2;
|
|
TIM.PSC = 0;
|
|
|
|
MyTimer_Base_Init(&TIM);
|
|
|
|
TIM2->CCMR1 |= 0x1 << 0; //CH1
|
|
TIM2->CCMR1 |= 0x1 << 8; //CH2
|
|
|
|
TIM2->SMCR |= 0x1 << 0; // Capture Mode : 1 => seulement les fronts montants 2 => seulement les fronts descendants 3 => les 2
|
|
//TIM2->CCMR1 |= 0x1 << 2;
|
|
|
|
MyGPIO_Init(&GPIOA0);
|
|
MyGPIO_Init(&GPIOA1);
|
|
|
|
MyTimer_Base_Start(TIM2);
|
|
}
|
|
|
|
uint16_t Get_Angle(void){return (TIM2 -> CNT)/2;}
|