The Big Refactoring of 2019: folder structure #723

This commit is contained in:
rusefi 2019-12-04 01:11:10 -05:00
parent d81c783391
commit 813b6aa6ce
27 changed files with 120 additions and 120 deletions

View File

@ -55,8 +55,8 @@
/** /**
* Build-in logic analyzer support. Logic analyzer viewer is one of the java console panes. * Build-in logic analyzer support. Logic analyzer viewer is one of the java console panes.
*/ */
#ifndef EFI_WAVE_ANALYZER #ifndef EFI_LOGIC_ANALYZER
#define EFI_WAVE_ANALYZER FALSE #define EFI_LOGIC_ANALYZER FALSE
#endif #endif
#ifndef EFI_ICU_INPUTS #ifndef EFI_ICU_INPUTS

View File

@ -33,7 +33,7 @@
// Build the logic analyzer support. // Build the logic analyzer support.
// A logic analyzer viewer is included in the java console. // A logic analyzer viewer is included in the java console.
#define EFI_WAVE_ANALYZER TRUE #define EFI_LOGIC_ANALYZER TRUE
// A development feature to test output jitter and consistency // A development feature to test output jitter and consistency
#define EFI_PWM_TESTER FALSE #define EFI_PWM_TESTER FALSE

View File

@ -57,8 +57,8 @@
/** /**
* Build-in logic analyzer support. Logic analyzer viewer is one of the java console panes. * Build-in logic analyzer support. Logic analyzer viewer is one of the java console panes.
*/ */
#ifndef EFI_WAVE_ANALYZER #ifndef EFI_LOGIC_ANALYZER
#define EFI_WAVE_ANALYZER TRUE #define EFI_LOGIC_ANALYZER TRUE
#endif #endif
#ifndef EFI_ICU_INPUTS #ifndef EFI_ICU_INPUTS

View File

