1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

ELRS SPI Fix eeprom write and reboot for msp over telemetry

This commit is contained in:
Hans Christian Olaussen 2022-05-01 00:00:49 +02:00
parent 9ca09763bb
commit 90b155ce1d
5 changed files with 73 additions and 12 deletions

View file

@ -75,6 +75,7 @@
#include "fc/board_info.h"
#include "fc/controlrate_profile.h"
#include "fc/core.h"
#include "fc/dispatch.h"
#include "fc/rc.h"
#include "fc/rc_adjustments.h"
#include "fc/rc_controls.h"
@ -142,6 +143,7 @@
#include "sensors/gyro_init.h"
#include "sensors/rangefinder.h"
#include "telemetry/msp_shared.h"
#include "telemetry/telemetry.h"
#ifdef USE_HARDWARE_REVISION_DETECTION
@ -384,6 +386,48 @@ static void mspRebootFn(serialPort_t *serialPort)
while (true) ;
}
#define MSP_DISPATCH_DELAY_US 1000000
void mspReboot(dispatchEntry_t* self)
{
UNUSED(self);
if (ARMING_FLAG(ARMED)) {
return;
}
mspRebootFn(NULL);
}
dispatchEntry_t mspRebootEntry =
{
mspReboot, 0, NULL, false
};
void writeReadEeprom(dispatchEntry_t* self)
{
UNUSED(self);
if (ARMING_FLAG(ARMED)) {
return;
}
writeEEPROM();
readEEPROM();
#ifdef USE_VTX_TABLE
if (vtxTableNeedsInit) {
vtxTableNeedsInit = false;
vtxTableInit(); // Reinitialize and refresh the in-memory copies
}
#endif
}
dispatchEntry_t writeReadEepromEntry =
{
writeReadEeprom, 0, NULL, false
};
static void serializeSDCardSummaryReply(sbuf_t *dst)
{
uint8_t flags = 0;
@ -2193,6 +2237,11 @@ static mspResult_e mspFcProcessOutCommandWithArg(mspDescriptor_t srcDesc, int16_
}
#endif
#if defined(USE_MSP_OVER_TELEMETRY)
if (featureIsEnabled(FEATURE_RX_SPI) && srcDesc == getMspTelemetryDescriptor()) {
dispatchAdd(&mspRebootEntry, MSP_DISPATCH_DELAY_US);
} else
#endif
if (mspPostProcessFn) {
*mspPostProcessFn = mspRebootFn;
}
@ -3076,15 +3125,14 @@ static mspResult_e mspProcessInCommand(mspDescriptor_t srcDesc, int16_t cmdMSP,
// ignore how long it takes to avoid confusing the scheduler
schedulerIgnoreTaskStateTime();
writeEEPROM();
readEEPROM();
#ifdef USE_VTX_TABLE
if (vtxTableNeedsInit) {
vtxTableNeedsInit = false;
vtxTableInit(); // Reinitialize and refresh the in-memory copies
}
#if defined(USE_MSP_OVER_TELEMETRY)
if (featureIsEnabled(FEATURE_RX_SPI) && srcDesc == getMspTelemetryDescriptor()) {
dispatchAdd(&writeReadEepromEntry, MSP_DISPATCH_DELAY_US);
} else
#endif
{
writeReadEeprom(NULL);
}
break;