Commit 91fc4a9c authored by Damien George's avatar Damien George
Browse files

stmhal: Fix ADC multiplier from 4096 to 4095; optimise fp operation.

parent 99bcaa2f
......@@ -353,7 +353,8 @@ float adc_read_core_vbat(ADC_HandleTypeDef *adcHandle) {
// be 12-bits.
raw_value <<= (12 - adc_get_resolution(adcHandle));
return raw_value * VBAT_DIV / 4096.0f * 3.3f;
// multiplier is 3.3/4095
return raw_value * VBAT_DIV * 0.8058608058608059e-3f;
}
float adc_read_core_vref(ADC_HandleTypeDef *adcHandle) {
......@@ -363,7 +364,8 @@ float adc_read_core_vref(ADC_HandleTypeDef *adcHandle) {
// be 12-bits.
raw_value <<= (12 - adc_get_resolution(adcHandle));
return raw_value / 4096.0f * 3.3f;
// multiplier is 3.3/4095
return raw_value * 0.8058608058608059e-3f;
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment