mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Fix false RX loss detection on EEPROM read/write
The problem is caused by hardware counters (timekeeping and PPM/PWM measurement) that keep running while the firmware is frozen. The result is misinterpretation of received data. EEPROM read & write now call a suspend and resume function to make RX ignore incoming wrong data during reads/writes (and flush the wrong data on resume). Fixes issue #1257 (+1 squashed commit) - Moved the check for skipSamples to the right place. As commented by hydra
This commit is contained in:
parent
f7530df974
commit
3a13edfdad
3 changed files with 28 additions and 0 deletions
|
@ -71,6 +71,7 @@ static bool rxFlightChannelsValid = false;
|
|||
|
||||
static uint32_t rxUpdateAt = 0;
|
||||
static uint32_t needRxSignalBefore = 0;
|
||||
static uint8_t skipRxSamples = 0;
|
||||
|
||||
int16_t rcRaw[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_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;
|
||||
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)
|
||||
{
|
||||
resetRxSignalReceivedFlagIfNeeded(currentTime);
|
||||
|
@ -467,6 +480,11 @@ void calculateRxChannelsAndUpdateFailsafe(uint32_t currentTime)
|
|||
}
|
||||
}
|
||||
|
||||
if (skipRxSamples) {
|
||||
skipRxSamples--;
|
||||
return;
|
||||
}
|
||||
|
||||
readRxChannelsApplyRanges();
|
||||
detectAndApplySignalLossBehaviour();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue