1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 19:40:31 +03:00

Added support for custom defaults in sector 0.

This commit is contained in:
mikeller 2019-07-21 20:55:18 +12:00
parent 7518ec67f5
commit 2c8d197ccb
20 changed files with 84 additions and 74 deletions

View file

@ -212,14 +212,22 @@ static bool signatureUpdated = false;
static const char* const emptyName = "-";
static const char* const emptyString = "";
#if defined(USE_CUSTOM_DEFAULTS)
static char __attribute__ ((section(".custom_defaults_address"))) *customDefaultsStart = &__custom_defaults_start;
static char __attribute__ ((section(".custom_defaults_address"))) *customDefaultsEnd = &__custom_defaults_end;
#if !defined(USE_CUSTOM_DEFAULTS)
#define CUSTOM_DEFAULTS_START ((char*)0)
#define CUSTOM_DEFAULTS_END ((char *)0)
#else
extern char __custom_defaults_start;
extern char __custom_defaults_end;
#define CUSTOM_DEFAULTS_START (&__custom_defaults_start)
#define CUSTOM_DEFAULTS_END (&__custom_defaults_end)
static bool processingCustomDefaults = false;
static char cliBufferTemp[CLI_IN_BUFFER_SIZE];
#endif
static char __attribute__ ((section(".custom_defaults_address"))) *customDefaultsStart = CUSTOM_DEFAULTS_START;
static char __attribute__ ((section(".custom_defaults_address"))) *customDefaultsEnd = CUSTOM_DEFAULTS_END;
#ifndef USE_QUAD_MIXER_ONLY
// sync this with mixerMode_e
static const char * const mixerNames[] = {
@ -4178,6 +4186,11 @@ static void cliDefaults(char *cmdline)
bool saveConfigs = true;
#if defined(USE_CUSTOM_DEFAULTS)
bool useCustomDefaults = true;
#else
// Required to keep the linker from eliminating these
if (customDefaultsStart != customDefaultsEnd) {
delay(0);
}
#endif
if (isEmpty(cmdline)) {
@ -6454,7 +6467,7 @@ void cliProcessCustomDefaults(void)
bufferIndex = 0;
processingCustomDefaults = true;
while (*ptr && ptr != 0xFF && ptr < customDefaultsEnd) {
while (*ptr && *ptr != 0xFF && ptr < customDefaultsEnd) {
processCommandCharacter(*ptr++);
}