43 lines
1,001 B
C
Executable file
43 lines
1,001 B
C
Executable file
#include "stm32f10x.h"
|
|
#include <stdio.h> // Pour print
|
|
#include "MyTimer.h"
|
|
#include "Nucleo.h"
|
|
#include "Girouette.h"
|
|
#include "DriverGPIO.h"
|
|
|
|
int test=0;
|
|
volatile int angleVent;
|
|
volatile int angleVoile;
|
|
int main ( void ){
|
|
|
|
// ---- Setup ------
|
|
//Nucleo.c
|
|
ConfigHorloge();
|
|
//ConfigBroche();
|
|
//MyTimer.c
|
|
ConfigureTimers();
|
|
//ConfigureIT();
|
|
//PWM.
|
|
ConfigurePWM();
|
|
// Giroutte.c
|
|
configEncoder(TIM2);
|
|
configChannel();
|
|
|
|
//MyTimer_Base_Start (TIM2);
|
|
//MyTimer_Base_Start (TIM1);
|
|
//MyTimer_Base_Start (TIM3);
|
|
|
|
// ----- Opération -----
|
|
while (1){
|
|
if(MyGPIO_Read(GPIOA,8)){ // Index
|
|
TIM2 -> CNT = 0x0; // Remet angle à zero
|
|
}
|
|
angleVent = returnAngle(TIM2); // Récupérer l'angle de girouette
|
|
angleVoile = vent2voile(angleVent); // Transformer l'angle de girouette au l'angle des voiles souhaités
|
|
Servo_Moteur(angleVoile, TIM1, 1); // Faire bouger le moteur servo
|
|
|
|
//printf("L'angle est %d ", returnAngle(TIM2));
|
|
|
|
|
|
}
|
|
};
|