From d827b35e57e916d3e670c23ee71ccc708fc31c36 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 20 Jul 2021 14:20:16 +1000 Subject: [PATCH] AP_RPM: implement arming_checks() --- libraries/AP_RPM/AP_RPM.cpp | 21 +++++++++++++++++++++ libraries/AP_RPM/AP_RPM.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/libraries/AP_RPM/AP_RPM.cpp b/libraries/AP_RPM/AP_RPM.cpp index e236bd307b..59008aef71 100644 --- a/libraries/AP_RPM/AP_RPM.cpp +++ b/libraries/AP_RPM/AP_RPM.cpp @@ -223,6 +223,27 @@ bool AP_RPM::get_rpm(uint8_t instance, float &rpm_value) const return true; } +// check settings are valid +bool AP_RPM::arming_checks(size_t buflen, char *buffer) const +{ + for (uint8_t i=0; isnprintf(buffer, buflen, "RPM[%u] no pin set", i + 1); + return false; + } + if (!hal.gpio->valid_pin(_pin[i])) { + hal.util->snprintf(buffer, buflen, "RPM[%u] pin %d invalid", i + 1, _pin[i]); + return false; + } + break; + } + } + return true; +} + // singleton instance AP_RPM *AP_RPM::_singleton; diff --git a/libraries/AP_RPM/AP_RPM.h b/libraries/AP_RPM/AP_RPM.h index 240acd3d49..ad02878200 100644 --- a/libraries/AP_RPM/AP_RPM.h +++ b/libraries/AP_RPM/AP_RPM.h @@ -96,6 +96,9 @@ public: static AP_RPM *get_singleton() { return _singleton; } + // check settings are valid + bool arming_checks(size_t buflen, char *buffer) const; + private: static AP_RPM *_singleton;