TP_microcontroleur/timer_act2/Source/principal.c
2021-09-24 18:38:27 +02:00

41 lines
720 B
C

#include "stm32f10x.h"
#include "Driver_GPIO.h"
#include "Driver_TIMER.h"
MyTimer_Struct_TypeDef MonTimer ;
MyGPIO_Struct_TypeDef greenLed ;
void handle_TIM2(void) {
MyGPIO_Toggle(greenLed.GPIO, greenLed.GPIO_Pin);
}
int main(void) {
Activate_TIM(2);
MyGPIO_Activate(1);
greenLed.GPIO = GPIOA;
greenLed.GPIO_Pin = 5 ;
greenLed.GPIO_Conf = Out_Ppull ;
MyGPIO_Init(&greenLed);
MonTimer.Timer = TIM2 ;
//méthode PGCD
//MonTimer.ARR = 65454;
//MonTimer.PSC = 550 ;
MonTimer.ARR = 18000;
MonTimer.PSC = 2000 ;
MyTimer_Base_Init(&MonTimer);
MyGPIO_Set(greenLed.GPIO,greenLed.GPIO_Pin);
MyTimer_Active_IT(TIM2, 1, handle_TIM2);
MyTimer_Base_Start(MonTimer.Timer);
while(1) {}
return 0;
}