@ -78,8 +78,8 @@ static void sayHello(void) {
scheduleMsg(&logger, "CH_DBG_SYSTEM_STATE_CHECK=%d", CH_DBG_SYSTEM_STATE_CHECK); scheduleMsg(&logger, "CH_DBG_SYSTEM_STATE_CHECK=%d", CH_DBG_SYSTEM_STATE_CHECK);
scheduleMsg(&logger, "CH_DBG_ENABLE_STACK_CHECK=%d", CH_DBG_ENABLE_STACK_CHECK); scheduleMsg(&logger, "CH_DBG_ENABLE_STACK_CHECK=%d", CH_DBG_ENABLE_STACK_CHECK);
#ifdef EFI_WAVE_ANALYZER #ifdef EFI_LOGIC_ANALYZER
scheduleMsg(&logger, "EFI_WAVE_ANALYZER=%d", EFI_WAVE_ANALYZER); scheduleMsg(&logger, "EFI_LOGIC_ANALYZER=%d", EFI_LOGIC_ANALYZER);
#endif #endif
#ifdef EFI_TUNER_STUDIO #ifdef EFI_TUNER_STUDIO
scheduleMsg(&logger, "EFI_TUNER_STUDIO=%d", EFI_TUNER_STUDIO); scheduleMsg(&logger, "EFI_TUNER_STUDIO=%d", EFI_TUNER_STUDIO);

View File

@ -30,9 +30,9 @@
#include "engine_controller.h" #include "engine_controller.h"
#include "adc_inputs.h" #include "adc_inputs.h"
#if EFI_WAVE_ANALYZER #if EFI_LOGIC_ANALYZER
#include "wave_analyzer.h" #include "logic_analyzer.h"
#endif /* EFI_WAVE_ANALYZER */ #endif /* EFI_LOGIC_ANALYZER */
#include "trigger_central.h" #include "trigger_central.h"
#include "allsensors.h" #include "allsensors.h"
@ -458,10 +458,10 @@ void printOverallStatus(systime_t nowSeconds) {
printOutPin(PROTOCOL_HIP_NAME, CONFIGB(hip9011IntHoldPin)); printOutPin(PROTOCOL_HIP_NAME, CONFIGB(hip9011IntHoldPin));
printOutPin(PROTOCOL_TACH_NAME, CONFIGB(tachOutputPin)); printOutPin(PROTOCOL_TACH_NAME, CONFIGB(tachOutputPin));
printOutPin(PROTOCOL_DIZZY_NAME, engineConfiguration->dizzySparkOutputPin); printOutPin(PROTOCOL_DIZZY_NAME, engineConfiguration->dizzySparkOutputPin);
#if EFI_WAVE_ANALYZER #if EFI_LOGIC_ANALYZER
printOutPin(PROTOCOL_WA_CHANNEL_1, CONFIGB(logicAnalyzerPins)[0]); printOutPin(PROTOCOL_WA_CHANNEL_1, CONFIGB(logicAnalyzerPins)[0]);
printOutPin(PROTOCOL_WA_CHANNEL_2, CONFIGB(logicAnalyzerPins)[1]); printOutPin(PROTOCOL_WA_CHANNEL_2, CONFIGB(logicAnalyzerPins)[1]);
#endif /* EFI_WAVE_ANALYZER */ #endif /* EFI_LOGIC_ANALYZER */
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
printOutPin(enginePins.coils[i].getShortName(), CONFIGB(ignitionPins)[i]); printOutPin(enginePins.coils[i].getShortName(), CONFIGB(ignitionPins)[i]);
@ -524,9 +524,9 @@ void updateDevConsoleState(void) {
chThdSleepMilliseconds(200); chThdSleepMilliseconds(200);
#endif #endif
#if EFI_WAVE_ANALYZER #if EFI_LOGIC_ANALYZER
printWave(&logger); printWave(&logger);
#endif /* EFI_WAVE_ANALYZER */ #endif /* EFI_LOGIC_ANALYZER */
scheduleLogging(&logger); scheduleLogging(&logger);
} }

View File

@ -133,9 +133,9 @@ void setAltPFactor(float p) {
static void applyAlternatorPinState(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->multiChannelStateSequence.waveCount == 1, "invalid idle waveCount");
OutputPin *output = state->outputPins[0]; OutputPin *output = state->outputPins[0];
int value = state->multiWave.getChannelState(/*channelIndex*/0, stateIndex); int value = state->multiChannelStateSequence.getChannelState(/*channelIndex*/0, stateIndex);
/** /**
* 'engine->isAlternatorControlEnabled' would be false is RPM is too low * 'engine->isAlternatorControlEnabled' would be false is RPM is too low
*/ */

View File

@ -521,9 +521,9 @@ void startIdleBench(void) {
static void applyIdleSolenoidPinState(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->multiChannelStateSequence.waveCount == 1, "invalid idle waveCount");
OutputPin *output = state->outputPins[0]; OutputPin *output = state->outputPins[0];
int value = state->multiWave.getChannelState(/*channelIndex*/0, stateIndex); int value = state->multiChannelStateSequence.getChannelState(/*channelIndex*/0, stateIndex);
if (!value /* always allow turning solenoid off */ || if (!value /* always allow turning solenoid off */ ||
(GET_RPM_VALUE != 0 || timeToStopIdleTest != 0) /* do not run solenoid unless engine is spinning or bench testing in progress */ (GET_RPM_VALUE != 0 || timeToStopIdleTest != 0) /* do not run solenoid unless engine is spinning or bench testing in progress */
) { ) {

View File

@ -11,7 +11,7 @@
#if EFI_PWM_TESTER #if EFI_PWM_TESTER
#include "pwm_tester.h" #include "pwm_tester.h"
#include "efi_wave.h" #include "state_requence.h"
#include "pwm_generator_logic.h" #include "pwm_generator_logic.h"
#include "engine.h" #include "engine.h"
#include "pwm_generator.h" #include "pwm_generator.h"

View File

@ -1,6 +1,6 @@
CONTROLLERS_CORE_SRC_CPP = \ CONTROLLERS_CORE_SRC_CPP = \
$(PROJECT_DIR)/controllers/core/efi_wave.cpp \ $(PROJECT_DIR)/controllers/core/state_sequence.cpp \
$(PROJECT_DIR)/controllers/core/fsio_core.cpp \ $(PROJECT_DIR)/controllers/core/fsio_core.cpp \
$(PROJECT_DIR)/controllers/core/fsio_impl.cpp \ $(PROJECT_DIR)/controllers/core/fsio_impl.cpp \

View File

@ -1,59 +1,59 @@
/** /**
* @file EfiWave.cpp * @file state_sequence.cpp
* *
* @date May 18, 2014 * @date May 18, 2014
* @author Andrey Belomutskiy, (c) 2012-2018 * @author Andrey Belomutskiy, (c) 2012-2018
*/ */
#include "global.h" #include "global.h"
#include "efi_wave.h" #include "state_sequence.h"
#include "trigger_structure.h" #include "trigger_structure.h"
SingleWave::SingleWave() { SingleChannelStateSequence::SingleChannelStateSequence() {
init(NULL); init(NULL);
} }
SingleWave::SingleWave(pin_state_t *ps) { SingleChannelStateSequence::SingleChannelStateSequence(pin_state_t *ps) {
init(ps); init(ps);
} }
void SingleWave::init(pin_state_t *pinStates) { void SingleChannelStateSequence::init(pin_state_t *pinStates) {
this->pinStates = pinStates; this->pinStates = pinStates;
} }
pin_state_t SingleWave::getState(int switchIndex) const { pin_state_t SingleChannelStateSequence::getState(int switchIndex) const {
pin_state_t state = pinStates[switchIndex]; pin_state_t state = pinStates[switchIndex];
efiAssert(OBD_PCM_Processor_Fault, state == 0 || state == 1, "wave state get", TV_FALL); efiAssert(OBD_PCM_Processor_Fault, state == 0 || state == 1, "wave state get", TV_FALL);
return state; return state;
} }
void SingleWave::setState(int switchIndex, pin_state_t state) { void SingleChannelStateSequence::setState(int switchIndex, pin_state_t state) {
efiAssertVoid(OBD_PCM_Processor_Fault, state == 0 || state == 1, "wave state set"); efiAssertVoid(OBD_PCM_Processor_Fault, state == 0 || state == 1, "wave state set");
pinStates[switchIndex] = state; pinStates[switchIndex] = state;
} }
MultiWave::MultiWave() { MultiChannelStateSequence::MultiChannelStateSequence() {
reset(); reset();
} }
MultiWave::MultiWave(float *switchTimes, SingleWave *waves) : MultiWave() { MultiChannelStateSequence::MultiChannelStateSequence(float *switchTimes, SingleChannelStateSequence *waves) : MultiChannelStateSequence() {
init(switchTimes, waves); init(switchTimes, waves);
} }
void MultiWave::init(float *switchTimes, SingleWave *channels) { void MultiChannelStateSequence::init(float *switchTimes, SingleChannelStateSequence *channels) {
this->switchTimes = switchTimes; this->switchTimes = switchTimes;
this->channels = channels; this->channels = channels;
} }
void MultiWave::reset(void) { void MultiChannelStateSequence::reset(void) {
waveCount = 0; waveCount = 0;
} }
float MultiWave::getSwitchTime(const int index) const { float MultiChannelStateSequence::getSwitchTime(const int index) const {
return switchTimes[index]; return switchTimes[index];
} }
void MultiWave::checkSwitchTimes(const int size) { void MultiChannelStateSequence::checkSwitchTimes(const int size) {
if (switchTimes[size - 1] != 1) { if (switchTimes[size - 1] != 1) {
firmwareError(CUSTOM_ERR_WAVE_1, "last switch time has to be 1 not %.2f", switchTimes[size - 1]); firmwareError(CUSTOM_ERR_WAVE_1, "last switch time has to be 1 not %.2f", switchTimes[size - 1]);
return; return;
@ -65,7 +65,7 @@ void MultiWave::checkSwitchTimes(const int size) {
} }
} }
pin_state_t MultiWave::getChannelState(const int channelIndex, const int phaseIndex) const { pin_state_t MultiChannelStateSequence::getChannelState(const int channelIndex, const int phaseIndex) const {
if (channelIndex >= waveCount) { if (channelIndex >= waveCount) {
// todo: would be nice to get this asserting working // todo: would be nice to get this asserting working
//firmwareError(OBD_PCM_Processor_Fault, "channel index %d/%d", channelIndex, waveCount); //firmwareError(OBD_PCM_Processor_Fault, "channel index %d/%d", channelIndex, waveCount);
@ -76,7 +76,7 @@ pin_state_t MultiWave::getChannelState(const int channelIndex, const int phaseIn
/** /**
* returns the index at which given value would need to be inserted into sorted array * returns the index at which given value would need to be inserted into sorted array
*/ */
int MultiWave::findInsertionAngle(const float angle, const int size) const { int MultiChannelStateSequence::findInsertionAngle(const float angle, const int size) const {
for (int i = size - 1; i >= 0; i--) { for (int i = size - 1; i >= 0; i--) {
if (angle > switchTimes[i]) if (angle > switchTimes[i])
return i + 1; return i + 1;
@ -84,7 +84,7 @@ int MultiWave::findInsertionAngle(const float angle, const int size) const {
return 0; return 0;
} }
int MultiWave::findAngleMatch(const float angle, const int size) const { int MultiChannelStateSequence::findAngleMatch(const float angle, const int size) const {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
if (isSameF(switchTimes[i], angle)) if (isSameF(switchTimes[i], angle))
return i; return i;
@ -92,7 +92,7 @@ int MultiWave::findAngleMatch(const float angle, const int size) const {
return EFI_ERROR_CODE; return EFI_ERROR_CODE;
} }
void MultiWave::setSwitchTime(const int index, const float value) { void MultiChannelStateSequence::setSwitchTime(const int index, const float value) {
efiAssertVoid(CUSTOM_ERR_PWM_SWITCH_ASSERT, switchTimes != NULL, "switchTimes"); efiAssertVoid(CUSTOM_ERR_PWM_SWITCH_ASSERT, switchTimes != NULL, "switchTimes");
switchTimes[index] = value; switchTimes[index] = value;
} }

View File

@ -1,11 +1,11 @@
/** /**
* @file efi_wave.h * @file state_sequence.h
* *
* @date May 18, 2014 * @date May 18, 2014
* @author Andrey Belomutskiy, (c) 2012-2017 * @author Andrey Belomutskiy, (c) 2012-2019
*/ */
#ifndef EFI_WAVE_H_
#define EFI_WAVE_H_ #pragma once
#include "global.h" #include "global.h"
@ -36,13 +36,14 @@ typedef trigger_value_e pin_state_t;
* is not implemented using a bit array, it could absolutely be a bit array * is not implemented using a bit array, it could absolutely be a bit array
* *
* This sequence does not know anything about signal lengths - only signal state at a given index * This sequence does not know anything about signal lengths - only signal state at a given index
* This sequence can have consecutive zeros and ones since these sequences work as a group within MultiChannelStateSequence
* *
* @brief PWM configuration for the specific output pin * @brief PWM configuration for the specific output pin
*/ */
class SingleWave { class SingleChannelStateSequence {
public: public:
SingleWave(); SingleChannelStateSequence();
explicit SingleWave(pin_state_t *pinStates); explicit SingleChannelStateSequence(pin_state_t *pinStates);
void init(pin_state_t *pinStates); void init(pin_state_t *pinStates);
/** /**
* todo: confirm that we only deal with two states here, no magic '-1'? * todo: confirm that we only deal with two states here, no magic '-1'?
@ -59,11 +60,11 @@ public:
* This class represents multi-channel logical signals with shared time axis * This class represents multi-channel logical signals with shared time axis
* *
*/ */
class MultiWave { class MultiChannelStateSequence {
public: public:
MultiWave(); MultiChannelStateSequence();
MultiWave(float *switchTimes, SingleWave *waves); MultiChannelStateSequence(float *switchTimes, SingleChannelStateSequence *waves);
void init(float *switchTimes, SingleWave *waves); void init(float *switchTimes, SingleChannelStateSequence *waves);
void reset(void); void reset(void);
float getSwitchTime(const int phaseIndex) const; float getSwitchTime(const int phaseIndex) const;
void setSwitchTime(const int phaseIndex, const float value); void setSwitchTime(const int phaseIndex, const float value);
@ -77,7 +78,7 @@ public:
* Number of signal channels * Number of signal channels
*/ */
int waveCount; int waveCount;
SingleWave *channels = nullptr; SingleChannelStateSequence *channels = nullptr;
//private: //private:
/** /**
* values in the (0..1] range which refer to points within the period at at which pin state should be changed * values in the (0..1] range which refer to points within the period at at which pin state should be changed
@ -86,4 +87,4 @@ public:
float *switchTimes = nullptr; float *switchTimes = nullptr;
}; };
#endif /* EFI_WAVE_H_ */

View File

@ -42,8 +42,8 @@
#include "injector_central.h" #include "injector_central.h"
#include "os_util.h" #include "os_util.h"
#include "engine_math.h" #include "engine_math.h"
#if EFI_WAVE_ANALYZER #if EFI_LOGIC_ANALYZER
#include "wave_analyzer.h" #include "logic_analyzer.h"
#endif #endif
#include "allsensors.h" #include "allsensors.h"
#include "electronic_throttle.h" #include "electronic_throttle.h"
@ -704,11 +704,11 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
initAlgo(sharedLogger); initAlgo(sharedLogger);
#if EFI_WAVE_ANALYZER #if EFI_LOGIC_ANALYZER
if (engineConfiguration->isWaveAnalyzerEnabled) { if (engineConfiguration->isWaveAnalyzerEnabled) {
initWaveAnalyzer(sharedLogger); initWaveAnalyzer(sharedLogger);
} }
#endif /* EFI_WAVE_ANALYZER */ #endif /* EFI_LOGIC_ANALYZER */
#if EFI_CJ125 #if EFI_CJ125
/** /**

View File

@ -48,12 +48,12 @@ PwmConfig::PwmConfig() {
arg = this; arg = this;
} }
PwmConfig::PwmConfig(float *st, SingleWave *waves) : PwmConfig() { PwmConfig::PwmConfig(float *st, SingleChannelStateSequence *waves) : PwmConfig() {
multiWave.init(st, waves); multiChannelStateSequence.init(st, waves);
} }
void PwmConfig::init(float *st, SingleWave *waves) { void PwmConfig::init(float *st, SingleChannelStateSequence *waves) {
multiWave.init(st, waves); multiChannelStateSequence.init(st, waves);
} }
/** /**
@ -91,7 +91,7 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
mode = PM_FULL; mode = PM_FULL;
} else { } else {
mode = PM_NORMAL; mode = PM_NORMAL;
multiWave.setSwitchTime(0, dutyCycle); multiChannelStateSequence.setSwitchTime(0, dutyCycle);
} }
} }
@ -102,7 +102,7 @@ static efitimeus_t getNextSwitchTimeUs(PwmConfig *state) {
efiAssert(CUSTOM_ERR_ASSERT, state->safe.phaseIndex < PWM_PHASE_MAX_COUNT, "phaseIndex range", 0); efiAssert(CUSTOM_ERR_ASSERT, state->safe.phaseIndex < PWM_PHASE_MAX_COUNT, "phaseIndex range", 0);
int iteration = state->safe.iteration; int iteration = state->safe.iteration;
// we handle PM_ZERO and PM_FULL separately // we handle PM_ZERO and PM_FULL separately
float switchTime = state->mode == PM_NORMAL ? state->multiWave.getSwitchTime(state->safe.phaseIndex) : 1; float switchTime = state->mode == PM_NORMAL ? state->multiChannelStateSequence.getSwitchTime(state->safe.phaseIndex) : 1;
float periodNt = state->safe.periodNt; float periodNt = state->safe.periodNt;
#if DEBUG_PWM #if DEBUG_PWM
scheduleMsg(&logger, "iteration=%d switchTime=%.2f period=%.2f", iteration, switchTime, period); scheduleMsg(&logger, "iteration=%d switchTime=%.2f period=%.2f", iteration, switchTime, period);
@ -274,17 +274,17 @@ void copyPwmParameters(PwmConfig *state, int phaseCount, float const *switchTime
state->phaseCount = phaseCount; state->phaseCount = phaseCount;
for (int phaseIndex = 0; phaseIndex < phaseCount; phaseIndex++) { for (int phaseIndex = 0; phaseIndex < phaseCount; phaseIndex++) {
state->multiWave.setSwitchTime(phaseIndex, switchTimes[phaseIndex]); state->multiChannelStateSequence.setSwitchTime(phaseIndex, switchTimes[phaseIndex]);
for (int channelIndex = 0; channelIndex < waveCount; channelIndex++) { for (int channelIndex = 0; channelIndex < waveCount; channelIndex++) {
// print("output switch time index (%d/%d) at %.2f to %d\r\n", phaseIndex, channelIndex, // print("output switch time index (%d/%d) at %.2f to %d\r\n", phaseIndex, channelIndex,
// switchTimes[phaseIndex], pinStates[waveIndex][phaseIndex]); // switchTimes[phaseIndex], pinStates[waveIndex][phaseIndex]);
pin_state_t value = pinStates[channelIndex][phaseIndex]; pin_state_t value = pinStates[channelIndex][phaseIndex];
state->multiWave.channels[channelIndex].setState(phaseIndex, value); state->multiChannelStateSequence.channels[channelIndex].setState(phaseIndex, value);
} }
} }
if (state->mode == PM_NORMAL) { if (state->mode == PM_NORMAL) {
state->multiWave.checkSwitchTimes(phaseCount); state->multiChannelStateSequence.checkSwitchTimes(phaseCount);
} }
} }
@ -315,7 +315,7 @@ void PwmConfig::weComplexInit(const char *msg, ExecutorInterface *executor,
this->pwmCycleCallback = pwmCycleCallback; this->pwmCycleCallback = pwmCycleCallback;
this->stateChangeCallback = stateChangeCallback; this->stateChangeCallback = stateChangeCallback;
multiWave.waveCount = waveCount; multiChannelStateSequence.waveCount = waveCount;
copyPwmParameters(this, phaseCount, switchTimes, waveCount, pinStates); copyPwmParameters(this, phaseCount, switchTimes, waveCount, pinStates);
@ -366,10 +366,10 @@ void startSimplePwmExt(SimplePwm *state, const char *msg,
*/ */
void applyPinState(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->multiChannelStateSequence.waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount");
for (int channelIndex = 0; channelIndex < state->multiWave.waveCount; channelIndex++) { for (int channelIndex = 0; channelIndex < state->multiChannelStateSequence.waveCount; channelIndex++) {
OutputPin *output = state->outputPins[channelIndex]; OutputPin *output = state->outputPins[channelIndex];
int value = state->multiWave.getChannelState(channelIndex, stateIndex); int value = state->multiChannelStateSequence.getChannelState(channelIndex, stateIndex);
output->setValue(value); output->setValue(value);
} }
} }

View File

@ -8,8 +8,8 @@
#ifndef PWM_GENERATOR_LOGIC_H_ #ifndef PWM_GENERATOR_LOGIC_H_
#define PWM_GENERATOR_LOGIC_H_ #define PWM_GENERATOR_LOGIC_H_
#include "../../core/state_sequence.h"
#include "global.h" #include "global.h"
#include "efi_wave.h"
#include "scheduler.h" #include "scheduler.h"
#include "efi_gpio.h" #include "efi_gpio.h"
@ -54,8 +54,8 @@ typedef enum {
class PwmConfig { class PwmConfig {
public: public:
PwmConfig(); PwmConfig();
PwmConfig(float *switchTimes, SingleWave *waves); PwmConfig(float *switchTimes, SingleChannelStateSequence *waves);
void init(float *switchTimes, SingleWave *waves); void init(float *switchTimes, SingleChannelStateSequence *waves);
void *arg = nullptr; void *arg = nullptr;
void weComplexInit(const char *msg, void weComplexInit(const char *msg,
@ -82,7 +82,7 @@ public:
// todo: 'outputPins' should be extracted away from here since technically one can want PWM scheduler without actual pin output // todo: 'outputPins' should be extracted away from here since technically one can want PWM scheduler without actual pin output
OutputPin *outputPins[PWM_PHASE_MAX_WAVE_PER_PWM]; OutputPin *outputPins[PWM_PHASE_MAX_WAVE_PER_PWM];
MultiWave multiWave; MultiChannelStateSequence multiChannelStateSequence;
efitimeus_t togglePwmState(); efitimeus_t togglePwmState();
void stop(); void stop();
@ -120,10 +120,10 @@ public:
explicit SimplePwm(const char *name); explicit SimplePwm(const char *name);
void setSimplePwmDutyCycle(float dutyCycle); void setSimplePwmDutyCycle(float dutyCycle);
pin_state_t pinStates[2]; pin_state_t pinStates[2];
SingleWave sr[1]; SingleChannelStateSequence sr[1];
float _switchTimes[2]; float _switchTimes[2];
private: private:
SingleWave waveInstance; SingleChannelStateSequence waveInstance;
}; };
/** /**

View File

@ -229,7 +229,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const channelIndex, t
if (privateTriggerDefinitionSize == 0) { if (privateTriggerDefinitionSize == 0) {
privateTriggerDefinitionSize = 1; privateTriggerDefinitionSize = 1;
for (int i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) { for (int i = 0; i < PWM_PHASE_MAX_WAVE_PER_PWM; i++) {
SingleWave *wave = &this->wave.channels[i]; SingleChannelStateSequence *wave = &this->wave.channels[i];
if (wave->pinStates == NULL) { if (wave->pinStates == NULL) {
warning(CUSTOM_ERR_STATE_NULL, "wave pinStates is NULL"); warning(CUSTOM_ERR_STATE_NULL, "wave pinStates is NULL");

View File

@ -8,9 +8,9 @@
#ifndef TRIGGER_STRUCTURE_H_ #ifndef TRIGGER_STRUCTURE_H_
#define TRIGGER_STRUCTURE_H_ #define TRIGGER_STRUCTURE_H_
#include "state_sequence.h"
#include "globalaccess.h" #include "globalaccess.h"
#include "engine_configuration_generated_structures.h" #include "engine_configuration_generated_structures.h"
#include "efi_wave.h"
#define FOUR_STROKE_ENGINE_CYCLE 720 #define FOUR_STROKE_ENGINE_CYCLE 720
@ -59,7 +59,7 @@ class trigger_shape_helper {
public: public:
trigger_shape_helper(); trigger_shape_helper();
SingleWave channels[TRIGGER_CHANNEL_COUNT]; SingleChannelStateSequence channels[TRIGGER_CHANNEL_COUNT];
private: private:
pin_state_t pinStates[TRIGGER_CHANNEL_COUNT][PWM_PHASE_MAX_COUNT]; pin_state_t pinStates[TRIGGER_CHANNEL_COUNT][PWM_PHASE_MAX_COUNT];
}; };
@ -187,7 +187,7 @@ public:
int triggerSignals[PWM_PHASE_MAX_COUNT]; int triggerSignals[PWM_PHASE_MAX_COUNT];
#endif #endif
MultiWave wave; MultiChannelStateSequence wave;
// todo: add a runtime validation which would verify that this field was set properly // todo: add a runtime validation which would verify that this field was set properly
// todo: maybe even automate this flag calculation? // todo: maybe even automate this flag calculation?

View File

@ -13,18 +13,18 @@
* @date Mar 3, 2014 * @date Mar 3, 2014
* @author Andrey Belomutskiy, (c) 2012-2018 * @author Andrey Belomutskiy, (c) 2012-2018
*/ */
#include "../core/state_sequence.h"
#include "global.h" #include "global.h"
#include "efi_gpio.h" #include "efi_gpio.h"
#include "efi_wave.h"
int getPreviousIndex(const int currentIndex, const int size) { int getPreviousIndex(const int currentIndex, const int size) {
return (currentIndex + size - 1) % size; return (currentIndex + size - 1) % size;
} }
bool needEvent(const int currentIndex, const int size, MultiWave *multiWave, int channelIndex) { bool needEvent(const int currentIndex, const int size, MultiChannelStateSequence *multiChannelStateSequence, int channelIndex) {
int prevIndex = getPreviousIndex(currentIndex, size); int prevIndex = getPreviousIndex(currentIndex, size);
pin_state_t previousValue = multiWave->getChannelState(channelIndex, /*phaseIndex*/prevIndex); pin_state_t previousValue = multiChannelStateSequence->getChannelState(channelIndex, /*phaseIndex*/prevIndex);
pin_state_t currentValue = multiWave->getChannelState(channelIndex, /*phaseIndex*/currentIndex); pin_state_t currentValue = multiChannelStateSequence->getChannelState(channelIndex, /*phaseIndex*/currentIndex);
return previousValue != currentValue; return previousValue != currentValue;
} }
@ -46,20 +46,20 @@ EXTERN_ENGINE
void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIndex) { void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIndex) {
// todo: code duplication with TriggerStimulatorHelper::feedSimulatedEvent? // todo: code duplication with TriggerStimulatorHelper::feedSimulatedEvent?
MultiWave *multiWave = &state->multiWave; MultiChannelStateSequence *multiChannelStateSequence = &state->multiChannelStateSequence;
if (needEvent(stateIndex, state->phaseCount, &state->multiWave, 0)) { if (needEvent(stateIndex, state->phaseCount, &state->multiChannelStateSequence, 0)) {
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/0, stateIndex); pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/0, stateIndex);
hwHandleShaftSignal(currentValue ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING); hwHandleShaftSignal(currentValue ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING);
} }
if (needEvent(stateIndex, state->phaseCount, &state->multiWave, 1)) { if (needEvent(stateIndex, state->phaseCount, &state->multiChannelStateSequence, 1)) {
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/1, stateIndex); pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/1, stateIndex);
hwHandleShaftSignal(currentValue ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING); hwHandleShaftSignal(currentValue ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING);
} }
if (needEvent(stateIndex, state->phaseCount, &state->multiWave, 2)) { if (needEvent(stateIndex, state->phaseCount, &state->multiChannelStateSequence, 2)) {
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/2, stateIndex); pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/2, stateIndex);
hwHandleShaftSignal(currentValue ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING); hwHandleShaftSignal(currentValue ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING);
} }
@ -73,9 +73,9 @@ void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIn
static pin_state_t pinStates1[PWM_PHASE_MAX_COUNT]; static pin_state_t pinStates1[PWM_PHASE_MAX_COUNT];
static pin_state_t pinStates2[PWM_PHASE_MAX_COUNT]; static pin_state_t pinStates2[PWM_PHASE_MAX_COUNT];
static pin_state_t pinStates3[PWM_PHASE_MAX_COUNT]; static pin_state_t pinStates3[PWM_PHASE_MAX_COUNT];
static SingleWave waves[PWM_PHASE_MAX_WAVE_PER_PWM] = { SingleWave(pinStates1), SingleWave(pinStates2), static SingleChannelStateSequence waves[PWM_PHASE_MAX_WAVE_PER_PWM] = { SingleChannelStateSequence(pinStates1), SingleChannelStateSequence(pinStates2),
SingleWave(pinStates3) }; SingleChannelStateSequence(pinStates3) };
static SingleWave sr[PWM_PHASE_MAX_WAVE_PER_PWM] = { waves[0], waves[1], waves[2] }; static SingleChannelStateSequence sr[PWM_PHASE_MAX_WAVE_PER_PWM] = { waves[0], waves[1], waves[2] };
static float switchTimesBuffer[PWM_PHASE_MAX_COUNT]; static float switchTimesBuffer[PWM_PHASE_MAX_COUNT];

View File

@ -20,6 +20,6 @@ public:
void initTriggerEmulatorLogic(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); void initTriggerEmulatorLogic(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
int getPreviousIndex(const int currentIndex, const int size); int getPreviousIndex(const int currentIndex, const int size);
bool needEvent(const int currentIndex, const int size, MultiWave *multiWave, int channelIndex); bool needEvent(const int currentIndex, const int size, MultiChannelStateSequence *multiChannelStateSequence, int channelIndex);
#endif /* TRIGGER_EMULATOR_ALGO_H_ */ #endif /* TRIGGER_EMULATOR_ALGO_H_ */

View File

@ -39,19 +39,19 @@ void TriggerStimulatorHelper::feedSimulatedEvent(TriggerState *state, TriggerSha
int time = (int) (SIMULATION_CYCLE_PERIOD * (loopIndex + shape->wave.getSwitchTime(stateIndex))); int time = (int) (SIMULATION_CYCLE_PERIOD * (loopIndex + shape->wave.getSwitchTime(stateIndex)));
MultiWave *multiWave = &shape->wave; MultiChannelStateSequence *multiChannelStateSequence = &shape->wave;
#if EFI_UNIT_TEST #if EFI_UNIT_TEST
int prevIndex = getPreviousIndex(stateIndex, shape->getSize()); int prevIndex = getPreviousIndex(stateIndex, shape->getSize());
pin_state_t primaryWheelState = multiWave->getChannelState(0, prevIndex); pin_state_t primaryWheelState = multiChannelStateSequence->getChannelState(0, prevIndex);
pin_state_t newPrimaryWheelState = multiWave->getChannelState(0, stateIndex); pin_state_t newPrimaryWheelState = multiChannelStateSequence->getChannelState(0, stateIndex);
pin_state_t secondaryWheelState = multiWave->getChannelState(1, prevIndex); pin_state_t secondaryWheelState = multiChannelStateSequence->getChannelState(1, prevIndex);
pin_state_t newSecondaryWheelState = multiWave->getChannelState(1, stateIndex); pin_state_t newSecondaryWheelState = multiChannelStateSequence->getChannelState(1, stateIndex);
// pin_state_t thirdWheelState = multiWave->getChannelState(2, prevIndex); // pin_state_t thirdWheelState = multiChannelStateSequence->getChannelState(2, prevIndex);
// pin_state_t new3rdWheelState = multiWave->getChannelState(2, stateIndex); // pin_state_t new3rdWheelState = multiChannelStateSequence->getChannelState(2, stateIndex);
if (printTriggerDebug) { if (printTriggerDebug) {
printf("feedSimulatedEvent: %d>%d primary %d>%d secondary %d>%d\r\n", prevIndex, stateIndex, primaryWheelState, newPrimaryWheelState, printf("feedSimulatedEvent: %d>%d primary %d>%d secondary %d>%d\r\n", prevIndex, stateIndex, primaryWheelState, newPrimaryWheelState,
@ -62,22 +62,22 @@ void TriggerStimulatorHelper::feedSimulatedEvent(TriggerState *state, TriggerSha
// todo: code duplication with TriggerEmulatorHelper::handleEmulatorCallback? // todo: code duplication with TriggerEmulatorHelper::handleEmulatorCallback?
if (needEvent(stateIndex, size, multiWave, 0)) { if (needEvent(stateIndex, size, multiChannelStateSequence, 0)) {
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/0, stateIndex); pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/0, stateIndex);
trigger_event_e s = currentValue ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING; trigger_event_e s = currentValue ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING;
if (isUsefulSignal(s PASS_ENGINE_PARAMETER_SUFFIX)) if (isUsefulSignal(s PASS_ENGINE_PARAMETER_SUFFIX))
state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER_SUFFIX); state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER_SUFFIX);
} }
if (needEvent(stateIndex, size, multiWave, 1)) { if (needEvent(stateIndex, size, multiChannelStateSequence, 1)) {
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/1, stateIndex); pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/1, stateIndex);
trigger_event_e s = currentValue ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING; trigger_event_e s = currentValue ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING;
if (isUsefulSignal(s PASS_ENGINE_PARAMETER_SUFFIX)) if (isUsefulSignal(s PASS_ENGINE_PARAMETER_SUFFIX))
state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER_SUFFIX); state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER_SUFFIX);
} }
if (needEvent(stateIndex, size, multiWave, 2)) { if (needEvent(stateIndex, size, multiChannelStateSequence, 2)) {
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/2, stateIndex); pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/2, stateIndex);
trigger_event_e s = currentValue ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING; trigger_event_e s = currentValue ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING;
if (isUsefulSignal(s PASS_ENGINE_PARAMETER_SUFFIX)) if (isUsefulSignal(s PASS_ENGINE_PARAMETER_SUFFIX))
state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER_SUFFIX); state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER_SUFFIX);

View File

@ -9,7 +9,7 @@ DEV_SRC_CPP = $(DEVELOPMENT_DIR)/trigger_emulator.cpp \
$(DEVELOPMENT_DIR)/rfi_perftest.cpp \ $(DEVELOPMENT_DIR)/rfi_perftest.cpp \
$(DEVELOPMENT_DIR)/engine_emulator.cpp \ $(DEVELOPMENT_DIR)/engine_emulator.cpp \
$(DEVELOPMENT_DIR)/engine_sniffer.cpp \ $(DEVELOPMENT_DIR)/engine_sniffer.cpp \
$(DEVELOPMENT_DIR)/wave_analyzer.cpp \ $(DEVELOPMENT_DIR)/logic_analyzer.cpp \
$(DEVELOPMENT_DIR)/development/perf_trace.cpp $(DEVELOPMENT_DIR)/development/perf_trace.cpp
DEV_SIMULATOR_SRC_CPP = $(DEVELOPMENT_DIR)/engine_sniffer.cpp DEV_SIMULATOR_SRC_CPP = $(DEVELOPMENT_DIR)/engine_sniffer.cpp

View File

@ -15,7 +15,7 @@
#include "fuel_math.h" #include "fuel_math.h"
#include "status_loop.h" #include "status_loop.h"
#include "wave_analyzer.h" #include "logic_analyzer.h"
#include "pin_repository.h" #include "pin_repository.h"
#include "pwm_generator_logic.h" #include "pwm_generator_logic.h"

View File

@ -5,7 +5,7 @@
* Here we have our own build-in logic analyzer. The data we aggregate here is sent to the * Here we have our own build-in logic analyzer. The data we aggregate here is sent to the
* java UI rusEfi Console so that it can be displayed nicely in the Sniffer tab. * java UI rusEfi Console so that it can be displayed nicely in the Sniffer tab.
* *
* Both external events (see wave_analyzer.c) and internal (see signal executors) are supported * Both external events (see logic_analyzer.cpp) and internal (see signal executors) are supported
* *
* @date Jun 23, 2013 * @date Jun 23, 2013
* @author Andrey Belomutskiy, (c) 2012-2019 * @author Andrey Belomutskiy, (c) 2012-2019

View File

@ -1,5 +1,5 @@
/** /**
* @file wave_analyzer.cpp * @file logic_analyzer.cpp
* @brief Initialization of Input Capture pins used for rusEfi console sniffer * @brief Initialization of Input Capture pins used for rusEfi console sniffer
* *
* This file is responsible for sniffing of external digital signals and registering * This file is responsible for sniffing of external digital signals and registering
@ -11,9 +11,10 @@
* @author Andrey Belomutskiy, (c) 2012-2019 * @author Andrey Belomutskiy, (c) 2012-2019
*/ */
#include "logic_analyzer.h"
#include "global.h" #include "global.h"
#include "os_access.h" #include "os_access.h"
#include "wave_analyzer.h"
#include "eficonsole.h" #include "eficonsole.h"
#include "data_buffer.h" #include "data_buffer.h"
#include "pin_repository.h" #include "pin_repository.h"
@ -26,7 +27,7 @@
#include "rpm_calculator.h" #include "rpm_calculator.h"
#include "engine_sniffer.h" #include "engine_sniffer.h"
#if EFI_WAVE_ANALYZER #if EFI_LOGIC_ANALYZER
EXTERN_ENGINE; EXTERN_ENGINE;
@ -231,4 +232,4 @@ void initWaveAnalyzer(Logging *sharedLogger) {
} }
#endif /* EFI_WAVE_ANALYZER */ #endif /* EFI_LOGIC_ANALYZER */

View File

@ -1,7 +1,5 @@
/** /**
* @file wave_analyzer.h * @file logic_analyzer.h
*
* todo: rename all this 'logic analyzer' is probably much more appropriate
* *
* @date Jan 7, 2013 * @date Jan 7, 2013
* @author Andrey Belomutskiy, (c) 2012-2019 * @author Andrey Belomutskiy, (c) 2012-2019
@ -11,7 +9,7 @@
#include "global.h" #include "global.h"
#if EFI_WAVE_ANALYZER #if EFI_LOGIC_ANALYZER
#include "digital_input_icu.h" #include "digital_input_icu.h"
#include "engine_sniffer.h" #include "engine_sniffer.h"
@ -56,5 +54,5 @@ void initWaveAnalyzer(Logging *sharedLogger);
void printWave(Logging *logging); void printWave(Logging *logging);
void showWaveInfo(void); void showWaveInfo(void);
#endif /* EFI_WAVE_ANALYZER */ #endif /* EFI_LOGIC_ANALYZER */

View File

@ -284,7 +284,7 @@ static void runChibioTest(void) {
print("EFI_INTERNAL_ADC=%d\r\n", EFI_INTERNAL_ADC); print("EFI_INTERNAL_ADC=%d\r\n", EFI_INTERNAL_ADC);
print("EFI_HD44780_LCD=%d\r\n", EFI_HD44780_LCD); print("EFI_HD44780_LCD=%d\r\n", EFI_HD44780_LCD);
print("EFI_MAP_AVERAGING=%d\r\n", EFI_MAP_AVERAGING); print("EFI_MAP_AVERAGING=%d\r\n", EFI_MAP_AVERAGING);
print("EFI_WAVE_ANALYZER=%d\r\n", EFI_WAVE_ANALYZER); print("EFI_LOGIC_ANALYZER=%d\r\n", EFI_LOGIC_ANALYZER);
print("EFI_ENGINE_SNIFFER=%d\r\n", EFI_ENGINE_SNIFFER); print("EFI_ENGINE_SNIFFER=%d\r\n", EFI_ENGINE_SNIFFER);
print("EFI_SENSOR_CHART=%d\r\n", EFI_SENSOR_CHART); print("EFI_SENSOR_CHART=%d\r\n", EFI_SENSOR_CHART);
print("EFI_SHAFT_POSITION_INPUT=%d\r\n", EFI_SHAFT_POSITION_INPUT); print("EFI_SHAFT_POSITION_INPUT=%d\r\n", EFI_SHAFT_POSITION_INPUT);

View File

@ -122,7 +122,7 @@
#define EFI_RTC FALSE #define EFI_RTC FALSE
#define EFI_MALFUNCTION_INDICATOR FALSE #define EFI_MALFUNCTION_INDICATOR FALSE
#define EFI_HD44780_LCD FALSE #define EFI_HD44780_LCD FALSE
#define EFI_WAVE_ANALYZER FALSE #define EFI_LOGIC_ANALYZER FALSE
#define EFI_PWM_TESTER FALSE #define EFI_PWM_TESTER FALSE
#define TRIGGER_EXTREME_LOGGING FALSE #define TRIGGER_EXTREME_LOGGING FALSE
#define SPARK_EXTREME_LOGGING FALSE #define SPARK_EXTREME_LOGGING FALSE

View File

@ -18,7 +18,7 @@ static int expectedTimeOfNextEvent;
static int pinValue = -1; static int pinValue = -1;
static void testApplyPinState(int stateIndex, PwmConfig *state) /* pwm_gen_callback */ { static void testApplyPinState(int stateIndex, PwmConfig *state) /* pwm_gen_callback */ {
pinValue = state->multiWave.getChannelState(/*channelIndex*/0, stateIndex); pinValue = state->multiChannelStateSequence.getChannelState(/*channelIndex*/0, stateIndex);
printf("PWM_test: setPinValue=%d @ timeNow=%d\r\n", pinValue, timeNowUs); printf("PWM_test: setPinValue=%d @ timeNow=%d\r\n", pinValue, timeNowUs);
} }