add basic .c
This commit is contained in:
parent
f021d56c0c
commit
6497b71a60
15 changed files with 197 additions and 0 deletions
1
MyDrivers/ADC.c
Normal file
1
MyDrivers/ADC.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "ADC.h"
|
2
MyDrivers/GPIO.c
Normal file
2
MyDrivers/GPIO.c
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#include "GPIO.h"
|
||||||
|
|
182
MyDrivers/Timer.c
Normal file
182
MyDrivers/Timer.c
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
// TOUT A FAIRE !! //
|
||||||
|
|
||||||
|
/*
|
||||||
|
indispensable pour pouvoir adresser les registres des périphériques.
|
||||||
|
Rem : OBLIGATION d'utiliser les définitions utiles contenues dans ce fichier (ex : TIM_CR1_CEN, RCC_APB1ENR_TIM2EN ...)
|
||||||
|
pour une meilleure lisibilité du code.
|
||||||
|
|
||||||
|
Pour les masques, utiliser également les définitions proposée
|
||||||
|
Rappel : pour mettre à 1 , reg = reg | Mask (ou Mask est le représente le ou les bits à positionner à 1)
|
||||||
|
pour mettre à 0 , reg = reg&~ Mask (ou Mask est le représente le ou les bits à positionner à 0)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Timer.h"
|
||||||
|
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
|
||||||
|
#include "stm32f1xx_ll_tim.h"
|
||||||
|
|
||||||
|
|
||||||
|
// variable pointeur de fonction permettant de mémoriser le callback à appeler depuis
|
||||||
|
// le handler d'IT
|
||||||
|
void (*Ptr_ItFct_TIM1)(void);
|
||||||
|
void (*Ptr_ItFct_TIM2)(void);
|
||||||
|
void (*Ptr_ItFct_TIM3)(void);
|
||||||
|
void (*Ptr_ItFct_TIM4)(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Active l'horloge et règle l'ARR et le PSC du timer visé
|
||||||
|
* @note Fonction à lancer avant toute autre. Le timer n'est pas encore lancé (voir MyTimerStart)
|
||||||
|
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
|
||||||
|
* int Arr : valeur à placer dans ARR
|
||||||
|
* int Psc : valeur à placer dans PSC
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void MyTimer_Conf(TIM_TypeDef * Timer,int Arr, int Psc)
|
||||||
|
{
|
||||||
|
LL_TIM_InitTypeDef My_LL_Tim_Init_Struct;
|
||||||
|
|
||||||
|
// Validation horloge locale
|
||||||
|
if (Timer==TIM1) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_TIM1);
|
||||||
|
else if (Timer==TIM2) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
|
||||||
|
else if (Timer==TIM3) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
|
||||||
|
else LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4);
|
||||||
|
|
||||||
|
// chargement structure Arr, Psc, Up Count
|
||||||
|
My_LL_Tim_Init_Struct.Autoreload=Arr;
|
||||||
|
My_LL_Tim_Init_Struct.Prescaler=Psc;
|
||||||
|
My_LL_Tim_Init_Struct.ClockDivision=LL_TIM_CLOCKDIVISION_DIV1;
|
||||||
|
My_LL_Tim_Init_Struct.CounterMode=LL_TIM_COUNTERMODE_UP;
|
||||||
|
My_LL_Tim_Init_Struct.RepetitionCounter=0;
|
||||||
|
|
||||||
|
LL_TIM_Init(Timer,&My_LL_Tim_Init_Struct);
|
||||||
|
|
||||||
|
|
||||||
|
// Blocage IT
|
||||||
|
LL_TIM_DisableIT_UPDATE(Timer);
|
||||||
|
|
||||||
|
|
||||||
|
// Blocage Timer
|
||||||
|
LL_TIM_DisableCounter(Timer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Démarre le timer considéré
|
||||||
|
* @note
|
||||||
|
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void MyTimer_Start(TIM_TypeDef * Timer)
|
||||||
|
{
|
||||||
|
LL_TIM_EnableCounter(Timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Arrêt le timer considéré
|
||||||
|
* @note
|
||||||
|
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void MyTimer_Stop(TIM_TypeDef * Timer)
|
||||||
|
{
|
||||||
|
LL_TIM_DisableCounter(Timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure le Timer considéré en interruption sur débordement.
|
||||||
|
* @note A ce stade, les interruptions ne sont pas validés (voir MyTimer_IT_Enable )
|
||||||
|
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
|
||||||
|
* void (*IT_function) (void) : nom (adresse) de la fonction à lancer sur interruption
|
||||||
|
* int Prio : priorité associée à l'interruption
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void MyTimer_IT_Conf(TIM_TypeDef * Timer, void (*IT_function) (void),int Prio)
|
||||||
|
{
|
||||||
|
// affectation de la fonction
|
||||||
|
if (Timer==TIM1) Ptr_ItFct_TIM1=IT_function;
|
||||||
|
else if (Timer==TIM2) Ptr_ItFct_TIM2=IT_function;
|
||||||
|
else if (Timer==TIM3) Ptr_ItFct_TIM3=IT_function;
|
||||||
|
else Ptr_ItFct_TIM4=IT_function;
|
||||||
|
|
||||||
|
|
||||||
|
// Blocage IT (il faudra la débloquer voir fct suivante)
|
||||||
|
LL_TIM_DisableIT_UPDATE(Timer);
|
||||||
|
|
||||||
|
// validation du canal NVIC
|
||||||
|
IRQn_Type TIM_irq;
|
||||||
|
|
||||||
|
if (Timer==TIM1) TIM_irq=TIM1_UP_IRQn;
|
||||||
|
else if (Timer==TIM2) TIM_irq=TIM2_IRQn;
|
||||||
|
else if (Timer==TIM3) TIM_irq=TIM3_IRQn;
|
||||||
|
else TIM_irq=TIM4_IRQn;
|
||||||
|
|
||||||
|
NVIC_SetPriority(TIM_irq, Prio);
|
||||||
|
NVIC_EnableIRQ(TIM_irq);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Autorise les interruptions
|
||||||
|
* @note
|
||||||
|
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void MyTimer_IT_Enable(TIM_TypeDef * Timer)
|
||||||
|
{
|
||||||
|
LL_TIM_EnableIT_UPDATE(Timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Interdit les interruptions
|
||||||
|
* @note
|
||||||
|
* @param TIM_TypeDef Timer : indique le timer à utiliser par le chronomètre, TIM1, TIM2, TIM3 ou TIM4
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void MyTimer_IT_Disable(TIM_TypeDef * Timer)
|
||||||
|
{
|
||||||
|
LL_TIM_DisableIT_UPDATE(Timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
============ LES INTERRUPTIONS =================================
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
void TIM1_UP_IRQHandler(void)
|
||||||
|
{
|
||||||
|
// rabaisser le flag d'IT
|
||||||
|
LL_TIM_ClearFlag_UPDATE(TIM1);
|
||||||
|
(*Ptr_ItFct_TIM1)();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TIM2_IRQHandler(void)
|
||||||
|
{
|
||||||
|
// rabaisser le flag d'IT
|
||||||
|
LL_TIM_ClearFlag_UPDATE(TIM2);
|
||||||
|
(*Ptr_ItFct_TIM2)();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TIM3_IRQHandler(void)
|
||||||
|
{
|
||||||
|
// rabaisser le flag d'IT
|
||||||
|
LL_TIM_ClearFlag_UPDATE(TIM3);
|
||||||
|
(*Ptr_ItFct_TIM3)();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TIM4_IRQHandler(void)
|
||||||
|
{
|
||||||
|
// rabaisser le flag d'IT
|
||||||
|
LL_TIM_ClearFlag_UPDATE(TIM4);
|
||||||
|
(*Ptr_ItFct_TIM4)();
|
||||||
|
}
|
1
MyDrivers/USART.c
Normal file
1
MyDrivers/USART.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "USART.h"
|
1
Services/Accelerometer.c
Normal file
1
Services/Accelerometer.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "Accelerometer.h"
|
1
Services/DCMotor.c
Normal file
1
Services/DCMotor.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "DCMotor.h"
|
1
Services/IncrementalEncoder.c
Normal file
1
Services/IncrementalEncoder.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "IncrementalEncoder.h"
|
1
Services/RFEmitter.c
Normal file
1
Services/RFEmitter.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "RFEmitter.h"
|
1
Services/RFReceiver.c
Normal file
1
Services/RFReceiver.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "RFReceiver.h"
|
1
Services/ServoMotor.c
Normal file
1
Services/ServoMotor.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "ServoMotor.h"
|
1
Services/Voltage.c
Normal file
1
Services/Voltage.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "Voltage.h"
|
1
Src/Display.c
Normal file
1
Src/Display.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "Display.h"
|
1
Src/Orientation.c
Normal file
1
Src/Orientation.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "Orientation.h"
|
1
Src/Roll.c
Normal file
1
Src/Roll.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "Roll.h"
|
1
Src/Sail.c
Normal file
1
Src/Sail.c
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "Sail.h"
|
Loading…
Reference in a new issue