smarter PWM API - need to pass arbitrary pointer

This commit is contained in:
rusefi 2019-04-12 20:15:18 -04:00
parent 22ad223d75
commit e3b74f0f3e
6 changed files with 10 additions and 10 deletions

View File

@ -124,7 +124,7 @@ void setAltPFactor(float p) {
showAltInfo(); 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_ERR_6643, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex");
efiAssertVoid(CUSTOM_IDLE_WAVE_CNT, state->multiWave.waveCount == 1, "invalid idle waveCount"); efiAssertVoid(CUSTOM_IDLE_WAVE_CNT, state->multiWave.waveCount == 1, "invalid idle waveCount");
OutputPin *output = state->outputPins[0]; OutputPin *output = state->outputPins[0];

View File

@ -449,7 +449,7 @@ void setDefaultIdleParameters(void) {
engineConfiguration->idleRpmPid.periodMs = 10; 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_6645, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex");
efiAssertVoid(CUSTOM_ERR_6646, state->multiWave.waveCount == 1, "invalid idle waveCount"); efiAssertVoid(CUSTOM_ERR_6646, state->multiWave.waveCount == 1, "invalid idle waveCount");
OutputPin *output = state->outputPins[0]; OutputPin *output = state->outputPins[0];

View File

@ -75,7 +75,7 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
* this custom handling of zero value comes from CJ125 heater code * this custom handling of zero value comes from CJ125 heater code
* TODO: is this really needed? cover by unit test? * TODO: is this really needed? cover by unit test?
*/ */
stateChangeCallback(this, 0, arg); stateChangeCallback(0, arg);
} }
if (dutyCycle < ZERO_PWM_THRESHOLD) { 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 * 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); return getTimeNowUs() + MS2US(NAN_FREQUENCY_SLEEP_PERIOD_MS);
} }
if (mode != PM_NORMAL) { if (mode != PM_NORMAL) {
@ -182,7 +182,7 @@ efitimeus_t PwmConfig::togglePwmState() {
cbStateIndex = 1; cbStateIndex = 1;
} }
stateChangeCallback(this, cbStateIndex, arg); stateChangeCallback(cbStateIndex, arg);
efitimeus_t nextSwitchTimeUs = getNextSwitchTimeUs(this); efitimeus_t nextSwitchTimeUs = getNextSwitchTimeUs(this);
#if DEBUG_PWM #if DEBUG_PWM
@ -332,7 +332,7 @@ void startSimplePwmExt(SimplePwm *state, const char *msg,
* *
* This method takes ~350 ticks. * 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_6663, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex");
efiAssertVoid(CUSTOM_ERR_6664, state->multiWave.waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount"); efiAssertVoid(CUSTOM_ERR_6664, state->multiWave.waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount");
for (int channelIndex = 0; channelIndex < state->multiWave.waveCount; channelIndex++) { for (int channelIndex = 0; channelIndex < state->multiWave.waveCount; channelIndex++) {

View File

@ -38,7 +38,7 @@ typedef struct {
class PwmConfig; class PwmConfig;
typedef void (pwm_cycle_callback)(PwmConfig *state); 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 { typedef enum {
PM_ZERO, PM_ZERO,

View File

@ -133,7 +133,7 @@ static void updateTriggerShapeIfNeeded(PwmConfig *state) {
static TriggerEmulatorHelper helper; 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) { if (stopEmulationAtIndex == stateIndex) {
isEmulating = false; isEmulating = false;
} }
@ -141,7 +141,7 @@ static void emulatorApplyPinState(PwmConfig *unused, int stateIndex, PwmConfig *
return; return;
} }
#if EFI_PROD_CODE || defined(__DOXYGEN__) #if EFI_PROD_CODE || defined(__DOXYGEN__)
applyPinState(unused, stateIndex, state); applyPinState(stateIndex, state);
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
if (engineConfiguration->directSelfStimulation) { if (engineConfiguration->directSelfStimulation) {
/** /**

View File

@ -21,6 +21,6 @@ void initPwmGenerator(void);
* default implementation of pwm_gen_callback which simply toggles the pins * 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_ */ #endif /* PWM_GENERATOR_H_ */