From a769d43b90adf85bc3adce8d8bc20dec36a2acd4 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Sun, 1 Jul 2018 20:21:00 -0400 Subject: [PATCH 1/2] Fix various compiler warnings for combinations of undefined USE_ features --- src/main/fc/fc_core.c | 2 ++ src/main/rx/fport.c | 8 +++++++- src/main/target/common_fc_post.h | 10 ++++++++++ src/main/telemetry/smartport.c | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index 3b8ae1e548..4fefe18ef2 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -558,7 +558,9 @@ bool isAirmodeActivated() bool processRx(timeUs_t currentTimeUs) { static bool armedBeeperOn = false; +#ifdef USE_TELEMETRY static bool sharedPortTelemetryEnabled = false; +#endif if (!calculateRxChannelsAndUpdateFailsafe(currentTimeUs)) { return false; diff --git a/src/main/rx/fport.c b/src/main/rx/fport.c index f31624ee68..758865c464 100644 --- a/src/main/rx/fport.c +++ b/src/main/rx/fport.c @@ -25,7 +25,7 @@ #include "platform.h" -#if defined(USE_SERIAL_RX) +#if defined(USE_SERIAL_RX) && defined(USE_SERIALRX_FPORT) #include "build/debug.h" @@ -114,7 +114,9 @@ typedef struct fportFrame_s { fportData_t data; } fportFrame_t; +#ifdef USE_TELEMETRY_SMARTPORT static const smartPortPayload_t emptySmartPortFrame = { .frameId = 0, .valueId = 0, .data = 0 }; +#endif #define FPORT_REQUEST_FRAME_LENGTH sizeof(fportFrame_t) #define FPORT_RESPONSE_FRAME_LENGTH (sizeof(uint8_t) + sizeof(smartPortPayload_t)) @@ -144,7 +146,9 @@ static smartPortPayload_t *mspPayload = NULL; static timeUs_t lastRcFrameReceivedMs = 0; static serialPort_t *fportPort; +#ifdef USE_TELEMETRY_SMARTPORT static bool telemetryEnabled = false; +#endif static void reportFrameError(uint8_t errorReason) { static volatile uint16_t frameErrors = 0; @@ -248,7 +252,9 @@ static bool checkChecksum(uint8_t *data, uint8_t length) static uint8_t fportFrameStatus(rxRuntimeConfig_t *rxRuntimeConfig) { +#ifdef USE_TELEMETRY_SMARTPORT static smartPortPayload_t payloadBuffer; +#endif static bool hasTelemetryRequest = false; uint8_t result = RX_FRAME_PENDING; diff --git a/src/main/target/common_fc_post.h b/src/main/target/common_fc_post.h index b13f008b13..8f13288363 100644 --- a/src/main/target/common_fc_post.h +++ b/src/main/target/common_fc_post.h @@ -56,6 +56,16 @@ #endif #endif +#if !defined(USE_TELEMETRY) +#undef USE_TELEMETRY_FRSKY_HUB +#undef USE_TELEMETRY_HOTT +#undef USE_TELEMETRY_LTM +#undef USE_TELEMETRY_SMARTPORT +#undef USE_TELEMETRY_CRSF +#undef USE_TELEMETRY_SRXL +#undef USE_SERIALRX_FPORT +#endif + #if defined(USE_MSP_OVER_TELEMETRY) #if !defined(USE_TELEMETRY_SMARTPORT) && !defined(USE_TELEMETRY_CRSF) #undef USE_MSP_OVER_TELEMETRY diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c index 4bfec77501..fc0989f501 100644 --- a/src/main/telemetry/smartport.c +++ b/src/main/telemetry/smartport.c @@ -472,6 +472,8 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear uint8_t *frameStart = (uint8_t *)&payload->valueId; smartPortMspReplyPending = handleMspFrame(frameStart, SMARTPORT_MSP_PAYLOAD_SIZE); } +#else + UNUSED(payload); #endif bool doRun = true; From 2e83accbfe27adf2680481eec2e63ae4f284736c Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Tue, 3 Jul 2018 08:44:21 -0400 Subject: [PATCH 2/2] Disable more telemetry types and fixup warning/errors if USE_SERIAL_RX is not defined --- src/main/rx/crsf.c | 2 +- src/main/rx/fport.c | 2 +- src/main/target/common_fc_post.h | 31 ++++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/main/rx/crsf.c b/src/main/rx/crsf.c index 2f3753cb17..0e62f46ffc 100644 --- a/src/main/rx/crsf.c +++ b/src/main/rx/crsf.c @@ -169,10 +169,10 @@ STATIC_UNIT_TESTED void crsfDataReceive(uint16_t c, void *data) break; } #endif +#if defined(USE_CRSF_CMS_TELEMETRY) case CRSF_FRAMETYPE_DEVICE_PING: crsfScheduleDeviceInfoResponse(); break; -#if defined(USE_CRSF_CMS_TELEMETRY) case CRSF_FRAMETYPE_DISPLAYPORT_CMD: { uint8_t *frameStart = (uint8_t *)&crsfFrame.frame.payload + CRSF_FRAME_ORIGIN_DEST_SIZE; crsfProcessDisplayPortCmd(frameStart); diff --git a/src/main/rx/fport.c b/src/main/rx/fport.c index 758865c464..b57d64acbf 100644 --- a/src/main/rx/fport.c +++ b/src/main/rx/fport.c @@ -25,7 +25,7 @@ #include "platform.h" -#if defined(USE_SERIAL_RX) && defined(USE_SERIALRX_FPORT) +#if defined(USE_SERIALRX_FPORT) #include "build/debug.h" diff --git a/src/main/target/common_fc_post.h b/src/main/target/common_fc_post.h index 8f13288363..231a252c58 100644 --- a/src/main/target/common_fc_post.h +++ b/src/main/target/common_fc_post.h @@ -56,12 +56,41 @@ #endif #endif +#if !defined(USE_SERIAL_RX) +#undef USE_SERIALRX_CRSF +#undef USE_SERIALRX_IBUS +#undef USE_SERIALRX_JETIEXBUS +#undef USE_SERIALRX_SBUS +#undef USE_SERIALRX_SPEKTRUM +#undef USE_SERIALRX_SUMD +#undef USE_SERIALRX_SUMH +#undef USE_SERIALRX_XBUS +#undef USE_SERIALRX_FPORT +#endif + +#if !defined(USE_SERIALRX_CRSF) +#undef USE_TELEMETRY_CRSF +#endif + +#if !defined(USE_SERIALRX_SPEKTRUM) +#undef USE_TELEMETRY_JETIEXBUS +#endif + +#if !defined(USE_SERIALRX_JETIEXBUS) +#undef USE_TELEMETRY_SRXL +#endif + #if !defined(USE_TELEMETRY) +#undef USE_CRSF_CMS_TELEMETRY +#undef USE_TELEMETRY_CRSF #undef USE_TELEMETRY_FRSKY_HUB #undef USE_TELEMETRY_HOTT +#undef USE_TELEMETRY_IBUS +#undef USE_TELEMETRY_IBUS_EXTENDED +#undef USE_TELEMETRY_JETIEXBUS #undef USE_TELEMETRY_LTM +#undef USE_TELEMETRY_MAVLINK #undef USE_TELEMETRY_SMARTPORT -#undef USE_TELEMETRY_CRSF #undef USE_TELEMETRY_SRXL #undef USE_SERIALRX_FPORT #endif