40 lines
879 B
C
40 lines
879 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)
|
|
{
|
|
MyGPIO_Struct_TypeDef MyGPIO={GPIOB,3,In_PullDown};
|
|
|
|
MyGPIO_Init(&MyGPIO);
|
|
MyGPIO.GPIO_Pin=4;
|
|
MyGPIO_Init(&MyGPIO);
|
|
//inturutpion sur rise de gbpiob 3 avec appelle de Girouette_Angle
|
|
MyTimer_Struct_Typedef MyTimerGirouette ={TIM4,72,1};//500kHZ
|
|
MyTimer_Base_Init(&MyTimerGirouette);
|
|
MyTimer_ActiveIT(TIM4,4,Girouette_Angle);//changer prio
|
|
|
|
while(1){};
|
|
}
|
|
|
|
|
|
void Girouette_Angle(void)
|
|
{
|
|
if ( ( Angle_Girouette==360 )||( Angle_Girouette==-360) )
|
|
{
|
|
Angle_Girouette=0;
|
|
}
|
|
if(MyGPIO_Read(GPIOB,4))
|
|
{
|
|
Angle_Girouette =Angle_Girouette-1/4;
|
|
}else{
|
|
Angle_Girouette =Angle_Girouette+1/4;
|
|
}
|
|
//print(Angle_Girouette);//a suppr apr test
|
|
}
|
|
|