1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

Merge pull request #6254 from mikeller/remove_feature_call

Removed calls to (latching) 'feature()'.
This commit is contained in:
Michael Keller 2018-08-23 00:00:16 +12:00 committed by GitHub
commit 4b965a572a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 280 additions and 250 deletions

View file

@ -166,6 +166,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
@ -532,7 +544,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
@ -1021,7 +1033,7 @@ static bool mspProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst)
#if defined(USE_ESC_SENSOR)
case MSP_ESC_SENSOR_DATA:
if (feature(FEATURE_ESC_SENSOR)) {
if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
sbufWriteU8(dst, getMotorCount());
for (int i = 0; i < getMotorCount(); i++) {
const escSensorData_t *escData = getEscSensorData(i);
@ -1555,7 +1567,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:
@ -2002,7 +2018,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;
@ -2127,8 +2148,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