mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 00:05:33 +03:00
Configuration validation.
This enables a new feature setting for PARALLEL_PWM which is enabled by default. This starts to move much of the feature checking/excluding code that is littered through into a single place - validateAndFixConfig(). Since the config is known to be valid after the method is called other code can just get on with it's job instead of checking for confliciting features/settings.
This commit is contained in:
parent
0fd127bf60
commit
5c4bfd4e58
13 changed files with 269 additions and 193 deletions
|
@ -19,7 +19,6 @@
|
|||
|
||||
void mspInit(serialConfig_t *serialConfig);
|
||||
void cliInit(serialConfig_t *serialConfig);
|
||||
void resetSerialConfig(serialConfig_t *serialConfig);
|
||||
|
||||
// this exists so the user can reference scenarios by a number in the CLI instead of an unuser-friendly bitmask.
|
||||
const serialPortFunctionScenario_e serialPortScenarios[SERIAL_PORT_SCENARIO_COUNT] = {
|
||||
|
@ -170,7 +169,7 @@ static serialPortSearchResult_t *findSerialPort(serialPortFunction_e function)
|
|||
uint8_t serialPortIndex = lookupSerialPortIndexByIdentifier(serialPortFunction->identifier);
|
||||
const serialPortConstraint_t *serialPortConstraint = &serialPortConstraints[serialPortIndex];
|
||||
|
||||
if (!canSoftwareSerialBeUsed() && (
|
||||
if (!feature(FEATURE_SOFTSERIAL) && (
|
||||
serialPortConstraint->identifier == SERIAL_PORT_SOFTSERIAL1 ||
|
||||
serialPortConstraint->identifier == SERIAL_PORT_SOFTSERIAL2
|
||||
)) {
|
||||
|
@ -349,6 +348,20 @@ bool isSerialConfigValid(serialConfig_t *serialConfig)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool doesConfigurationUsePort(serialConfig_t *serialConfig, serialPortIdentifier_e portIdentifier)
|
||||
{
|
||||
serialPortSearchResult_t *searchResult;
|
||||
uint8_t index;
|
||||
for (index = 0; index < FUNCTION_CONSTRAINT_COUNT; index++) {
|
||||
searchResult = findSerialPort(functionConstraints[index].function);
|
||||
if (searchResult->portConstraint->identifier == portIdentifier) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void applySerialConfigToPortFunctions(serialConfig_t *serialConfig)
|
||||
{
|
||||
serialPortFunctions[lookupSerialPortFunctionIndexByIdentifier(SERIAL_PORT_USART1)].scenario = serialPortScenarios[serialConfig->serial_port_1_scenario];
|
||||
|
@ -363,11 +376,6 @@ void serialInit(serialConfig_t *initialSerialConfig)
|
|||
serialConfig = initialSerialConfig;
|
||||
applySerialConfigToPortFunctions(serialConfig);
|
||||
|
||||
if (!isSerialConfigValid(serialConfig)) {
|
||||
resetSerialConfig(serialConfig);
|
||||
applySerialConfigToPortFunctions(serialConfig);
|
||||
}
|
||||
|
||||
mspInit(serialConfig);
|
||||
cliInit(serialConfig);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue