From 4187f4b081113fb023139c65d2433edf6e92ebc6 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 3 Feb 2019 01:27:47 -0500 Subject: [PATCH] Refactor Trigger System #635 --- firmware/controllers/core/EfiWave.cpp | 2 +- firmware/controllers/core/EfiWave.h | 4 ++-- firmware/controllers/system/pwm_generator_logic.cpp | 2 +- firmware/controllers/trigger/decoders/trigger_chrysler.cpp | 2 +- firmware/controllers/trigger/decoders/trigger_structure.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/core/EfiWave.cpp b/firmware/controllers/core/EfiWave.cpp index 7ae28726ae..936574bb2e 100644 --- a/firmware/controllers/core/EfiWave.cpp +++ b/firmware/controllers/core/EfiWave.cpp @@ -69,7 +69,7 @@ void MultiWave::checkSwitchTimes(int size) { } } -int MultiWave::getChannelState(int channelIndex, int phaseIndex) const { +pin_state_t MultiWave::getChannelState(int channelIndex, int phaseIndex) const { return channels[channelIndex].pinStates[phaseIndex]; } diff --git a/firmware/controllers/core/EfiWave.h b/firmware/controllers/core/EfiWave.h index 30dcc4d13f..57c59079fa 100644 --- a/firmware/controllers/core/EfiWave.h +++ b/firmware/controllers/core/EfiWave.h @@ -19,7 +19,7 @@ * todo: migrate to bit-array to save memory? * this would cost some CPU cycles. see std::vector */ -typedef int8_t pin_state_t; +typedef trigger_value_e pin_state_t; /** * This class represents one channel of a digital signal state sequence @@ -60,7 +60,7 @@ public: float getSwitchTime(int phaseIndex) const; void setSwitchTime(int phaseIndex, float value); void checkSwitchTimes(int size); - int getChannelState(int channelIndex, int phaseIndex) const; + pin_state_t getChannelState(int channelIndex, int phaseIndex) const; int findAngleMatch(float angle, int size) const; int findInsertionAngle(float angle, int size) const; diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index 2c38a6c846..10836b5c6d 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -311,7 +311,7 @@ void startSimplePwm(SimplePwm *state, const char *msg, ExecutorInterface *execut } float switchTimes[] = { dutyCycle, 1 }; - pin_state_t pinStates0[] = { 0, 1 }; + pin_state_t pinStates0[] = { TV_FALL, TV_RISE }; state->setSimplePwmDutyCycle(dutyCycle); pin_state_t *pinStates[1] = { pinStates0 }; diff --git a/firmware/controllers/trigger/decoders/trigger_chrysler.cpp b/firmware/controllers/trigger/decoders/trigger_chrysler.cpp index 53f07419e4..3decbd5294 100644 --- a/firmware/controllers/trigger/decoders/trigger_chrysler.cpp +++ b/firmware/controllers/trigger/decoders/trigger_chrysler.cpp @@ -466,7 +466,7 @@ void configureNeon1995TriggerShape(TriggerShape *s) { s->useRiseEdge = false; - s->initialState[T_PRIMARY] = 1; + s->initialState[T_PRIMARY] = TV_RISE; configureNeon1995TriggerShapeCommon(true, s); diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index b403a3b845..1700131495 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -265,7 +265,7 @@ void TriggerShape::addEvent(bool useOnlyRisingEdgeForTrigger, angle_t angle, tri privateTriggerDefinitionSize++; for (int i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) { - int value = wave.getChannelState(/* channelIndex */i, index - 1); + pin_state_t value = wave.getChannelState(/* channelIndex */i, index - 1); wave.channels[i].setState(index, value); } wave.setSwitchTime(index, angle);