From 8cc662163b17712e8ed79edb95c091a33a1e8246 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 16 May 2023 12:21:28 +1000 Subject: [PATCH] AP_RCProtocol: add separate define for AP_RCPROTOCOL_DSM_ENABLED --- libraries/AP_RCProtocol/AP_RCProtocol.cpp | 4 ++++ libraries/AP_RCProtocol/AP_RCProtocol.h | 4 ++++ libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp | 4 ++-- libraries/AP_RCProtocol/AP_RCProtocol_DSM.h | 4 ++-- libraries/AP_RCProtocol/AP_RCProtocol_config.h | 4 ++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libraries/AP_RCProtocol/AP_RCProtocol.cpp b/libraries/AP_RCProtocol/AP_RCProtocol.cpp index d2d11cfb30..2b501c888f 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol.cpp +++ b/libraries/AP_RCProtocol/AP_RCProtocol.cpp @@ -55,7 +55,9 @@ void AP_RCProtocol::init() #if AP_RCPROTOCOL_FASTSBUS_ENABLED backend[AP_RCProtocol::FASTSBUS] = new AP_RCProtocol_SBUS(*this, true, 200000); #endif +#if AP_RCPROTOCOL_DSM_ENABLED backend[AP_RCProtocol::DSM] = new AP_RCProtocol_DSM(*this); +#endif #if AP_RCPROTOCOL_SUMD_ENABLED backend[AP_RCProtocol::SUMD] = new AP_RCProtocol_SUMD(*this); #endif @@ -475,8 +477,10 @@ const char *AP_RCProtocol::protocol_name_from_protocol(rcprotocol_t protocol) case FASTSBUS: return "FastSBUS"; #endif +#if AP_RCPROTOCOL_DSM_ENABLED case DSM: return "DSM"; +#endif #if AP_RCPROTOCOL_SUMD_ENABLED case SUMD: return "SUMD"; diff --git a/libraries/AP_RCProtocol/AP_RCProtocol.h b/libraries/AP_RCProtocol/AP_RCProtocol.h index 8889fdce89..f5823739d6 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol.h +++ b/libraries/AP_RCProtocol/AP_RCProtocol.h @@ -42,7 +42,9 @@ public: #if AP_RCPROTOCOL_SBUS_NI_ENABLED SBUS_NI = 3, #endif +#if AP_RCPROTOCOL_DSM_ENABLED DSM = 4, +#endif #if AP_RCPROTOCOL_SUMD_ENABLED SUMD = 5, #endif @@ -111,7 +113,9 @@ public: // for protocols without strong CRCs we require 3 good frames to lock on bool requires_3_frames(enum rcprotocol_t p) { switch (p) { +#if AP_RCPROTOCOL_DSM_ENABLED case DSM: +#endif #if AP_RCPROTOCOL_FASTSBUS_ENABLED case FASTSBUS: #endif diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp b/libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp index 6258f4069c..bcfd8f3f64 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp +++ b/libraries/AP_RCProtocol/AP_RCProtocol_DSM.cpp @@ -20,7 +20,7 @@ #include "AP_RCProtocol_config.h" -#if AP_RCPROTOCOL_ENABLED +#if AP_RCPROTOCOL_DSM_ENABLED #include "AP_RCProtocol_DSM.h" #include @@ -539,4 +539,4 @@ void AP_RCProtocol_DSM::process_byte(uint8_t b, uint32_t baudrate) _process_byte(AP_HAL::millis(), b); } -#endif // AP_RCPROTOCOL_ENABLED +#endif // AP_RCPROTOCOL_DSM_ENABLED diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_DSM.h b/libraries/AP_RCProtocol/AP_RCProtocol_DSM.h index 65a3e266c1..61141bf8f6 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_DSM.h +++ b/libraries/AP_RCProtocol/AP_RCProtocol_DSM.h @@ -19,7 +19,7 @@ #include "AP_RCProtocol_config.h" -#if AP_RCPROTOCOL_ENABLED +#if AP_RCPROTOCOL_DSM_ENABLED #include "AP_RCProtocol_Backend.h" @@ -83,4 +83,4 @@ private: SoftSerial ss{115200, SoftSerial::SERIAL_CONFIG_8N1}; }; -#endif // AP_RCPROTOCOL_ENABLED +#endif // AP_RCPROTOCOL_DSM_ENABLED diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_config.h b/libraries/AP_RCProtocol/AP_RCProtocol_config.h index d6bef7d61b..7136a381e3 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_config.h +++ b/libraries/AP_RCProtocol/AP_RCProtocol_config.h @@ -19,6 +19,10 @@ #define AP_RCPROTOCOL_DRONECAN_ENABLED AP_RCPROTOCOL_BACKEND_DEFAULT_ENABLED && HAL_ENABLE_DRONECAN_DRIVERS #endif +#ifndef AP_RCPROTOCOL_DSM_ENABLED +#define AP_RCPROTOCOL_DSM_ENABLED AP_RCPROTOCOL_BACKEND_DEFAULT_ENABLED +#endif + #ifndef AP_RCPROTOCOL_FPORT_ENABLED #define AP_RCPROTOCOL_FPORT_ENABLED AP_RCPROTOCOL_BACKEND_DEFAULT_ENABLED #endif