From 9d099fbcd5f1dcb15e28e831773b9a027aaffa3b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 14 Mar 2023 22:18:29 +1100 Subject: [PATCH] AP_RCProtocol: add option to not include SRXL in build --- libraries/AP_RCProtocol/AP_RCProtocol.cpp | 4 ++++ libraries/AP_RCProtocol/AP_RCProtocol.h | 4 ++++ libraries/AP_RCProtocol/AP_RCProtocol_SRXL.cpp | 6 ++++++ libraries/AP_RCProtocol/AP_RCProtocol_SRXL.h | 10 +++++++++- libraries/AP_RCProtocol/AP_RCProtocol_config.h | 13 +++++++++++-- 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/libraries/AP_RCProtocol/AP_RCProtocol.cpp b/libraries/AP_RCProtocol/AP_RCProtocol.cpp index 1b73608a2d..bc07ce3493 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol.cpp +++ b/libraries/AP_RCProtocol/AP_RCProtocol.cpp @@ -45,7 +45,9 @@ void AP_RCProtocol::init() #endif backend[AP_RCProtocol::DSM] = new AP_RCProtocol_DSM(*this); backend[AP_RCProtocol::SUMD] = new AP_RCProtocol_SUMD(*this); +#if AP_RCPROTOCOL_SRXL_ENABLED backend[AP_RCProtocol::SRXL] = new AP_RCProtocol_SRXL(*this); +#endif #ifndef IOMCU_FW backend[AP_RCProtocol::SBUS_NI] = new AP_RCProtocol_SBUS(*this, false, 100000); backend[AP_RCProtocol::SRXL2] = new AP_RCProtocol_SRXL2(*this); @@ -420,8 +422,10 @@ const char *AP_RCProtocol::protocol_name_from_protocol(rcprotocol_t protocol) return "DSM"; case SUMD: return "SUMD"; +#if AP_RCPROTOCOL_SRXL_ENABLED case SRXL: return "SRXL"; +#endif case SRXL2: return "SRXL2"; case CRSF: diff --git a/libraries/AP_RCProtocol/AP_RCProtocol.h b/libraries/AP_RCProtocol/AP_RCProtocol.h index 2caf8a1cda..9d17e96739 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol.h +++ b/libraries/AP_RCProtocol/AP_RCProtocol.h @@ -47,7 +47,9 @@ public: SBUS_NI = 3, DSM = 4, SUMD = 5, +#if AP_RCPROTOCOL_SRXL_ENABLED SRXL = 6, +#endif SRXL2 = 7, CRSF = 8, ST24 = 9, @@ -105,7 +107,9 @@ public: return true; case IBUS: case SUMD: +#if AP_RCPROTOCOL_SRXL_ENABLED case SRXL: +#endif case SRXL2: case ST24: case NONE: diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_SRXL.cpp b/libraries/AP_RCProtocol/AP_RCProtocol_SRXL.cpp index 8e05bb6f4e..934f26c88d 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_SRXL.cpp +++ b/libraries/AP_RCProtocol/AP_RCProtocol_SRXL.cpp @@ -20,6 +20,10 @@ - 2016.10.23: SRXL variant V1 sucessfully (Testbench and Pixhawk/MissionPlanner) tested with RX-9-DR M-LINK (SW v1.26) */ +#include "AP_RCProtocol_config.h" + +#if AP_RCPROTOCOL_SRXL_ENABLED + #include "AP_RCProtocol_SRXL.h" #include #include @@ -281,3 +285,5 @@ void AP_RCProtocol_SRXL::process_byte(uint8_t byte, uint32_t baudrate) } _process_byte(AP_HAL::micros(), byte); } + +#endif // AP_RCPROTOCOL_SRXL_ENABLED diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_SRXL.h b/libraries/AP_RCProtocol/AP_RCProtocol_SRXL.h index eb1429949e..504f061cb1 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_SRXL.h +++ b/libraries/AP_RCProtocol/AP_RCProtocol_SRXL.h @@ -17,11 +17,17 @@ #pragma once +#include "AP_RCProtocol_config.h" + +// this define is out here because SRXL2 uses it - probably incorrectly +#define SRXL_MAX_CHANNELS 20U /* Maximum number of channels from srxl datastream */ + +#if AP_RCPROTOCOL_SRXL_ENABLED + #include "AP_RCProtocol.h" #include "SoftSerial.h" #define SRXL_MIN_FRAMESPACE_US 8000U /* Minumum space between srxl frames in us (applies to all variants) */ -#define SRXL_MAX_CHANNELS 20U /* Maximum number of channels from srxl datastream */ /* Variant specific SRXL datastream characteristics */ /* Framelength in byte */ @@ -64,3 +70,5 @@ private: SoftSerial ss{115200, SoftSerial::SERIAL_CONFIG_8N1}; }; + +#endif // AP_RCPROTOCOL_SRXL_ENABLED diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_config.h b/libraries/AP_RCProtocol/AP_RCProtocol_config.h index d9361e58ff..f489879bce 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_config.h +++ b/libraries/AP_RCProtocol/AP_RCProtocol_config.h @@ -1,10 +1,19 @@ #pragma once +#include #include +#ifndef AP_RCPROTOCOL_BACKEND_DEFAULT_ENABLED +#define AP_RCPROTOCOL_BACKEND_DEFAULT_ENABLED 1 +#endif + #ifndef AP_RCPROTOCOL_FPORT_ENABLED -#define AP_RCPROTOCOL_FPORT_ENABLED AP_FRSKY_SPORT_TELEM_ENABLED +#define AP_RCPROTOCOL_FPORT_ENABLED AP_RCPROTOCOL_BACKEND_DEFAULT_ENABLED && AP_FRSKY_SPORT_TELEM_ENABLED #endif #ifndef AP_RCPROTOCOL_FPORT2_ENABLED -#define AP_RCPROTOCOL_FPORT2_ENABLED AP_FRSKY_SPORT_TELEM_ENABLED +#define AP_RCPROTOCOL_FPORT2_ENABLED AP_RCPROTOCOL_BACKEND_DEFAULT_ENABLED && AP_FRSKY_SPORT_TELEM_ENABLED +#endif + +#ifndef AP_RCPROTOCOL_SRXL_ENABLED +#define AP_RCPROTOCOL_SRXL_ENABLED AP_RCPROTOCOL_BACKEND_DEFAULT_ENABLED #endif