diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index cb05d0df86..63873e6b87 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -272,23 +272,25 @@ static const char *getGpioPinName(int index) { return NULL; } +float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { + if (fsioLogics[index] == NULL) { + warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(boardConfiguration->fsioOutputPins[index])); + return NAN; + } else { + return calc.getValue2(engine->fsioLastValue[index], fsioLogics[index] PASS_ENGINE_PARAMETER_SUFFIX); + } +} + /** * @param index from zero for (FSIO_COMMAND_COUNT - 1) */ -static void handleFsio(Engine *engine, int index) { +static void handleFsio(int index DECLARE_ENGINE_PARAMETER_SUFFIX) { if (boardConfiguration->fsioOutputPins[index] == GPIO_UNASSIGNED) return; bool isPwmMode = boardConfiguration->fsioFrequency[index] != NO_PWM; - float fvalue; - if (fsioLogics[index] == NULL) { - warning(CUSTOM_NO_FSIO, "no FSIO for #%d %s", index + 1, hwPortname(boardConfiguration->fsioOutputPins[index])); - fvalue = NAN; - } else { - fvalue = calc.getValue2(engine->fsioLastValue[index], fsioLogics[index] PASS_ENGINE_PARAMETER_SUFFIX); - } - engine->fsioLastValue[index] = fvalue; + engine->fsioLastValue[index] = getFsioOutputValue(index PASS_ENGINE_PARAMETER_SUFFIX); if (isPwmMode) { fsioPwm[index].setSimplePwmDutyCycle(fvalue); @@ -365,9 +367,12 @@ static void setFsioFrequency(int index, int frequency) { } } -void runFsio(void) { - for (int i = 0; i < FSIO_COMMAND_COUNT; i++) { - handleFsio(engine, i); +/** + * this method should be invoked periodically to calculate FSIO and toggle corresponding FSIO outputs + */ +void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + for (int index = 0; index < FSIO_COMMAND_COUNT; index++) { + handleFsio(index PASS_ENGINE_PARAMETER_SUFFIX); } #if EFI_FUEL_PUMP || defined(__DOXYGEN__) diff --git a/firmware/controllers/core/fsio_impl.h b/firmware/controllers/core/fsio_impl.h index 553f760bad..9d742139a0 100644 --- a/firmware/controllers/core/fsio_impl.h +++ b/firmware/controllers/core/fsio_impl.h @@ -23,7 +23,8 @@ void setFsio(int index, brain_pin_e pin, const char * exp DECLARE_ENGINE_PARAMET void setFsioExt(int index, brain_pin_e pin, const char * exp, int pwmFrequency DECLARE_ENGINE_PARAMETER_SUFFIX); void initFsioImpl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); -void runFsio(void); +void runFsio(DECLARE_ENGINE_PARAMETER_SIGNATURE); +float getFsioOutputValue(int index DECLARE_ENGINE_PARAMETER_SUFFIX); void applyFsioConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE); void prepareFsio(void); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 6e9e7c8d1b..ab0ffb2fc5 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -274,7 +274,7 @@ static void periodicSlowCallback(Engine *engine) { engine->checkShutdown(); #if (EFI_PROD_CODE && EFI_FSIO) || defined(__DOXYGEN__) - runFsio(); + runFsio(PASS_ENGINE_PARAMETER_SIGNATURE); #endif /* EFI_PROD_CODE && EFI_FSIO */ cylinderCleanupControl(engine);