diff --git a/firmware/controllers/system/efi_gpio.cpp b/firmware/controllers/system/efi_gpio.cpp index 2b728d1e56..447c430c04 100644 --- a/firmware/controllers/system/efi_gpio.cpp +++ b/firmware/controllers/system/efi_gpio.cpp @@ -357,6 +357,15 @@ bool OutputPin::getAndSet(int logicValue) { return oldValue; } +void OutputPin::setOnchipValue(int electricalValue, int logicValue) { + if (port != GPIO_NULL) { + setPinValue(this, electricalValue, logicValue); + } else { + // even without physical pin sometimes it's nice to track logic pin value + currentLogicValue = logicValue; + } +} + void OutputPin::setValue(int logicValue) { #if ENABLE_PERF_TRACE // todo: https://github.com/rusefi/rusefi/issues/1638 @@ -367,14 +376,11 @@ void OutputPin::setValue(int logicValue) { efiAssertVoid(CUSTOM_ERR_6621, modePtr!=NULL, "pin mode not initialized"); pin_output_mode_e mode = *modePtr; efiAssertVoid(CUSTOM_ERR_6622, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); - int eValue = getElectricalValue(logicValue, mode); + int electricalValue = getElectricalValue(logicValue, mode); #if (BOARD_EXT_GPIOCHIPS > 0) if (!this->ext) { - /* onchip pin */ - if (port != GPIO_NULL) { - setPinValue(this, eValue, logicValue); - } + setOnchipValue(electricalValue, logicValue); } else { /* external pin */ gpiochips_writePad(this->brainPin, logicValue); @@ -382,12 +388,7 @@ void OutputPin::setValue(int logicValue) { currentLogicValue = logicValue; } #else - if (port != GPIO_NULL) { - setPinValue(this, eValue, logicValue); - } else { - // even without physical pin sometimes it's nice to track logic pin value - currentLogicValue = logicValue; - } + setOnchipValue(electricalValue, logicValue); #endif #else /* EFI_PROD_CODE */ diff --git a/firmware/controllers/system/efi_gpio.h b/firmware/controllers/system/efi_gpio.h index 0b385d64c6..87f3b55b68 100644 --- a/firmware/controllers/system/efi_gpio.h +++ b/firmware/controllers/system/efi_gpio.h @@ -77,6 +77,7 @@ public: private: // todo: inline this method? void setDefaultPinState(const pin_output_mode_e *defaultState); + void setOnchipValue(int electricalValue, int logicValue); // 4 byte pointer is a bit of a memory waste here const pin_output_mode_e *modePtr;