31 行
516 B
C
31 行
516 B
C
#include "Batterie.h"
|
|
#define NULL 0
|
|
|
|
|
|
|
|
|
|
/* Delarations */
|
|
MyGPIO_Struct_TypeDef GPIOC0; /* Les pins sont a remappés */
|
|
int nivBatterie = 0;
|
|
|
|
void Init_Batterie (void){
|
|
|
|
/* Configuration des GPIOs */
|
|
GPIOC0.GPIO = GPIOC;
|
|
GPIOC0.GPIO_Pin = 0;
|
|
GPIOC0.GPIO_Conf = In_Analog;
|
|
MyGPIO_Init(&GPIOC0);
|
|
|
|
/* On configure l'ADC */
|
|
initADC(10);
|
|
startADC();
|
|
}
|
|
|
|
|
|
int Get_Batterie (void){
|
|
|
|
nivBatterie = read(); // sur 12 bits
|
|
nivBatterie *= 100;
|
|
return (nivBatterie / 4095); // pour avoir le niveau sur 100%
|
|
|
|
}
|