#include "Driver_GPIO.h" #include "Driver_Timer.h" int main (void){ //Déclaration d'une LED et d'un BP par structure GPIO MyGPIO_Struct_TypeDef LED; MyGPIO_Struct_TypeDef BP; //Déclaration d'un Timer 500 ms MyTimer_Struct_TypeDef TIM500ms; //Config LED PA5 LED.GPIO_Conf = Out_Ppull; LED.GPIO_Pin = 5; LED.GPIO = GPIOA; MyGPIO_Init (&LED) ; //Config BP PC13 BP.GPIO_Conf = In_Floating; BP.GPIO_Pin = 13; BP.GPIO = GPIOC; //Init BP & LED MyGPIO_Init (&LED); MyGPIO_Init (&BP); //Init Timer 2 et Test TIM500ms.Timer = TIM2; TIM500ms.PSC = 7200; // =0.5ms(calculé à partir de la fréquence du micro) TIM500ms.ARR = 5000; MyTimer_Base_Init(&TIM500ms); /* TIM2->DIER |= 1<< 0 ; //INTERRUPTION PERIPH //TIM2->DIER |= TIM_DIER_UIE ; NVIC->ISER[0] |= 1<IP[TIM2_IRQn] = 2<< 4 ; */ MyTimer_Base_Start(TIM500ms.Timer); //Boucle infinie de la réponse de la LED à l'état BP MyTimer_PWM(&TIM500ms, 50); while(1){ // if (MyGPIO_Read(BP.GPIO,BP.GPIO_Pin)==0){ // MyGPIO_Set(LED.GPIO,LED.GPIO_Pin); // }else{ // MyGPIO_Reset(LED.GPIO,LED.GPIO_Pin); // } } } /* void TIM2_IRQHandler (void) { MyGPIO_Toggle(GPIOA,5); TIM2->SR &= ~(1<<0); } */