22 lines
No EOL
737 B
C
22 lines
No EOL
737 B
C
#include <stm32f10x.h>
|
|
#include <Batterie.h>
|
|
#include <GPIO.h>
|
|
#include <ADC.h>
|
|
#include <USART.h>
|
|
|
|
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
|
|
} |