#include #include #include #include #include int a; void MyBatterie_Init(void){ MyGPIO_Init(GPIOC,4,In_Floating); // Init PORT pour recevoir tension MyADC_Init(ADC1,14); // Init ADC pour convertir valeur My_USART_Init(USART2); // Init USART pour envoyer batterie MyGPIO_Init(GPIOA,2,AltOut_Ppull); // Init PORT pour envoyer pourcentage batterie MyADC_ActiveIT(ADC1,15,&handler_ADC); // Init interruption quand conversion finie } void handler_ADC (void){ a = ADC1->DR &~ (0xF << 12); // Retourne valeur numérique send_USART(USART2,a*13*100/12); // Envoie la valeur numérique*13 send_USART(USART2,'%'); start_conversion(ADC1); // Recommence la conversion pour le prochain }