stmhal: Fix ADC multiplier from 4096 to 4095; optimise fp operation.
This commit is contained in:
parent
99bcaa2fb6
commit
91fc4a9ce1
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue