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

Don't count crsf errors while eeprom write is in progress

to avoid false errors while writing to flash.
This commit is contained in:
Hans Christian Olaussen 2022-03-30 23:22:33 +02:00
parent 97b934a436
commit bef70530a8
3 changed files with 14 additions and 4 deletions

View file

@ -97,6 +97,8 @@ static bool configIsDirty; /* someone indicated that the config is modified and
static bool rebootRequired = false; // set if a config change requires a reboot to take effect
static bool eepromWriteInProgress = false;
pidProfile_t *currentPidProfile;
#ifndef RX_SPI_DEFAULT_PROTOCOL
@ -126,6 +128,11 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig,
.enableStickArming = false,
);
bool isEepromWriteInProgress(void)
{
return eepromWriteInProgress;
}
uint8_t getCurrentPidProfileIndex(void)
{
return systemConfig()->pidProfileIndex;
@ -738,9 +745,9 @@ void writeUnmodifiedConfigToEEPROM(void)
validateAndFixConfig();
suspendRxSignal();
eepromWriteInProgress = true;
writeConfigToEEPROM();
eepromWriteInProgress = false;
resumeRxSignal();
configIsDirty = false;
}

View file

@ -90,3 +90,4 @@ void targetValidateConfiguration(void);
bool isSystemConfigured(void);
void setRebootRequired(void);
bool getRebootRequired(void);
bool isEepromWriteInProgress(void);

View file

@ -34,6 +34,8 @@
#include "common/maths.h"
#include "common/utils.h"
#include "config/config.h"
#include "pg/rx.h"
#include "drivers/serial.h"
@ -464,8 +466,8 @@ STATIC_UNIT_TESTED void crsfDataReceive(uint16_t c, void *data)
}
}
#if defined(USE_CRSF_V3)
if (crsfBaudNegotiationInProgress()) {
// don't count errors when negotiation in progress.
if (crsfBaudNegotiationInProgress() || isEepromWriteInProgress()) {
// don't count errors when negotiation or eeprom write is in progress
crsfFrameErrorCnt = 0;
} else if (crsfFrameErrorCnt >= CRSF_FRAME_ERROR_COUNT_THRESHOLD) {
// fall back to default speed if speed mismatch detected