mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
fix-use-before-initiated
This commit is contained in:
parent
a75e71d012
commit
800fc570d3
2 changed files with 11 additions and 12 deletions
|
@ -322,7 +322,7 @@ void activateConfig(void)
|
||||||
#endif // USE_OSD_SLAVE
|
#endif // USE_OSD_SLAVE
|
||||||
}
|
}
|
||||||
|
|
||||||
void validateAndFixConfig(void)
|
static void validateAndFixConfig(void)
|
||||||
{
|
{
|
||||||
#if !defined(USE_QUAD_MIXER_ONLY) && !defined(USE_OSD_SLAVE)
|
#if !defined(USE_QUAD_MIXER_ONLY) && !defined(USE_OSD_SLAVE)
|
||||||
// Reset unsupported mixer mode to default.
|
// Reset unsupported mixer mode to default.
|
||||||
|
@ -345,9 +345,17 @@ void validateAndFixConfig(void)
|
||||||
if (systemConfig()->activeRateProfile >= CONTROL_RATE_PROFILE_COUNT) {
|
if (systemConfig()->activeRateProfile >= CONTROL_RATE_PROFILE_COUNT) {
|
||||||
systemConfigMutable()->activeRateProfile = 0;
|
systemConfigMutable()->activeRateProfile = 0;
|
||||||
}
|
}
|
||||||
|
setControlRateProfile(systemConfig()->activeRateProfile);
|
||||||
|
|
||||||
if (systemConfig()->pidProfileIndex >= MAX_PROFILE_COUNT) {
|
if (systemConfig()->pidProfileIndex >= MAX_PROFILE_COUNT) {
|
||||||
systemConfigMutable()->pidProfileIndex = 0;
|
systemConfigMutable()->pidProfileIndex = 0;
|
||||||
}
|
}
|
||||||
|
setPidProfile(systemConfig()->pidProfileIndex);
|
||||||
|
|
||||||
|
// Prevent invalid notch cutoff
|
||||||
|
if (currentPidProfile->dterm_notch_cutoff >= currentPidProfile->dterm_notch_hz) {
|
||||||
|
currentPidProfile->dterm_notch_hz = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) && (motorConfig()->mincommand < 1000)) {
|
if ((motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) && (motorConfig()->mincommand < 1000)) {
|
||||||
motorConfigMutable()->mincommand = 1000;
|
motorConfigMutable()->mincommand = 1000;
|
||||||
|
@ -357,6 +365,8 @@ void validateAndFixConfig(void)
|
||||||
motorConfigMutable()->dev.motorPwmRate = BRUSHLESS_MOTORS_PWM_RATE;
|
motorConfigMutable()->dev.motorPwmRate = BRUSHLESS_MOTORS_PWM_RATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateAndFixGyroConfig();
|
||||||
|
|
||||||
if (!(featureConfigured(FEATURE_RX_PARALLEL_PWM) || featureConfigured(FEATURE_RX_PPM) || featureConfigured(FEATURE_RX_SERIAL) || featureConfigured(FEATURE_RX_MSP) || featureConfigured(FEATURE_RX_SPI))) {
|
if (!(featureConfigured(FEATURE_RX_PARALLEL_PWM) || featureConfigured(FEATURE_RX_PPM) || featureConfigured(FEATURE_RX_SERIAL) || featureConfigured(FEATURE_RX_MSP) || featureConfigured(FEATURE_RX_SPI))) {
|
||||||
featureSet(DEFAULT_RX_FEATURE);
|
featureSet(DEFAULT_RX_FEATURE);
|
||||||
}
|
}
|
||||||
|
@ -409,12 +419,6 @@ void validateAndFixConfig(void)
|
||||||
}
|
}
|
||||||
#endif // USE_SOFTSPI
|
#endif // USE_SOFTSPI
|
||||||
|
|
||||||
// Prevent invalid notch cutoff
|
|
||||||
if (currentPidProfile->dterm_notch_cutoff >= currentPidProfile->dterm_notch_hz) {
|
|
||||||
currentPidProfile->dterm_notch_hz = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
validateAndFixGyroConfig();
|
|
||||||
#endif // USE_OSD_SLAVE
|
#endif // USE_OSD_SLAVE
|
||||||
|
|
||||||
if (!isSerialConfigValid(serialConfig())) {
|
if (!isSerialConfigValid(serialConfig())) {
|
||||||
|
@ -606,10 +610,6 @@ void readEEPROM(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
validateAndFixConfig();
|
validateAndFixConfig();
|
||||||
#ifndef USE_OSD_SLAVE
|
|
||||||
setControlRateProfile(systemConfig()->activeRateProfile);
|
|
||||||
setPidProfile(systemConfig()->pidProfileIndex);
|
|
||||||
#endif
|
|
||||||
activateConfig();
|
activateConfig();
|
||||||
|
|
||||||
#ifndef USE_OSD_SLAVE
|
#ifndef USE_OSD_SLAVE
|
||||||
|
|
|
@ -113,7 +113,6 @@ void writeEEPROM(void);
|
||||||
void ensureEEPROMContainsValidData(void);
|
void ensureEEPROMContainsValidData(void);
|
||||||
|
|
||||||
void saveConfigAndNotify(void);
|
void saveConfigAndNotify(void);
|
||||||
void validateAndFixConfig(void);
|
|
||||||
void validateAndFixGyroConfig(void);
|
void validateAndFixGyroConfig(void);
|
||||||
void activateConfig(void);
|
void activateConfig(void);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue