From 39d21ca08f8a5671059a0247e938d8f5c8cc9d1a Mon Sep 17 00:00:00 2001 From: rusefillc Date: Tue, 3 Nov 2020 11:31:40 -0500 Subject: [PATCH] Output pin init/deinit needs a linked list #1803 --- firmware/controllers/system/efi_gpio.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index 985b640358..1b8cd84461 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -201,6 +201,11 @@ void EnginePins::unregisterPins() { output.initPin(name, CONFIG(pin), &CONFIG(pinMode)); \ } +#define initIfPinChanged(output, name, pin) \ + if (isConfigurationChanged(pin)) { \ + output.initPin(name, CONFIG(pin)); \ + } + void EnginePins::startPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { #if EFI_ENGINE_CONTROL @@ -217,15 +222,15 @@ void EnginePins::startPins(DECLARE_ENGINE_PARAMETER_SIGNATURE) { initIfPinOrModeChanged(fanRelay, "Fan", fanPin, fanPinMode); initIfPinOrModeChanged(acRelay, "A/C relay", acRelayPin, acRelayPinMode); // todo: should we move this code closer to the fuel pump logic? - fuelPumpRelay.initPin("Fuel pump", CONFIG(fuelPumpPin), &CONFIG(fuelPumpPinMode)); - boostPin.initPin("Boost", CONFIG(boostControlPin)); + initIfPinOrModeChanged(fuelPumpRelay, "Fuel pump", fuelPumpPin, fuelPumpPinMode); + initIfPinChanged(boostPin, "Boost", boostControlPin); - idleSolenoidPin.initPin("Idle Valve", CONFIG(idle).solenoidPin); - secondIdleSolenoidPin.initPin("Idle Valve#2", CONFIG(secondSolenoidPin)); - alternatorPin.initPin("Alternator control", CONFIG(alternatorControlPin)); + initIfPinChanged(idleSolenoidPin, "Idle Valve", idle.solenoidPin); + initIfPinChanged(secondIdleSolenoidPin, "Idle Valve#2", secondSolenoidPin); + initIfPinChanged(alternatorPin, "Alternator control", alternatorControlPin); - triggerDecoderErrorPin.initPin("led: trigger debug", CONFIG(triggerErrorPin), - &CONFIG(triggerErrorPinMode)); + initIfPinOrModeChanged(triggerDecoderErrorPin, "led: trigger debug", triggerErrorPin, + triggerErrorPinMode); }