mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Added shadow copies for CLI and MSP.
This commit is contained in:
parent
985a9208d5
commit
6de1c32d9d
56 changed files with 277 additions and 222 deletions
|
@ -165,6 +165,18 @@ typedef enum {
|
|||
|
||||
#define RTC_NOT_SUPPORTED 0xff
|
||||
|
||||
static bool featureMaskIsCopied = false;
|
||||
static uint32_t featureMaskCopy;
|
||||
|
||||
static uint32_t getFeatureMask(void)
|
||||
{
|
||||
if (featureMaskIsCopied) {
|
||||
return featureMaskCopy;
|
||||
} else {
|
||||
return featureMask();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_SERIAL_4WAY_BLHELI_INTERFACE
|
||||
#define ESC_4WAY 0xff
|
||||
|
||||
|
@ -531,7 +543,7 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
|
|||
break;
|
||||
|
||||
case MSP_FEATURE_CONFIG:
|
||||
sbufWriteU32(dst, featureMask());
|
||||
sbufWriteU32(dst, getFeatureMask());
|
||||
break;
|
||||
|
||||
#ifdef USE_BEEPER
|
||||
|
@ -1018,7 +1030,7 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
|
|||
|
||||
#if defined(USE_ESC_SENSOR)
|
||||
case MSP_ESC_SENSOR_DATA:
|
||||
if (featureConfigured(FEATURE_ESC_SENSOR)) {
|
||||
if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
|
||||
sbufWriteU8(dst, getMotorCount());
|
||||
for (int i = 0; i < getMotorCount(); i++) {
|
||||
const escSensorData_t *escData = getEscSensorData(i);
|
||||
|
@ -1552,7 +1564,11 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
readEEPROM();
|
||||
break;
|
||||
case MSP_EEPROM_WRITE:
|
||||
writeEEPROM();
|
||||
if (featureMaskIsCopied) {
|
||||
writeEEPROMWithFeatures(featureMaskCopy);
|
||||
} else {
|
||||
writeEEPROM();
|
||||
}
|
||||
readEEPROM();
|
||||
break;
|
||||
default:
|
||||
|
@ -1999,7 +2015,12 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
if (ARMING_FLAG(ARMED)) {
|
||||
return MSP_RESULT_ERROR;
|
||||
}
|
||||
writeEEPROM();
|
||||
|
||||
if (featureMaskIsCopied) {
|
||||
writeEEPROMWithFeatures(featureMaskCopy);
|
||||
} else {
|
||||
writeEEPROM();
|
||||
}
|
||||
readEEPROM();
|
||||
break;
|
||||
|
||||
|
@ -2124,8 +2145,11 @@ static mspResult_e mspProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
break;
|
||||
#endif // USE_GPS
|
||||
case MSP_SET_FEATURE_CONFIG:
|
||||
featureClearAll();
|
||||
featureSet(sbufReadU32(src)); // features bitmap
|
||||
featureMaskCopy = sbufReadU32(src);
|
||||
if (!featureMaskIsCopied) {
|
||||
featureMaskIsCopied = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
#ifdef USE_BEEPER
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue