mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Avoid recalculation of adc vrefmv, add vrevfmv to ADC_INTERNAL debug
mode.
This commit is contained in:
parent
b5a6b543a9
commit
74638da93e
1 changed files with 6 additions and 2 deletions
|
@ -57,13 +57,14 @@ static uint16_t adcTempsensorValues[8];
|
||||||
movingAverageStateUint16_t adcTempsensorAverageState = { 0, adcTempsensorValues, 8, 0 } ;
|
movingAverageStateUint16_t adcTempsensorAverageState = { 0, adcTempsensorValues, 8, 0 } ;
|
||||||
|
|
||||||
static int16_t coreTemperature;
|
static int16_t coreTemperature;
|
||||||
|
static uint16_t vrefMv;
|
||||||
|
|
||||||
uint16_t getVrefMv(void)
|
uint16_t getVrefMv(void)
|
||||||
{
|
{
|
||||||
#ifdef ADC_VOLTAGE_REFERENCE_MV
|
#ifdef ADC_VOLTAGE_REFERENCE_MV
|
||||||
return ADC_VOLTAGE_REFERENCE_MV;
|
return ADC_VOLTAGE_REFERENCE_MV;
|
||||||
#else
|
#else
|
||||||
return 3300 * adcVrefintValue / adcVREFINTCAL;
|
return vrefMv;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,12 +87,15 @@ void adcInternalProcess(timeUs_t currentTimeUs)
|
||||||
adcVrefintValue = updateMovingAverageUint16(&adcVrefintAverageState, vrefintSample);
|
adcVrefintValue = updateMovingAverageUint16(&adcVrefintAverageState, vrefintSample);
|
||||||
adcTempsensorValue = updateMovingAverageUint16(&adcTempsensorAverageState, tempsensorSample);
|
adcTempsensorValue = updateMovingAverageUint16(&adcTempsensorAverageState, tempsensorSample);
|
||||||
|
|
||||||
int32_t adcTempsensorAdjusted = (int32_t)adcTempsensorValue * 3300 / getVrefMv();
|
vrefMv = 3300 * adcVrefintValue / adcVREFINTCAL;
|
||||||
|
|
||||||
|
int32_t adcTempsensorAdjusted = (int32_t)(adcTempsensorValue * 3300) / vrefMv;
|
||||||
coreTemperature = ((adcTempsensorAdjusted - adcTSCAL1) * adcTSSlopeK + 30 * 1000 + 500) / 1000;
|
coreTemperature = ((adcTempsensorAdjusted - adcTSCAL1) * adcTSSlopeK + 30 * 1000 + 500) / 1000;
|
||||||
|
|
||||||
DEBUG_SET(DEBUG_ADC_INTERNAL, 0, coreTemperature);
|
DEBUG_SET(DEBUG_ADC_INTERNAL, 0, coreTemperature);
|
||||||
DEBUG_SET(DEBUG_ADC_INTERNAL, 1, vrefintSample);
|
DEBUG_SET(DEBUG_ADC_INTERNAL, 1, vrefintSample);
|
||||||
DEBUG_SET(DEBUG_ADC_INTERNAL, 2, tempsensorSample);
|
DEBUG_SET(DEBUG_ADC_INTERNAL, 2, tempsensorSample);
|
||||||
|
DEBUG_SET(DEBUG_ADC_INTERNAL, 3, vrefMv);
|
||||||
|
|
||||||
adcInternalStartConversion(); // Start next conversion
|
adcInternalStartConversion(); // Start next conversion
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue