38 lines
866 B
C
38 lines
866 B
C
#include "stm32f10x.h"
|
|
#include "../../driver/MyI2C.h"
|
|
#include "../../driver/MySPI.h"
|
|
#include "../../driver/timer.h"
|
|
#include "../../driver/gpio.h"
|
|
|
|
void Girouette_Angle(void);
|
|
int Angle_Girouette=0;
|
|
|
|
int main (void)
|
|
{
|
|
//configuration gpiob6 et gpiob7 en entrées pull up
|
|
MyGPIO_Struct_TypeDef MyGPIO={GPIOB,6,In_PullUp};
|
|
MyGPIO_Init(&MyGPIO);
|
|
MyGPIO.GPIO_Pin=7;
|
|
MyGPIO_Init(&MyGPIO);
|
|
//configuration TIM4 reset a 360
|
|
MyTimer_Struct_Typedef MyTimerGirouette ={TIM4,359,1};
|
|
MyTimer_Base_Init(&MyTimerGirouette);
|
|
TIM4->SMCR &=~0x07;
|
|
TIM4->SMCR |=~0x011;
|
|
TIM4->CCMR1 |= TIM_CCMR1_CC1S_0;
|
|
TIM4->CCMR1 |= TIM_CCMR1_CC2S_0;
|
|
TIM4->CCER &=~TIM_CCER_CC1P;
|
|
TIM4->CCER &=~TIM_CCER_CC1NP;
|
|
TIM4->CCER &=~TIM_CCER_CC2P;
|
|
TIM4->CCER &=~TIM_CCER_CC2NP;
|
|
TIM4->CCMR1&=~TIM_CCER_IC1F;
|
|
TIM1->CR1 |= 1;
|
|
Angle_Girouette=TIM4->CNT;
|
|
|
|
|
|
|
|
while(1){};
|
|
}
|
|
|
|
|
|
|