diff --git a/src/drivers/stm32/adc/adc.cpp b/src/drivers/stm32/adc/adc.cpp index cd2213f450..541abce421 100644 --- a/src/drivers/stm32/adc/adc.cpp +++ b/src/drivers/stm32/adc/adc.cpp @@ -68,6 +68,7 @@ #include #if defined(ADC_CHANNELS) + /* * Register accessors. * For now, no reason not to just use ADC1. @@ -347,16 +348,19 @@ ADC::update_system_power(hrt_abstime now) system_power.voltage5V_v = 0; -#if defined(ADC_5V_RAIL_SENSE) + /* HW provides ADC_SCALED_V5_SENSE */ + +# if defined(ADC_SCALED_V5_SENSE) for (unsigned i = 0; i < _channel_count; i++) { - if (_samples[i].am_channel == ADC_5V_RAIL_SENSE) { + if (_samples[i].am_channel == ADC_SCALED_V5_SENSE) { // it is 2:1 scaled - system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096); + system_power.voltage5V_v = _samples[i].am_data * (ADC_V5_V_FULL_SCALE / 4096); + break; } } -#endif +# endif /* Note once the board_config.h provides BOARD_ADC_USB_CONNECTED, * It must provide the true logic GPIO BOARD_ADC_xxxx macros.