a bit of OOP
This commit is contained in:
parent
a22f52c5ca
commit
f65af61e82
|
@ -222,33 +222,28 @@ static msg_t benchThread(int param) {
|
|||
#endif
|
||||
}
|
||||
|
||||
static void unregister(brain_pin_e currentPin, OutputPin *output) {
|
||||
if (currentPin == GPIO_UNASSIGNED)
|
||||
return;
|
||||
scheduleMsg(logger, "unregistering %s", hwPortname(currentPin));
|
||||
unmarkPin(currentPin);
|
||||
output->unregister();
|
||||
}
|
||||
|
||||
void unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin, OutputPin *output) {
|
||||
if (oldPin != newPin) {
|
||||
unregister(oldPin, output);
|
||||
void OutputPin::unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin) {
|
||||
if (oldPin != GPIO_UNASSIGNED && oldPin != newPin) {
|
||||
scheduleMsg(logger, "unregistering %s", hwPortname(oldPin));
|
||||
unmarkPin(oldPin);
|
||||
unregister();
|
||||
}
|
||||
}
|
||||
|
||||
void stopIgnitionPins(void) {
|
||||
for (int i = 0; i < IGNITION_PIN_COUNT; i++) {
|
||||
NamedOutputPin *output = &enginePins.coils[i];
|
||||
unregisterOutput(activeConfiguration.bc.ignitionPins[i],
|
||||
engineConfiguration->bc.ignitionPins[i], output);
|
||||
output->unregisterOutput(activeConfiguration.bc.ignitionPins[i],
|
||||
engineConfiguration->bc.ignitionPins[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void stopInjectionPins(void) {
|
||||
for (int i = 0; i < INJECTION_PIN_COUNT; i++) {
|
||||
NamedOutputPin *output = &enginePins.injectors[i];
|
||||
unregisterOutput(activeConfiguration.bc.injectionPins[i],
|
||||
engineConfiguration->bc.injectionPins[i], output);
|
||||
output->unregisterOutput(activeConfiguration.bc.injectionPins[i],
|
||||
engineConfiguration->bc.injectionPins[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ bool isRunningBenchTest(void);
|
|||
|
||||
void stopInjectionPins(void);
|
||||
void startInjectionPins(void);
|
||||
void unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin, OutputPin *output);
|
||||
|
||||
void stopIgnitionPins(void);
|
||||
void startIgnitionPins(void);
|
||||
|
|
|
@ -35,6 +35,8 @@ public:
|
|||
bool isPinAssigned();
|
||||
void initPin(const char *msg, brain_pin_e brainPin);
|
||||
void initPin(const char *msg, brain_pin_e brainPin, pin_output_mode_e *outputMode);
|
||||
void unregisterOutput(brain_pin_e oldPin, brain_pin_e newPin);
|
||||
|
||||
|
||||
#if EFI_GPIO_HARDWARE || defined(__DOXYGEN__)
|
||||
ioportid_t port;
|
||||
|
|
|
@ -263,36 +263,34 @@ void applyNewHardwareSettings(void) {
|
|||
unregisterPin(engineConfiguration->bc.clutchUpPin, activeConfiguration.bc.clutchUpPin);
|
||||
|
||||
|
||||
unregisterOutput(activeConfiguration.bc.fuelPumpPin, engineConfiguration->bc.fuelPumpPin,
|
||||
&enginePins.fuelPumpRelay);
|
||||
unregisterOutput(activeConfiguration.bc.fanPin, engineConfiguration->bc.fanPin, &enginePins.fanRelay);
|
||||
unregisterOutput(activeConfiguration.bc.hip9011CsPin,
|
||||
engineConfiguration->bc.hip9011CsPin, &enginePins.hipCs);
|
||||
unregisterOutput(activeConfiguration.bc.triggerErrorPin,
|
||||
engineConfiguration->bc.triggerErrorPin, &enginePins.triggerDecoderErrorPin);
|
||||
unregisterOutput(activeConfiguration.bc.sdCardCsPin, engineConfiguration->bc.sdCardCsPin,
|
||||
&enginePins.sdCsPin);
|
||||
unregisterOutput(activeConfiguration.bc.etbDirectionPin1,
|
||||
engineConfiguration->bc.etbDirectionPin1, &enginePins.etbOutput1);
|
||||
unregisterOutput(activeConfiguration.bc.etbDirectionPin2,
|
||||
engineConfiguration->bc.etbDirectionPin2, &enginePins.etbOutput2);
|
||||
unregisterOutput(activeConfiguration.bc.malfunctionIndicatorPin,
|
||||
engineConfiguration->bc.malfunctionIndicatorPin, &enginePins.checkEnginePin);
|
||||
unregisterOutput(activeConfiguration.dizzySparkOutputPin,
|
||||
engineConfiguration->dizzySparkOutputPin, &enginePins.dizzyOutput);
|
||||
unregisterOutput(activeConfiguration.bc.tachOutputPin,
|
||||
engineConfiguration->bc.tachOutputPin, &enginePins.tachOut);
|
||||
unregisterOutput(activeConfiguration.bc.idle.solenoidPin,
|
||||
engineConfiguration->bc.idle.solenoidPin, &enginePins.idleSolenoidPin);
|
||||
enginePins.fuelPumpRelay.unregisterOutput(activeConfiguration.bc.fuelPumpPin, engineConfiguration->bc.fuelPumpPin);
|
||||
enginePins.fanRelay.unregisterOutput(activeConfiguration.bc.fanPin, engineConfiguration->bc.fanPin);
|
||||
enginePins.hipCs.unregisterOutput(activeConfiguration.bc.hip9011CsPin, engineConfiguration->bc.hip9011CsPin);
|
||||
enginePins.triggerDecoderErrorPin.unregisterOutput(activeConfiguration.bc.triggerErrorPin,
|
||||
engineConfiguration->bc.triggerErrorPin);
|
||||
enginePins.sdCsPin.unregisterOutput(activeConfiguration.bc.sdCardCsPin, engineConfiguration->bc.sdCardCsPin);
|
||||
enginePins.etbOutput1.unregisterOutput(activeConfiguration.bc.etbDirectionPin1,
|
||||
engineConfiguration->bc.etbDirectionPin1);
|
||||
enginePins.etbOutput2.unregisterOutput(activeConfiguration.bc.etbDirectionPin2,
|
||||
engineConfiguration->bc.etbDirectionPin2);
|
||||
enginePins.checkEnginePin.unregisterOutput(activeConfiguration.bc.malfunctionIndicatorPin,
|
||||
engineConfiguration->bc.malfunctionIndicatorPin);
|
||||
enginePins.dizzyOutput.unregisterOutput(activeConfiguration.dizzySparkOutputPin,
|
||||
engineConfiguration->dizzySparkOutputPin);
|
||||
enginePins.tachOut.unregisterOutput(activeConfiguration.bc.tachOutputPin,
|
||||
engineConfiguration->bc.tachOutputPin);
|
||||
enginePins.idleSolenoidPin.unregisterOutput(activeConfiguration.bc.idle.solenoidPin,
|
||||
engineConfiguration->bc.idle.solenoidPin);
|
||||
|
||||
for (int i = 0;i < LE_COMMAND_COUNT;i++)
|
||||
unregisterOutput(activeConfiguration.bc.fsioPins[i],
|
||||
engineConfiguration->bc.fsioPins[i], &enginePins.fsioOutputs[i]);
|
||||
for (int i = 0;i < LE_COMMAND_COUNT;i++) {
|
||||
enginePins.fsioOutputs[i].unregisterOutput(activeConfiguration.bc.fsioPins[i],
|
||||
engineConfiguration->bc.fsioPins[i]);
|
||||
}
|
||||
|
||||
unregisterOutput(activeConfiguration.bc.alternatorControlPin,
|
||||
engineConfiguration->bc.alternatorControlPin, &enginePins.alternatorPin);
|
||||
unregisterOutput(activeConfiguration.bc.mainRelayPin,
|
||||
engineConfiguration->bc.mainRelayPin, &enginePins.mainRelay);
|
||||
enginePins.alternatorPin.unregisterOutput(activeConfiguration.bc.alternatorControlPin,
|
||||
engineConfiguration->bc.alternatorControlPin);
|
||||
enginePins.mainRelay.unregisterOutput(activeConfiguration.bc.mainRelayPin,
|
||||
engineConfiguration->bc.mainRelayPin);
|
||||
|
||||
startInjectionPins();
|
||||
startIgnitionPins();
|
||||
|
|
Loading…
Reference in New Issue