Projet_Voilier/ProjetsKEIL/Drivers/Driver_timers.c
2023-03-21 16:28:46 +01:00

29 lines
No EOL
590 B
C

#include "Driver_timers.h"
void timer_init(MyTimer_Struct_TypeDef * Timer){
if(Timer->Timer == TIM1){
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
}
if(Timer->Timer == TIM2){
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
}
if(Timer->Timer == TIM3){
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
}
if(Timer->Timer == TIM4){
RCC->APB1ENR |= RCC_APB1ENR_TIM4EN;
}
}
void MyTimer_Start(MyTimer_Struct_TypeDef *Timer)
{
Timer->Timer->CR1 |= TIM_CR1_CEN; // Démarre le Timer
}
void MyTimer_Stop(MyTimer_Struct_TypeDef *Timer)
{
Timer->Timer->CR1 &= ~TIM_CR1_CEN; // Arrête le Timer
}