Compare commits
No commits in common. "399ce1d9261ecb31faf038cd8cfda3a47aeb5970" and "7d032ee3ce6915df2c092006a5b47d5a3cf365a2" have entirely different histories.
399ce1d926
...
7d032ee3ce
2 changed files with 66 additions and 0 deletions
12
Services/Include/MyTimer.h
Normal file
12
Services/Include/MyTimer.h
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "stm32f10x.h"
|
||||||
|
|
||||||
|
//TIMERS start
|
||||||
|
#define MyTimer_Base_Start(Timer) (Timer->CR1 |= TIM_CR1_CEN)
|
||||||
|
#define MyTimer_Base_Stop(Timer) (Timer -> CR1 =(0x0))
|
||||||
|
// IT
|
||||||
|
extern volatile int g_tick_count; // Declara que a variável existe em outro arquivo
|
||||||
|
void Test(void);
|
||||||
|
void ConfigureIT();
|
||||||
|
// PWM
|
||||||
|
void ConfigurePWM();
|
||||||
|
void ConfigureTimers();
|
||||||
54
Services/Source/MyTimer.c
Normal file
54
Services/Source/MyTimer.c
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
#include <stm32f10x.h>
|
||||||
|
#include "Timer.h"
|
||||||
|
#include "MyTimer.h"
|
||||||
|
#include "PWM.h"
|
||||||
|
#include "DriverGPIO.h"
|
||||||
|
#include "Horloge.h"
|
||||||
|
|
||||||
|
// Constantes
|
||||||
|
#define ARR_TIM1 0xFFAD
|
||||||
|
#define PSC_TIM1 0xFF
|
||||||
|
#define ARR_TIM2 0xFFAD
|
||||||
|
#define PSC_TIM2 0x0225
|
||||||
|
#define ARR_TIM3 0x2CF
|
||||||
|
#define PSC_TIM3 0x0
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
volatile int g_tick_count;
|
||||||
|
|
||||||
|
|
||||||
|
void Test(void) {
|
||||||
|
// Signal
|
||||||
|
g_tick_count++;
|
||||||
|
MyGPIO_Toggle(GPIOA, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
// LES COMMENTAIRES SONT POUR ACTIVER DES TIMERS QUE L'ON UTILISE PAS POUR LE MOMENT
|
||||||
|
void ConfigureTimers() {
|
||||||
|
// Config ARR & PSC
|
||||||
|
//MyTimer_Base_Init(TIM2, ARR_TIM2, PSC_TIM2);
|
||||||
|
//MyTimer_Base_Init(TIM1, ARR_TIM1, PSC_TIM1);
|
||||||
|
//MyTimer_Base_Init(TIM3, ARR_TIM2, PSC_TIM2);
|
||||||
|
//Timer_Init(TIM1, ARR_TIM1, PSC_TIM1);
|
||||||
|
Timer_Init(TIM2, 0, 0);
|
||||||
|
Timer_Init(TIM8, 0, 0);
|
||||||
|
|
||||||
|
// Enable timer clock
|
||||||
|
//EnableTimer(TIM1);
|
||||||
|
//EnableTimer(TIM2);
|
||||||
|
//EnableTimer(TIM3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ConfigureIT() { // Activate general interuption with a function and priority
|
||||||
|
//MyTimer_ActiveIT(TIM2, 4, Test); //start interruption with priority 4
|
||||||
|
//MyTimer_ActiveIT(TIM1, 4, Test); //start interruption with priority 4
|
||||||
|
MyTimer_ActiveIT(TIM3, 4, Test); //start interruption with priority 4
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ConfigurePWM() { // Set dutycycle with timer
|
||||||
|
MyTimer_PWM(TIM8, 2); // Utiliser timer1 avec channel 1
|
||||||
|
//MyTimer_Set_DutyCycle(TIM1, 1, 20.0);
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in a new issue