From e3b74f0f3e6692ec844d6cee3c89c691fa13365e Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 12 Apr 2019 20:15:18 -0400 Subject: [PATCH] smarter PWM API - need to pass arbitrary pointer --- firmware/controllers/actuators/alternator_controller.cpp | 2 +- firmware/controllers/actuators/idle_thread.cpp | 2 +- firmware/controllers/scheduling/pwm_generator_logic.cpp | 8 ++++---- firmware/controllers/scheduling/pwm_generator_logic.h | 2 +- firmware/controllers/trigger/trigger_emulator_algo.cpp | 4 ++-- firmware/hw_layer/pwm_generator.h | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/firmware/controllers/actuators/alternator_controller.cpp b/firmware/controllers/actuators/alternator_controller.cpp index 61d6d5e0d4..14df7bce4a 100644 --- a/firmware/controllers/actuators/alternator_controller.cpp +++ b/firmware/controllers/actuators/alternator_controller.cpp @@ -124,7 +124,7 @@ void setAltPFactor(float p) { showAltInfo(); } -static void applyAlternatorPinState(PwmConfig *unused, int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { +static void applyAlternatorPinState(int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { efiAssertVoid(CUSTOM_ERR_6643, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex"); efiAssertVoid(CUSTOM_IDLE_WAVE_CNT, state->multiWave.waveCount == 1, "invalid idle waveCount"); OutputPin *output = state->outputPins[0]; diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 03cedfcc76..db3b0b5b4f 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -449,7 +449,7 @@ void setDefaultIdleParameters(void) { engineConfiguration->idleRpmPid.periodMs = 10; } -static void applyIdleSolenoidPinState(PwmConfig *unused, int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { +static void applyIdleSolenoidPinState(int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { efiAssertVoid(CUSTOM_ERR_6645, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex"); efiAssertVoid(CUSTOM_ERR_6646, state->multiWave.waveCount == 1, "invalid idle waveCount"); OutputPin *output = state->outputPins[0]; diff --git a/firmware/controllers/scheduling/pwm_generator_logic.cpp b/firmware/controllers/scheduling/pwm_generator_logic.cpp index babb930b3d..3e9829629b 100644 --- a/firmware/controllers/scheduling/pwm_generator_logic.cpp +++ b/firmware/controllers/scheduling/pwm_generator_logic.cpp @@ -75,7 +75,7 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) { * this custom handling of zero value comes from CJ125 heater code * TODO: is this really needed? cover by unit test? */ - stateChangeCallback(this, 0, arg); + stateChangeCallback(0, arg); } if (dutyCycle < ZERO_PWM_THRESHOLD) { @@ -157,7 +157,7 @@ efitimeus_t PwmConfig::togglePwmState() { /** * NaN period means PWM is paused, we also set the pin low */ - stateChangeCallback(this, 0, arg); + stateChangeCallback(0, arg); return getTimeNowUs() + MS2US(NAN_FREQUENCY_SLEEP_PERIOD_MS); } if (mode != PM_NORMAL) { @@ -182,7 +182,7 @@ efitimeus_t PwmConfig::togglePwmState() { cbStateIndex = 1; } - stateChangeCallback(this, cbStateIndex, arg); + stateChangeCallback(cbStateIndex, arg); efitimeus_t nextSwitchTimeUs = getNextSwitchTimeUs(this); #if DEBUG_PWM @@ -332,7 +332,7 @@ void startSimplePwmExt(SimplePwm *state, const char *msg, * * This method takes ~350 ticks. */ -void applyPinState(PwmConfig *unused, int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { +void applyPinState(int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { efiAssertVoid(CUSTOM_ERR_6663, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex"); efiAssertVoid(CUSTOM_ERR_6664, state->multiWave.waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount"); for (int channelIndex = 0; channelIndex < state->multiWave.waveCount; channelIndex++) { diff --git a/firmware/controllers/scheduling/pwm_generator_logic.h b/firmware/controllers/scheduling/pwm_generator_logic.h index e241a81679..e2d303c302 100644 --- a/firmware/controllers/scheduling/pwm_generator_logic.h +++ b/firmware/controllers/scheduling/pwm_generator_logic.h @@ -38,7 +38,7 @@ typedef struct { class PwmConfig; typedef void (pwm_cycle_callback)(PwmConfig *state); -typedef void (pwm_gen_callback)(PwmConfig *state, int stateIndex, void *arg); +typedef void (pwm_gen_callback)(int stateIndex, void *arg); typedef enum { PM_ZERO, diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index fae174a790..15fd3a8915 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -133,7 +133,7 @@ static void updateTriggerShapeIfNeeded(PwmConfig *state) { static TriggerEmulatorHelper helper; -static void emulatorApplyPinState(PwmConfig *unused, int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { +static void emulatorApplyPinState(int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { if (stopEmulationAtIndex == stateIndex) { isEmulating = false; } @@ -141,7 +141,7 @@ static void emulatorApplyPinState(PwmConfig *unused, int stateIndex, PwmConfig * return; } #if EFI_PROD_CODE || defined(__DOXYGEN__) - applyPinState(unused, stateIndex, state); + applyPinState(stateIndex, state); #endif /* EFI_PROD_CODE */ if (engineConfiguration->directSelfStimulation) { /** diff --git a/firmware/hw_layer/pwm_generator.h b/firmware/hw_layer/pwm_generator.h index b063a0e195..88dc4f4fb6 100644 --- a/firmware/hw_layer/pwm_generator.h +++ b/firmware/hw_layer/pwm_generator.h @@ -21,6 +21,6 @@ void initPwmGenerator(void); * default implementation of pwm_gen_callback which simply toggles the pins * */ -void applyPinState(PwmConfig *unused, int stateIndex, PwmConfig* state) /* pwm_gen_callback */; +void applyPinState(int stateIndex, PwmConfig* state) /* pwm_gen_callback */; #endif /* PWM_GENERATOR_H_ */