Compare commits
3 commits
f24d419c1b
...
7e6eb879f1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e6eb879f1 | ||
|
|
cdcf3a2f9d | ||
|
|
6ded190d3d |
6 changed files with 86 additions and 13 deletions
|
|
@ -1,11 +1,12 @@
|
|||
#include "IncrementalEncoder.h"
|
||||
|
||||
#include "Timer.h"
|
||||
#include "GPIO.h"
|
||||
|
||||
void IncrementalEncoder_conf(TIM_TypeDef * timer)
|
||||
void IncrementalEncoder_conf(TIM_TypeDef * timer, GPIO_TypeDef * gpio, int pin)
|
||||
{
|
||||
Timer_encoder_conf(timer);
|
||||
// TODO GPIO config
|
||||
GPIO_conf(gpio, pin, LL_GPIO_MODE_INPUT, LL_GPIO_OUTPUT_PUSHPULL, LL_GPIO_PULL_UP);
|
||||
}
|
||||
|
||||
void IncrementalEncoder_start(TIM_TypeDef * timer)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* @param TIM_TypeDef Timer : indique le timer à utiliser : TIM1, TIM2, TIM3 ou TIM4
|
||||
* @retval None
|
||||
*/
|
||||
void IncrementalEncoder_conf(TIM_TypeDef * timer);
|
||||
void IncrementalEncoder_conf(TIM_TypeDef * timer, GPIO_TypeDef * gpio, int pin);
|
||||
|
||||
/**
|
||||
* @brief Démarre le codeur incrémental associé au timer donné
|
||||
|
|
|
|||
21
Services/Scheduler.c
Normal file
21
Services/Scheduler.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#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)
|
||||
{
|
||||
|
||||
}
|
||||
22
Services/Scheduler.h
Normal file
22
Services/Scheduler.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#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,14 +1,20 @@
|
|||
#include "Sail.h"
|
||||
#include "ServoMotor.h"
|
||||
#include "IncrementalEncoder.h"
|
||||
|
||||
TIM_TypeDef * SAIL_TIMER = TIM4;
|
||||
const int SAIL_CHANNEL = LL_TIM_CHANNEL_CH3;
|
||||
GPIO_TypeDef * SAIL_GPIO = GPIOB;
|
||||
const int SAIL_PIN = LL_GPIO_PIN_8;
|
||||
TIM_TypeDef * MOTOR_TIMER = TIM4;
|
||||
const int MOTOR_CHANNEL = LL_TIM_CHANNEL_CH3;
|
||||
GPIO_TypeDef * MOTOR_GPIO = GPIOB;
|
||||
const int MOTOR_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()
|
||||
{
|
||||
ServoMotor_conf(SAIL_TIMER, SAIL_CHANNEL, SAIL_GPIO, SAIL_PIN);
|
||||
ServoMotor_conf(MOTOR_TIMER, MOTOR_CHANNEL, MOTOR_GPIO, MOTOR_PIN);
|
||||
IncrementalEncoder_conf(ENCODER_TIMER, ENCODER_GPIO, ENCODER_PIN);
|
||||
}
|
||||
|
||||
void Sail_background()
|
||||
|
|
@ -24,5 +30,6 @@ void Sail_reset()
|
|||
|
||||
void Sail_start()
|
||||
{
|
||||
Timer_start(SAIL_TIMER);
|
||||
Timer_start(MOTOR_TIMER);
|
||||
Timer_start(ENCODER_TIMER);
|
||||
}
|
||||
|
|
|
|||
28
Src/main.c
28
Src/main.c
|
|
@ -21,17 +21,36 @@
|
|||
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
||||
|
||||
#include "Sail.h"
|
||||
#include "Scheduler.h"
|
||||
|
||||
void SystemClock_Config(void);
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
int counter = 1;
|
||||
|
||||
void backgroundTask()
|
||||
{
|
||||
counter++;
|
||||
Sail_background();
|
||||
}
|
||||
|
||||
|
||||
void configurePeripherals()
|
||||
{
|
||||
Sail_conf();
|
||||
}
|
||||
|
||||
void startPeripherals()
|
||||
{
|
||||
Sail_start();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main program
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* Configure the system clock to 72 MHz */
|
||||
|
|
@ -43,9 +62,12 @@ int main(void)
|
|||
// Lancement chronomètre
|
||||
// Chrono_Start();
|
||||
// time = Chrono_Read();
|
||||
configurePeripherals();
|
||||
startPeripherals();
|
||||
|
||||
Scheduler_conf(backgroundTask);
|
||||
Scheduler_start();
|
||||
|
||||
Sail_conf();
|
||||
Sail_start();
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue