From f7cba024c1eb4ff93dd9b59e434ad63004af26dc Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Wed, 22 Sep 2021 20:47:38 +0100 Subject: [PATCH] AP_HAL_ChibiOS: AnalogSource: check for valid pin --- libraries/AP_HAL_ChibiOS/AnalogIn.cpp | 20 ++++++++++++++++++-- libraries/AP_HAL_ChibiOS/AnalogIn.h | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/AnalogIn.cpp b/libraries/AP_HAL_ChibiOS/AnalogIn.cpp index 73fe8c6ddb..2bd608a367 100644 --- a/libraries/AP_HAL_ChibiOS/AnalogIn.cpp +++ b/libraries/AP_HAL_ChibiOS/AnalogIn.cpp @@ -140,11 +140,26 @@ float AnalogSource::voltage_latest() return _pin_scaler() * read_latest(); } -void AnalogSource::set_pin(uint8_t pin) +bool AnalogSource::set_pin(uint8_t pin) { if (_pin == pin) { - return; + return true; } + bool found_pin = false; + if (_pin == ANALOG_SERVO_VRSSI_PIN) { + found_pin = true; + } else { + for (uint8_t i=0; i