Compare commits
No commits in common. "7e6eb879f1193ba980a821d6f344c9ad49baf2ee" and "f24d419c1b7ed0ec7c983642792b698bea837d30" have entirely different histories.
7e6eb879f1
...
f24d419c1b
6 changed files with 13 additions and 86 deletions
|
|
@ -1,12 +1,11 @@
|
||||||
#include "IncrementalEncoder.h"
|
#include "IncrementalEncoder.h"
|
||||||
|
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "GPIO.h"
|
|
||||||
|
|
||||||
void IncrementalEncoder_conf(TIM_TypeDef * timer, GPIO_TypeDef * gpio, int pin)
|
void IncrementalEncoder_conf(TIM_TypeDef * timer)
|
||||||
{
|
{
|
||||||
Timer_encoder_conf(timer);
|
Timer_encoder_conf(timer);
|
||||||
GPIO_conf(gpio, pin, LL_GPIO_MODE_INPUT, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_UP);
|
// TODO GPIO config
|
||||||
}
|
}
|
||||||
|
|
||||||
void IncrementalEncoder_start(TIM_TypeDef * timer)
|
void IncrementalEncoder_start(TIM_TypeDef * timer)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
* @param TIM_TypeDef Timer : indique le timer à utiliser : TIM1, TIM2, TIM3 ou TIM4
|
* @param TIM_TypeDef Timer : indique le timer à utiliser : TIM1, TIM2, TIM3 ou TIM4
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void IncrementalEncoder_conf(TIM_TypeDef * timer, GPIO_TypeDef * gpio, int pin);
|
void IncrementalEncoder_conf(TIM_TypeDef * timer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Démarre le codeur incrémental associé au timer donné
|
* @brief Démarre le codeur incrémental associé au timer donné
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
#include "Scheduler.h"
|
|
||||||
#include "Timer.h"
|
|
||||||
#include "stm32f1xx_ll_utils.h"
|
|
||||||
|
|
||||||
void (*it_callback_SysTick)(void);
|
|
||||||
|
|
||||||
void SysTick_Handler(void)
|
|
||||||
{
|
|
||||||
(*it_callback_SysTick)();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scheduler_conf(void (*it_callback) (void))
|
|
||||||
{
|
|
||||||
it_callback_SysTick = it_callback;
|
|
||||||
LL_Init1msTick(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scheduler_start(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
#ifndef SCHEDULER_H
|
|
||||||
#define SCHEDULER_H
|
|
||||||
|
|
||||||
#include "stm32f103xb.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure l'horloge interne comme ordonanceur
|
|
||||||
* @note
|
|
||||||
* @param (void)* it_callback : Tache de fond à executer
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void Scheduler_conf(void (*it_callback) (void));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Démarre ordonanceur
|
|
||||||
* @note
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void Scheduler_start(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
19
Src/Sail.c
19
Src/Sail.c
|
|
@ -1,20 +1,14 @@
|
||||||
#include "Sail.h"
|
#include "Sail.h"
|
||||||
#include "ServoMotor.h"
|
#include "ServoMotor.h"
|
||||||
#include "IncrementalEncoder.h"
|
|
||||||
|
|
||||||
TIM_TypeDef * MOTOR_TIMER = TIM4;
|
TIM_TypeDef * SAIL_TIMER = TIM4;
|
||||||
const int MOTOR_CHANNEL = LL_TIM_CHANNEL_CH3;
|
const int SAIL_CHANNEL = LL_TIM_CHANNEL_CH3;
|
||||||
GPIO_TypeDef * MOTOR_GPIO = GPIOB;
|
GPIO_TypeDef * SAIL_GPIO = GPIOB;
|
||||||
const int MOTOR_PIN = LL_GPIO_PIN_8;
|
const int SAIL_PIN = LL_GPIO_PIN_8;
|
||||||
|
|
||||||
TIM_TypeDef * ENCODER_TIMER = TIM3;
|
|
||||||
GPIO_TypeDef * ENCODER_GPIO = GPIOA;
|
|
||||||
const int ENCODER_PIN = LL_GPIO_PIN_5;
|
|
||||||
|
|
||||||
void Sail_conf()
|
void Sail_conf()
|
||||||
{
|
{
|
||||||
ServoMotor_conf(MOTOR_TIMER, MOTOR_CHANNEL, MOTOR_GPIO, MOTOR_PIN);
|
ServoMotor_conf(SAIL_TIMER, SAIL_CHANNEL, SAIL_GPIO, SAIL_PIN);
|
||||||
IncrementalEncoder_conf(ENCODER_TIMER, ENCODER_GPIO, ENCODER_PIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sail_background()
|
void Sail_background()
|
||||||
|
|
@ -30,6 +24,5 @@ void Sail_reset()
|
||||||
|
|
||||||
void Sail_start()
|
void Sail_start()
|
||||||
{
|
{
|
||||||
Timer_start(MOTOR_TIMER);
|
Timer_start(SAIL_TIMER);
|
||||||
Timer_start(ENCODER_TIMER);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
28
Src/main.c
28
Src/main.c
|
|
@ -21,36 +21,17 @@
|
||||||
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
||||||
|
|
||||||
#include "Sail.h"
|
#include "Sail.h"
|
||||||
#include "Scheduler.h"
|
|
||||||
|
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
|
||||||
int counter = 1;
|
|
||||||
|
|
||||||
void backgroundTask()
|
|
||||||
{
|
|
||||||
counter++;
|
|
||||||
Sail_background();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void configurePeripherals()
|
|
||||||
{
|
|
||||||
Sail_conf();
|
|
||||||
}
|
|
||||||
|
|
||||||
void startPeripherals()
|
|
||||||
{
|
|
||||||
Sail_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Main program
|
* @brief Main program
|
||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* Configure the system clock to 72 MHz */
|
/* Configure the system clock to 72 MHz */
|
||||||
|
|
@ -62,12 +43,9 @@ int main(void)
|
||||||
// Lancement chronomètre
|
// Lancement chronomètre
|
||||||
// Chrono_Start();
|
// Chrono_Start();
|
||||||
// time = Chrono_Read();
|
// time = Chrono_Read();
|
||||||
configurePeripherals();
|
|
||||||
startPeripherals();
|
|
||||||
|
|
||||||
Scheduler_conf(backgroundTask);
|
|
||||||
Scheduler_start();
|
|
||||||
|
|
||||||
|
Sail_conf();
|
||||||
|
Sail_start();
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue