HAL_ChibiOS: fixed min/max inversion in MCU voltage logging

This commit is contained in:
Andrew Tridgell 2022-03-07 13:41:31 +11:00
parent c7d72821da
commit 93031e297d
1 changed files with 3 additions and 2 deletions

View File

@ -513,8 +513,9 @@ void AnalogIn::_timer_tick(void)
_mcu_temperature = ((110 - 30) / (TS_CAL2 - TS_CAL1)) * (float(buf_adc3[1]) - TS_CAL1) + 30;
_mcu_voltage = 3.3 * VREFINT_CAL / float(buf_adc3[2]+0.001);
_mcu_voltage_min = 3.3 * VREFINT_CAL / float(min_adc3[2]+0.001);
_mcu_voltage_max = 3.3 * VREFINT_CAL / float(max_adc3[2]+0.001);
// note min/max swap due to inversion
_mcu_voltage_min = 3.3 * VREFINT_CAL / float(max_adc3[2]+0.001);
_mcu_voltage_max = 3.3 * VREFINT_CAL / float(min_adc3[2]+0.001);
}
#endif
}