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

This commit is contained in:
Damien George 2015-02-11 00:25:22 +00:00
parent 99bcaa2fb6
commit 91fc4a9ce1
1 changed files with 4 additions and 2 deletions

View File

@ -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