mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Merge pull request #1258 from ProDrone/is1257_false_rx_loss_detection_1
Fix false RX loss detection on EEPROM read/write
This commit is contained in:
commit
df05d599b5
3 changed files with 28 additions and 0 deletions
|
@ -829,6 +829,8 @@ void readEEPROM(void)
|
||||||
if (!isEEPROMContentValid())
|
if (!isEEPROMContentValid())
|
||||||
failureMode(10);
|
failureMode(10);
|
||||||
|
|
||||||
|
suspendRxSignal();
|
||||||
|
|
||||||
// Read flash
|
// Read flash
|
||||||
memcpy(&masterConfig, (char *) CONFIG_START_FLASH_ADDRESS, sizeof(master_t));
|
memcpy(&masterConfig, (char *) CONFIG_START_FLASH_ADDRESS, sizeof(master_t));
|
||||||
|
|
||||||
|
@ -844,6 +846,8 @@ void readEEPROM(void)
|
||||||
|
|
||||||
validateAndFixConfig();
|
validateAndFixConfig();
|
||||||
activateConfig();
|
activateConfig();
|
||||||
|
|
||||||
|
resumeRxSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void readEEPROMAndNotify(void)
|
void readEEPROMAndNotify(void)
|
||||||
|
@ -862,6 +866,8 @@ void writeEEPROM(void)
|
||||||
uint32_t wordOffset;
|
uint32_t wordOffset;
|
||||||
int8_t attemptsRemaining = 3;
|
int8_t attemptsRemaining = 3;
|
||||||
|
|
||||||
|
suspendRxSignal();
|
||||||
|
|
||||||
// prepare checksum/version constants
|
// prepare checksum/version constants
|
||||||
masterConfig.version = EEPROM_CONF_VERSION;
|
masterConfig.version = EEPROM_CONF_VERSION;
|
||||||
masterConfig.size = sizeof(master_t);
|
masterConfig.size = sizeof(master_t);
|
||||||
|
@ -903,6 +909,8 @@ void writeEEPROM(void)
|
||||||
if (status != FLASH_COMPLETE || !isEEPROMContentValid()) {
|
if (status != FLASH_COMPLETE || !isEEPROMContentValid()) {
|
||||||
failureMode(10);
|
failureMode(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resumeRxSignal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ensureEEPROMContainsValidData(void)
|
void ensureEEPROMContainsValidData(void)
|
||||||
|
|
|
@ -71,6 +71,7 @@ static bool rxFlightChannelsValid = false;
|
||||||
|
|
||||||
static uint32_t rxUpdateAt = 0;
|
static uint32_t rxUpdateAt = 0;
|
||||||
static uint32_t needRxSignalBefore = 0;
|
static uint32_t needRxSignalBefore = 0;
|
||||||
|
static uint8_t skipRxSamples = 0;
|
||||||
|
|
||||||
int16_t rcRaw[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
|
int16_t rcRaw[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
|
||||||
int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
|
int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
|
||||||
|
@ -79,6 +80,8 @@ int16_t rcData[MAX_SUPPORTED_RC_CHANNEL_COUNT]; // interval [1000;2000]
|
||||||
|
|
||||||
#define DELAY_50_HZ (1000000 / 50)
|
#define DELAY_50_HZ (1000000 / 50)
|
||||||
#define DELAY_10_HZ (1000000 / 10)
|
#define DELAY_10_HZ (1000000 / 10)
|
||||||
|
#define SKIP_RC_SAMPLES_ON_SUSPEND 75 // approx. 1.5 seconds of samples at 50Hz
|
||||||
|
#define SKIP_RC_SAMPLES_ON_RESUME 2 // flush 2 samples to drop wrong measurements
|
||||||
|
|
||||||
rxRuntimeConfig_t rxRuntimeConfig;
|
rxRuntimeConfig_t rxRuntimeConfig;
|
||||||
static rxConfig_t *rxConfig;
|
static rxConfig_t *rxConfig;
|
||||||
|
@ -261,6 +264,16 @@ static void resetRxSignalReceivedFlagIfNeeded(uint32_t currentTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void suspendRxSignal(void)
|
||||||
|
{
|
||||||
|
skipRxSamples = SKIP_RC_SAMPLES_ON_SUSPEND;
|
||||||
|
}
|
||||||
|
|
||||||
|
void resumeRxSignal(void)
|
||||||
|
{
|
||||||
|
skipRxSamples = SKIP_RC_SAMPLES_ON_RESUME;
|
||||||
|
}
|
||||||
|
|
||||||
void updateRx(uint32_t currentTime)
|
void updateRx(uint32_t currentTime)
|
||||||
{
|
{
|
||||||
resetRxSignalReceivedFlagIfNeeded(currentTime);
|
resetRxSignalReceivedFlagIfNeeded(currentTime);
|
||||||
|
@ -467,6 +480,11 @@ void calculateRxChannelsAndUpdateFailsafe(uint32_t currentTime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skipRxSamples) {
|
||||||
|
skipRxSamples--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
readRxChannelsApplyRanges();
|
readRxChannelsApplyRanges();
|
||||||
detectAndApplySignalLossBehaviour();
|
detectAndApplySignalLossBehaviour();
|
||||||
|
|
||||||
|
|
|
@ -142,3 +142,5 @@ uint8_t serialRxFrameStatus(rxConfig_t *rxConfig);
|
||||||
void updateRSSI(uint32_t currentTime);
|
void updateRSSI(uint32_t currentTime);
|
||||||
void resetAllRxChannelRangeConfigurations(rxChannelRangeConfiguration_t *rxChannelRangeConfiguration);
|
void resetAllRxChannelRangeConfigurations(rxChannelRangeConfiguration_t *rxChannelRangeConfiguration);
|
||||||
|
|
||||||
|
void suspendRxSignal(void);
|
||||||
|
void resumeRxSignal(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue