22 lines
482 B
C
22 lines
482 B
C
#include "Voltage.h"
|
|
|
|
|
|
void Voltage_conf(ADC_TypeDef * adc, GPIO_TypeDef * gpio, int pin)
|
|
{
|
|
//On configure le pin qui recevra le signal, ici PC2
|
|
GPIO_conf(gpio, pin, LL_GPIO_MODE_ANALOG, 0, 0);
|
|
|
|
//On configure l'ADC
|
|
ADC_conf(adc);
|
|
}
|
|
|
|
void Voltage_start(ADC_TypeDef * adc)
|
|
{
|
|
ADC_start(adc);
|
|
}
|
|
|
|
float Voltage_getVoltage(ADC_TypeDef * adc, int channel)
|
|
{
|
|
// 13 * la valeur de l'ADC, car pont diviseur de tension en amont de l'ADC
|
|
return 13.0f * ADC_readVolt(adc, channel);
|
|
}
|