1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-994 Add an API to PIOS_ADC to get directly the Voltage value

This commit is contained in:
Alessio Morale 2013-05-27 01:34:55 +02:00
parent 6671a404ca
commit 51a7f27b99
4 changed files with 11 additions and 2 deletions

View File

@ -471,8 +471,8 @@ static void updateStats()
lastTickCount = now;
idleCounterClear = 1;
#if defined(PIOS_INCLUDE_ADC) && defined(PIOS_ADC_USE_TEMP_SENSOR)
float temp_voltage = PIOS_ADC_VOLTAGE_SCALE * PIOS_ADC_PinGet(PIOS_ADC_TEMPERATURE_PIN);
stats.CPUTemp = (temp_voltage-PIOS_ADC_STM32_TEMP_V25) * 1000.0f / PIOS_ADC_STM32_TEMP_AVG_SLOPE + 25.0f;
float temp_voltage = PIOS_ADC_PinGetVolt(PIOS_ADC_TEMPERATURE_PIN);
stats.CPUTemp = (temp_voltage - PIOS_ADC_STM32_TEMP_V25) * 1000.0f / PIOS_ADC_STM32_TEMP_AVG_SLOPE + 25.0f;
#endif
SystemStatsSet(&stats);
}

View File

@ -39,6 +39,7 @@ typedef void (*ADCCallback)(float *data);
/* Public Functions */
void PIOS_ADC_Config(uint32_t oversampling);
int32_t PIOS_ADC_PinGet(uint32_t pin);
float PIOS_ADC_PinGetVolt(uint32_t pin);
int16_t *PIOS_ADC_GetRawBuffer(void);
uint8_t PIOS_ADC_GetOverSampling(void);
void PIOS_ADC_SetCallback(ADCCallback new_function);

View File

@ -57,6 +57,10 @@ struct pios_adc_dev {
enum pios_adc_dev_magic magic;
};
float PIOS_ADC_PinGetVolt(uint32_t pin){
return ((float)PIOS_ADC_PinGet(pin)) * PIOS_ADC_VOLTAGE_SCALE;
}
#if defined(PIOS_INCLUDE_FREERTOS)
struct pios_adc_dev *pios_adc_dev;
#endif

View File

@ -325,6 +325,10 @@ int32_t PIOS_ADC_PinGet(uint32_t pin)
return -1;
}
float PIOS_ADC_PinGetVolt(uint32_t pin){
return ((float)PIOS_ADC_PinGet(pin)) * PIOS_ADC_VOLTAGE_SCALE;
}
/**
* @brief Set a callback function that is executed whenever
* the ADC double buffer swaps