px4 ADC Use device reference_v and dn_fullcount

This commit is contained in:
David Sidrane 2023-06-23 07:50:21 -07:00 committed by Daniel Agar
parent f0bc7d287d
commit 68354dc760
1 changed files with 4 additions and 2 deletions

View File

@ -210,7 +210,8 @@ void ADC::update_system_power(hrt_abstime now)
if (_samples[i].am_channel == ADC_SCALED_V5_SENSE) {
// it is 2:1 scaled
system_power.voltage5v_v = _samples[i].am_data * (ADC_V5_V_FULL_SCALE / px4_arch_adc_dn_fullcount());
system_power.voltage5v_v = _samples[i].am_data * ((ADC_V5_V_FULL_SCALE / 3.3f) * (px4_arch_adc_reference_v() /
px4_arch_adc_dn_fullcount()));
cnt--;
} else
@ -224,7 +225,8 @@ void ADC::update_system_power(hrt_abstime now)
for (int j = 0; j < ADC_SCALED_V3V3_SENSORS_COUNT; ++j) {
if (_samples[i].am_channel == sensors_channels[j]) {
// it is 2:1 scaled
system_power.sensors3v3[j] = _samples[i].am_data * (ADC_3V3_SCALE * (3.3f / px4_arch_adc_dn_fullcount()));
system_power.sensors3v3[j] = _samples[i].am_data * (ADC_3V3_SCALE * (px4_arch_adc_reference_v() /
px4_arch_adc_dn_fullcount()));
system_power.sensors3v3_valid |= 1 << j;
cnt--;
}