From 25435ea49cbff8ef063c4f50c4e4dc85bbe1ac29 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Sun, 19 May 2019 08:58:44 -0400 Subject: [PATCH] Add reboot required arming disabled flag, support for setting in MSP --- src/main/fc/config.c | 14 ++++++++++++++ src/main/fc/config.h | 3 +++ src/main/fc/runtime_config.c | 3 ++- src/main/fc/runtime_config.h | 3 ++- src/main/msp/msp.c | 22 +++++++++++++++++----- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/main/fc/config.c b/src/main/fc/config.c index b98692bcc3..6358d89f40 100644 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -41,6 +41,7 @@ #include "fc/rc.h" #include "fc/rc_adjustments.h" #include "fc/rc_controls.h" +#include "fc/runtime_config.h" #include "flight/failsafe.h" #include "flight/imu.h" @@ -72,6 +73,8 @@ static bool configIsDirty; /* someone indicated that the config is modified and it is not yet saved */ +static bool rebootRequired = false; // set if a config change requires a reboot to take effect + pidProfile_t *currentPidProfile; #ifndef RX_SPI_DEFAULT_PROTOCOL @@ -742,3 +745,14 @@ bool isSystemConfigured(void) return true; #endif } + +void setRebootRequired(void) +{ + rebootRequired = true; + setArmingDisabled(ARMING_DISABLED_REBOOT_REQUIRED); +} + +bool getRebootRequired(void) +{ + return rebootRequired; +} diff --git a/src/main/fc/config.h b/src/main/fc/config.h index e692a22ec6..4ca1b9fa98 100644 --- a/src/main/fc/config.h +++ b/src/main/fc/config.h @@ -55,6 +55,7 @@ PG_DECLARE(systemConfig_t, systemConfig); struct pidProfile_s; extern struct pidProfile_s *currentPidProfile; + void initEEPROM(void); void resetEEPROM(void); bool readEEPROM(void); @@ -86,3 +87,5 @@ void targetConfiguration(void); void targetValidateConfiguration(void); bool isSystemConfigured(void); +void setRebootRequired(void); +bool getRebootRequired(void); diff --git a/src/main/fc/runtime_config.c b/src/main/fc/runtime_config.c index b878d7c935..3ed02e8847 100644 --- a/src/main/fc/runtime_config.c +++ b/src/main/fc/runtime_config.c @@ -53,8 +53,9 @@ const char *armingDisableFlagNames[]= { "MSP", "PARALYZE", "GPS", - "RESCUE SW", + "RESCUE_SW", "RPMFILTER", + "REBOOT_REQD", "ARMSWITCH", }; diff --git a/src/main/fc/runtime_config.h b/src/main/fc/runtime_config.h index 3017afb0cf..365b35dbe8 100644 --- a/src/main/fc/runtime_config.h +++ b/src/main/fc/runtime_config.h @@ -61,7 +61,8 @@ typedef enum { ARMING_DISABLED_GPS = (1 << 18), ARMING_DISABLED_RESC = (1 << 19), ARMING_DISABLED_RPMFILTER = (1 << 20), - ARMING_DISABLED_ARM_SWITCH = (1 << 21), // Needs to be the last element, since it's always activated if one of the others is active when arming + ARMING_DISABLED_REBOOT_REQUIRED = (1 << 21), + ARMING_DISABLED_ARM_SWITCH = (1 << 22), // Needs to be the last element, since it's always activated if one of the others is active when arming } armingDisableFlags_e; #define ARMING_DISABLE_FLAGS_COUNT (LOG2(ARMING_DISABLED_ARM_SWITCH) + 1) diff --git a/src/main/msp/msp.c b/src/main/msp/msp.c index 25e7db5ac4..c0b5c349f2 100644 --- a/src/main/msp/msp.c +++ b/src/main/msp/msp.c @@ -241,6 +241,14 @@ static void mspFc4waySerialCommand(sbuf_t *dst, sbuf_t *src, mspPostProcessFnPtr } #endif //USE_SERIAL_4WAY_BLHELI_INTERFACE +static void configRebootUpdateCheckU8(uint8_t *parm, uint8_t value) +{ + if (*parm != value) { + setRebootRequired(); + } + *parm = value; +} + static void mspRebootFn(serialPort_t *serialPort) { UNUSED(serialPort); @@ -860,6 +868,10 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst) // 4 bytes, flags const uint32_t armingDisableFlags = getArmingDisableFlags(); sbufWriteU32(dst, armingDisableFlags); + + // config state flags - bits to indicate the state of the configuration, reboot required, etc. + // other flags can be added as needed + sbufWriteU8(dst, (getRebootRequired() << 0)); } break; @@ -2431,11 +2443,11 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src) // Added in MSP API 1.40 rxConfigMutable()->rcInterpolationChannels = sbufReadU8(src); #if defined(USE_RC_SMOOTHING_FILTER) - rxConfigMutable()->rc_smoothing_type = sbufReadU8(src); - rxConfigMutable()->rc_smoothing_input_cutoff = sbufReadU8(src); - rxConfigMutable()->rc_smoothing_derivative_cutoff = sbufReadU8(src); - rxConfigMutable()->rc_smoothing_input_type = sbufReadU8(src); - rxConfigMutable()->rc_smoothing_derivative_type = sbufReadU8(src); + configRebootUpdateCheckU8(&rxConfigMutable()->rc_smoothing_type, sbufReadU8(src)); + configRebootUpdateCheckU8(&rxConfigMutable()->rc_smoothing_input_cutoff, sbufReadU8(src)); + configRebootUpdateCheckU8(&rxConfigMutable()->rc_smoothing_derivative_cutoff, sbufReadU8(src)); + configRebootUpdateCheckU8(&rxConfigMutable()->rc_smoothing_input_type, sbufReadU8(src)); + configRebootUpdateCheckU8(&rxConfigMutable()->rc_smoothing_derivative_type, sbufReadU8(src)); #else sbufReadU8(src); sbufReadU8(src);