80 lines
1.4 KiB
C
80 lines
1.4 KiB
C
#include "stm32f10x.h"
|
|
#include "GPIO.h"
|
|
#include "TIMER.h"
|
|
#include "MyI2C.h"
|
|
#include "MySPI.h"
|
|
#include "Rouli.h"
|
|
#include "CAP_voilier.h"
|
|
#include <stdio.h>
|
|
|
|
|
|
void Mafonction_IT (void);
|
|
MyGPIO_Struct_TypeDef PA5;
|
|
MyGPIO_Struct_TypeDef PB0;
|
|
MyTimer_Struct_TypeDef timer2,timer3;
|
|
//PA5 LED
|
|
//PC13 Bouton
|
|
char X0,X1,Y0,Y1,Z0,Z1;
|
|
char read_DATA,read_BWR,read_PWRC;
|
|
int16_t gX,gY,gZ;
|
|
int test =0;
|
|
XYZ mesures;
|
|
|
|
int main ( void )
|
|
{
|
|
|
|
|
|
PA5.GPIO=GPIOA;
|
|
PA5.GPIO_Conf=Out_Ppull;
|
|
PA5.GPIO_Pin=5;
|
|
MyGPIO_Init(&PA5);
|
|
timer2.Timer=TIM2;
|
|
timer2.ARR=18000; //pour avoir 250ms
|
|
timer2.PSC=1000;
|
|
MyTimer_Base_Init(&timer2);
|
|
MyTimer_ActiveIT(timer2.Timer,1, &Mafonction_IT);
|
|
MyTimer_Base_Start(timer2.Timer);
|
|
|
|
|
|
PB0.GPIO=GPIOB;
|
|
PB0.GPIO_Conf=AltOut_Ppull;
|
|
PB0.GPIO_Pin=0;
|
|
MyGPIO_Init(&PB0);
|
|
timer3.Timer=TIM3;
|
|
timer3.ARR=14400; //pour avoir 20ms
|
|
timer3.PSC=100;
|
|
MyTimer_Base_Init(&timer3);
|
|
//MyTimer_ActiveIT(timer3.Timer,2, &Mafonction_IT);
|
|
MyTimer_Base_Start(timer3.Timer);
|
|
MyPWM_init(timer3.Timer,3);
|
|
|
|
|
|
MySPI_Init(SPI1);
|
|
rouli_InitAccel();
|
|
MySPI_Send(READ|DATA_FORMAT);
|
|
read_DATA = MySPI_Read();
|
|
MySPI_Send(READ|BW_RATE);
|
|
read_BWR = MySPI_Read();
|
|
MySPI_Send(READ|POWER_CTL);
|
|
read_PWRC = MySPI_Read();
|
|
|
|
while(1)
|
|
{
|
|
rouli_GetAccel(&mesures);
|
|
My_cap();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
void Mafonction_IT (void)
|
|
{
|
|
if((mesures.gY <= (-0.7)) || (mesures.gY >= 0.7))
|
|
{
|
|
MyPWM_Duty(timer3.Timer,3,720);//0.985ms
|
|
test = test+1;
|
|
|
|
}
|
|
|
|
}
|