diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 6acd9ccade..6a58816a7f 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -79,6 +79,7 @@ class Engine final : public TriggerStateListener { public: explicit Engine(persistent_config_s *config); Engine(); + bool isPwmEnabled = true; IEtbController *etbControllers[ETB_COUNT] = {nullptr}; IFuelComputer *fuelComputer = nullptr; diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 9904f0eee1..88a7621f5d 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -898,6 +898,8 @@ static void enableOrDisable(const char *param, bool isEnabled) { engineConfiguration->canWriteEnabled = isEnabled; } else if (strEqualCaseInsensitive(param, CMD_INJECTION)) { engineConfiguration->isInjectionEnabled = isEnabled; + } else if (strEqualCaseInsensitive(param, CMD_PWM)) { + engine->isPwmEnabled = isEnabled; } else if (strEqualCaseInsensitive(param, "trigger_details")) { engineConfiguration->verboseTriggerSynchDetails = isEnabled; } else if (strEqualCaseInsensitive(param, "vvt_details")) { diff --git a/firmware/controllers/system/timer/pwm_generator_logic.cpp b/firmware/controllers/system/timer/pwm_generator_logic.cpp index 8e7e446936..84ad78ef57 100644 --- a/firmware/controllers/system/timer/pwm_generator_logic.cpp +++ b/firmware/controllers/system/timer/pwm_generator_logic.cpp @@ -13,9 +13,12 @@ #include "pwm_generator_logic.h" #include "perf_trace.h" +EXTERN_ENGINE; + #if EFI_PROD_CODE #include "mpu_util.h" -#endif +#include "engine.h" +#endif // EFI_PROD_CODE // 1% duty cycle #define ZERO_PWM_THRESHOLD 0.01 @@ -375,6 +378,16 @@ void startSimplePwmHard(SimplePwm *state, const char *msg, * This method takes ~350 ticks. */ void applyPinState(int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { +#if EFI_PROD_CODE + if (!engine->isPwmEnabled) { + for (int channelIndex = 0; channelIndex < state->multiChannelStateSequence.waveCount; channelIndex++) { + OutputPin *output = state->outputPins[channelIndex]; + output->setValue(0); + } + return; + } +#endif // EFI_PROD_CODE + efiAssertVoid(CUSTOM_ERR_6663, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex"); efiAssertVoid(CUSTOM_ERR_6664, state->multiChannelStateSequence.waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount"); for (int channelIndex = 0; channelIndex < state->multiChannelStateSequence.waveCount; channelIndex++) {