From e5988f7153d18752bc0ed14b804605b1fe23ed1b Mon Sep 17 00:00:00 2001 From: Alexey Kozin Date: Sun, 23 Jun 2019 23:05:28 +0300 Subject: [PATCH] AP_HAL_ChibiOS: fix voltage sensor connected to fmu adc --- libraries/AP_HAL_ChibiOS/AnalogIn.cpp | 5 +++++ libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/libraries/AP_HAL_ChibiOS/AnalogIn.cpp b/libraries/AP_HAL_ChibiOS/AnalogIn.cpp index 44933ab708..8bc46ec31e 100644 --- a/libraries/AP_HAL_ChibiOS/AnalogIn.cpp +++ b/libraries/AP_HAL_ChibiOS/AnalogIn.cpp @@ -297,6 +297,11 @@ void AnalogIn::_timer_tick(void) // voltage_average_ratiometric() _board_voltage = buf_adc[i] * pin_config[i].scaling; } +#endif +#ifdef FMU_SERVORAIL_ADC_CHAN + if (pin_config[i].channel == FMU_SERVORAIL_ADC_CHAN) { + _servorail_voltage = buf_adc[i] * pin_config[i].scaling; + } #endif } diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py index ff1010a9cc..1768b04fdf 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/chibios_hwdef.py @@ -1204,6 +1204,9 @@ def write_ADC_config(f): if p.label == 'VDD_5V_SENS': f.write('#define ANALOG_VCC_5V_PIN %u\n' % chan) f.write('#define HAL_HAVE_BOARD_VOLTAGE 1\n') + if p.label == 'FMU_SERVORAIL_VCC_SENS': + f.write('#define FMU_SERVORAIL_ADC_CHAN %u\n' % chan) + f.write('#define HAL_HAVE_SERVO_VOLTAGE 1\n') adc_chans.append((chan, scale, p.label, p.portpin)) adc_chans = sorted(adc_chans) vdd = get_config('STM32_VDD')