47 lines
No EOL
1.1 KiB
C
47 lines
No EOL
1.1 KiB
C
#include "MyTimer.h"
|
|
#include "stm32f10x.h"
|
|
#include "Driver_GPIO.h"
|
|
#include "Plateau.h"
|
|
|
|
|
|
/* Permet de diriger le plateau du voilier */
|
|
void Set_Moteur_Plateau(char sens, char vitesse){ // -1 gauche et 1 droite
|
|
/* Declarations */
|
|
char channel;
|
|
MyTimer_Struct_TypeDef TIM;
|
|
MyGPIO_Struct_TypeDef GPIOA5; // pin direction
|
|
MyGPIO_Struct_TypeDef GPIOA6; // pin moteur
|
|
channel =1;
|
|
|
|
/* Configuration du Timer */
|
|
MyTimer_Struct_TypeDef * Data = &TIM;
|
|
Data->Timer = TIM3;
|
|
Data->ARR = 300;
|
|
Data->PSC = 11; // pas sur de la valeur car on veut 20kHz au max
|
|
|
|
Set_Duty_Cycle(Data->Timer, channel, Get_Max_Duty(Data->Timer)*vitesse);
|
|
MyTimer_Base_Init(Data);
|
|
|
|
/* Configuration des GPIOs */
|
|
GPIOA5.GPIO = GPIOA;
|
|
GPIOA5.GPIO_Pin = 5;
|
|
GPIOA5.GPIO_Conf = Out_Ppull;
|
|
|
|
GPIOA6.GPIO = GPIOA;
|
|
GPIOA6.GPIO_Pin = 6;
|
|
GPIOA6.GPIO_Conf = AltOut_Ppull;
|
|
|
|
MyTimer_Base_Start(TIM3);
|
|
MyTimer_PWM(Data->Timer,channel);
|
|
|
|
/* Rotation */
|
|
if (sens == 1){
|
|
MyGPIO_Reset(GPIOA5.GPIO, GPIOA5.GPIO_Pin); // on met à 0
|
|
}
|
|
else {
|
|
MyGPIO_Set(GPIOA5.GPIO, GPIOA5.GPIO_Pin); // on met à 1
|
|
}
|
|
|
|
|
|
|
|
} |