From 3b8b90d17086b56c2f3f8c3b324ed95c7dcb5ecc Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Wed, 22 Sep 2021 23:56:09 +0100 Subject: [PATCH] AP_HAL: move is_dshot_protocol to AP_HAL --- libraries/AP_HAL/RCOutput.cpp | 16 ++++++++++++++++ libraries/AP_HAL/RCOutput.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/libraries/AP_HAL/RCOutput.cpp b/libraries/AP_HAL/RCOutput.cpp index 74b49795bb..a3891cffef 100644 --- a/libraries/AP_HAL/RCOutput.cpp +++ b/libraries/AP_HAL/RCOutput.cpp @@ -52,3 +52,19 @@ void AP_HAL::RCOutput::append_to_banner(char banner_msg[], uint8_t banner_msg_le hal.util->snprintf(banner_msg, banner_msg_len, "%s %s:%u-%u", banner_msg_temp, mode_str, (unsigned)low_ch, (unsigned)high_ch); } } + +/* + true when the output mode is of type dshot +*/ +bool AP_HAL::RCOutput::is_dshot_protocol(const enum output_mode mode) +{ + switch (mode) { + case MODE_PWM_DSHOT150: + case MODE_PWM_DSHOT300: + case MODE_PWM_DSHOT600: + case MODE_PWM_DSHOT1200: + return true; + default: + return false; + } +} diff --git a/libraries/AP_HAL/RCOutput.h b/libraries/AP_HAL/RCOutput.h index f18a9b2993..aa3110bfa6 100644 --- a/libraries/AP_HAL/RCOutput.h +++ b/libraries/AP_HAL/RCOutput.h @@ -202,6 +202,10 @@ public: MODE_NEOPIXEL, // same as MODE_PWM_DSHOT at 800kHz but it's an LED MODE_PROFILED, // same as MODE_PWM_DSHOT using separate clock and data }; + // true when the output mode is of type dshot + // static to allow use in the ChibiOS thread stuff + static bool is_dshot_protocol(const enum output_mode mode); + // https://github.com/bitdump/BLHeli/blob/master/BLHeli_32%20ARM/BLHeli_32%20Firmware%20specs/Digital_Cmd_Spec.txt enum BLHeliDshotCommand : uint8_t {