The Big Refactoring of 2019: folder structure #723
This commit is contained in:
parent
d81c783391
commit
813b6aa6ce
|
@ -55,8 +55,8 @@
|
|||
/**
|
||||
* Build-in logic analyzer support. Logic analyzer viewer is one of the java console panes.
|
||||
*/
|
||||
#ifndef EFI_WAVE_ANALYZER
|
||||
#define EFI_WAVE_ANALYZER FALSE
|
||||
#ifndef EFI_LOGIC_ANALYZER
|
||||
#define EFI_LOGIC_ANALYZER FALSE
|
||||
#endif
|
||||
|
||||
#ifndef EFI_ICU_INPUTS
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
// Build the logic analyzer support.
|
||||
// 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
|
||||
#define EFI_PWM_TESTER FALSE
|
||||
|
|
|
@ -57,8 +57,8 @@
|
|||
/**
|
||||
* Build-in logic analyzer support. Logic analyzer viewer is one of the java console panes.
|
||||
*/
|
||||
#ifndef EFI_WAVE_ANALYZER
|
||||
#define EFI_WAVE_ANALYZER TRUE
|
||||
#ifndef EFI_LOGIC_ANALYZER
|
||||
#define EFI_LOGIC_ANALYZER TRUE
|
||||
#endif
|
||||
|
||||
#ifndef EFI_ICU_INPUTS
|
||||
|
|
|
@ -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_ENABLE_STACK_CHECK=%d", CH_DBG_ENABLE_STACK_CHECK);
|
||||
|
||||
#ifdef EFI_WAVE_ANALYZER
|
||||
scheduleMsg(&logger, "EFI_WAVE_ANALYZER=%d", EFI_WAVE_ANALYZER);
|
||||
#ifdef EFI_LOGIC_ANALYZER
|
||||
scheduleMsg(&logger, "EFI_LOGIC_ANALYZER=%d", EFI_LOGIC_ANALYZER);
|
||||
#endif
|
||||
#ifdef EFI_TUNER_STUDIO
|
||||
scheduleMsg(&logger, "EFI_TUNER_STUDIO=%d", EFI_TUNER_STUDIO);
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
#include "engine_controller.h"
|
||||
|
||||
#include "adc_inputs.h"
|
||||
#if EFI_WAVE_ANALYZER
|
||||
#include "wave_analyzer.h"
|
||||
#endif /* EFI_WAVE_ANALYZER */
|
||||
#if EFI_LOGIC_ANALYZER
|
||||
#include "logic_analyzer.h"
|
||||
#endif /* EFI_LOGIC_ANALYZER */
|
||||
|
||||
#include "trigger_central.h"
|
||||
#include "allsensors.h"
|
||||
|
@ -458,10 +458,10 @@ void printOverallStatus(systime_t nowSeconds) {
|
|||
printOutPin(PROTOCOL_HIP_NAME, CONFIGB(hip9011IntHoldPin));
|
||||
printOutPin(PROTOCOL_TACH_NAME, CONFIGB(tachOutputPin));
|
||||
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_2, CONFIGB(logicAnalyzerPins)[1]);
|
||||
#endif /* EFI_WAVE_ANALYZER */
|
||||
#endif /* EFI_LOGIC_ANALYZER */
|
||||
|
||||
for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) {
|
||||
printOutPin(enginePins.coils[i].getShortName(), CONFIGB(ignitionPins)[i]);
|
||||
|
@ -524,9 +524,9 @@ void updateDevConsoleState(void) {
|
|||
chThdSleepMilliseconds(200);
|
||||
#endif
|
||||
|
||||
#if EFI_WAVE_ANALYZER
|
||||
#if EFI_LOGIC_ANALYZER
|
||||
printWave(&logger);
|
||||
#endif /* EFI_WAVE_ANALYZER */
|
||||
#endif /* EFI_LOGIC_ANALYZER */
|
||||
|
||||
scheduleLogging(&logger);
|
||||
}
|
||||
|
|
|
@ -133,9 +133,9 @@ void setAltPFactor(float p) {
|
|||
|
||||
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");
|
||||
efiAssertVoid(CUSTOM_IDLE_WAVE_CNT, state->multiChannelStateSequence.waveCount == 1, "invalid idle waveCount");
|
||||
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
|
||||
*/
|
||||
|
|
|
@ -521,9 +521,9 @@ void startIdleBench(void) {
|
|||
|
||||
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");
|
||||
efiAssertVoid(CUSTOM_ERR_6646, state->multiChannelStateSequence.waveCount == 1, "invalid idle waveCount");
|
||||
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 */ ||
|
||||
(GET_RPM_VALUE != 0 || timeToStopIdleTest != 0) /* do not run solenoid unless engine is spinning or bench testing in progress */
|
||||
) {
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#if EFI_PWM_TESTER
|
||||
|
||||
#include "pwm_tester.h"
|
||||
#include "efi_wave.h"
|
||||
#include "state_requence.h"
|
||||
#include "pwm_generator_logic.h"
|
||||
#include "engine.h"
|
||||
#include "pwm_generator.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
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_impl.cpp \
|
||||
|
||||
|
|
|
@ -1,59 +1,59 @@
|
|||
/**
|
||||
* @file EfiWave.cpp
|
||||
* @file state_sequence.cpp
|
||||
*
|
||||
* @date May 18, 2014
|
||||
* @author Andrey Belomutskiy, (c) 2012-2018
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "efi_wave.h"
|
||||
#include "state_sequence.h"
|
||||
#include "trigger_structure.h"
|
||||
|
||||
SingleWave::SingleWave() {
|
||||
SingleChannelStateSequence::SingleChannelStateSequence() {
|
||||
init(NULL);
|
||||
}
|
||||
|
||||
SingleWave::SingleWave(pin_state_t *ps) {
|
||||
SingleChannelStateSequence::SingleChannelStateSequence(pin_state_t *ps) {
|
||||
init(ps);
|
||||
}
|
||||
|
||||
void SingleWave::init(pin_state_t *pinStates) {
|
||||
void SingleChannelStateSequence::init(pin_state_t *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];
|
||||
efiAssert(OBD_PCM_Processor_Fault, state == 0 || state == 1, "wave state get", TV_FALL);
|
||||
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");
|
||||
pinStates[switchIndex] = state;
|
||||
}
|
||||
|
||||
MultiWave::MultiWave() {
|
||||
MultiChannelStateSequence::MultiChannelStateSequence() {
|
||||
reset();
|
||||
}
|
||||
|
||||
MultiWave::MultiWave(float *switchTimes, SingleWave *waves) : MultiWave() {
|
||||
MultiChannelStateSequence::MultiChannelStateSequence(float *switchTimes, SingleChannelStateSequence *waves) : MultiChannelStateSequence() {
|
||||
init(switchTimes, waves);
|
||||
}
|
||||
|
||||
void MultiWave::init(float *switchTimes, SingleWave *channels) {
|
||||
void MultiChannelStateSequence::init(float *switchTimes, SingleChannelStateSequence *channels) {
|
||||
this->switchTimes = switchTimes;
|
||||
this->channels = channels;
|
||||
}
|
||||
|
||||
void MultiWave::reset(void) {
|
||||
void MultiChannelStateSequence::reset(void) {
|
||||
waveCount = 0;
|
||||
}
|
||||
|
||||
float MultiWave::getSwitchTime(const int index) const {
|
||||
float MultiChannelStateSequence::getSwitchTime(const int index) const {
|
||||
return switchTimes[index];
|
||||
}
|
||||
|
||||
void MultiWave::checkSwitchTimes(const int size) {
|
||||
void MultiChannelStateSequence::checkSwitchTimes(const int size) {
|
||||
if (switchTimes[size - 1] != 1) {
|
||||
firmwareError(CUSTOM_ERR_WAVE_1, "last switch time has to be 1 not %.2f", switchTimes[size - 1]);
|
||||
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) {
|
||||
// todo: would be nice to get this asserting working
|
||||
//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
|
||||
*/
|
||||
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--) {
|
||||
if (angle > switchTimes[i])
|
||||
return i + 1;
|
||||
|
@ -84,7 +84,7 @@ int MultiWave::findInsertionAngle(const float angle, const int size) const {
|
|||
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++) {
|
||||
if (isSameF(switchTimes[i], angle))
|
||||
return i;
|
||||
|
@ -92,7 +92,7 @@ int MultiWave::findAngleMatch(const float angle, const int size) const {
|
|||
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");
|
||||
switchTimes[index] = value;
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
/**
|
||||
* @file efi_wave.h
|
||||
* @file state_sequence.h
|
||||
*
|
||||
* @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"
|
||||
|
||||
|
@ -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
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
class SingleWave {
|
||||
class SingleChannelStateSequence {
|
||||
public:
|
||||
SingleWave();
|
||||
explicit SingleWave(pin_state_t *pinStates);
|
||||
SingleChannelStateSequence();
|
||||
explicit SingleChannelStateSequence(pin_state_t *pinStates);
|
||||
void init(pin_state_t *pinStates);
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
class MultiWave {
|
||||
class MultiChannelStateSequence {
|
||||
public:
|
||||
MultiWave();
|
||||
MultiWave(float *switchTimes, SingleWave *waves);
|
||||
void init(float *switchTimes, SingleWave *waves);
|
||||
MultiChannelStateSequence();
|
||||
MultiChannelStateSequence(float *switchTimes, SingleChannelStateSequence *waves);
|
||||
void init(float *switchTimes, SingleChannelStateSequence *waves);
|
||||
void reset(void);
|
||||
float getSwitchTime(const int phaseIndex) const;
|
||||
void setSwitchTime(const int phaseIndex, const float value);
|
||||
|
@ -77,7 +78,7 @@ public:
|
|||
* Number of signal channels
|
||||
*/
|
||||
int waveCount;
|
||||
SingleWave *channels = nullptr;
|
||||
SingleChannelStateSequence *channels = nullptr;
|
||||
//private:
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
#endif /* EFI_WAVE_H_ */
|
||||
|
|
@ -42,8 +42,8 @@
|
|||
#include "injector_central.h"
|
||||
#include "os_util.h"
|
||||
#include "engine_math.h"
|
||||
#if EFI_WAVE_ANALYZER
|
||||
#include "wave_analyzer.h"
|
||||
#if EFI_LOGIC_ANALYZER
|
||||
#include "logic_analyzer.h"
|
||||
#endif
|
||||
#include "allsensors.h"
|
||||
#include "electronic_throttle.h"
|
||||
|
@ -704,11 +704,11 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
|
|||
|
||||
initAlgo(sharedLogger);
|
||||
|
||||
#if EFI_WAVE_ANALYZER
|
||||
#if EFI_LOGIC_ANALYZER
|
||||
if (engineConfiguration->isWaveAnalyzerEnabled) {
|
||||
initWaveAnalyzer(sharedLogger);
|
||||
}
|
||||
#endif /* EFI_WAVE_ANALYZER */
|
||||
#endif /* EFI_LOGIC_ANALYZER */
|
||||
|
||||
#if EFI_CJ125
|
||||
/**
|
||||
|
|
|
@ -48,12 +48,12 @@ PwmConfig::PwmConfig() {
|
|||
arg = this;
|
||||
}
|
||||
|
||||
PwmConfig::PwmConfig(float *st, SingleWave *waves) : PwmConfig() {
|
||||
multiWave.init(st, waves);
|
||||
PwmConfig::PwmConfig(float *st, SingleChannelStateSequence *waves) : PwmConfig() {
|
||||
multiChannelStateSequence.init(st, waves);
|
||||
}
|
||||
|
||||
void PwmConfig::init(float *st, SingleWave *waves) {
|
||||
multiWave.init(st, waves);
|
||||
void PwmConfig::init(float *st, SingleChannelStateSequence *waves) {
|
||||
multiChannelStateSequence.init(st, waves);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,7 +91,7 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
|
|||
mode = PM_FULL;
|
||||
} else {
|
||||
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);
|
||||
int iteration = state->safe.iteration;
|
||||
// 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;
|
||||
#if DEBUG_PWM
|
||||
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;
|
||||
|
||||
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++) {
|
||||
// print("output switch time index (%d/%d) at %.2f to %d\r\n", phaseIndex, channelIndex,
|
||||
// switchTimes[phaseIndex], pinStates[waveIndex][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) {
|
||||
state->multiWave.checkSwitchTimes(phaseCount);
|
||||
state->multiChannelStateSequence.checkSwitchTimes(phaseCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ void PwmConfig::weComplexInit(const char *msg, ExecutorInterface *executor,
|
|||
this->pwmCycleCallback = pwmCycleCallback;
|
||||
this->stateChangeCallback = stateChangeCallback;
|
||||
|
||||
multiWave.waveCount = waveCount;
|
||||
multiChannelStateSequence.waveCount = waveCount;
|
||||
|
||||
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 */ {
|
||||
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++) {
|
||||
efiAssertVoid(CUSTOM_ERR_6664, state->multiChannelStateSequence.waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount");
|
||||
for (int channelIndex = 0; channelIndex < state->multiChannelStateSequence.waveCount; channelIndex++) {
|
||||
OutputPin *output = state->outputPins[channelIndex];
|
||||
int value = state->multiWave.getChannelState(channelIndex, stateIndex);
|
||||
int value = state->multiChannelStateSequence.getChannelState(channelIndex, stateIndex);
|
||||
output->setValue(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#ifndef PWM_GENERATOR_LOGIC_H_
|
||||
#define PWM_GENERATOR_LOGIC_H_
|
||||
|
||||
#include "../../core/state_sequence.h"
|
||||
#include "global.h"
|
||||
#include "efi_wave.h"
|
||||
#include "scheduler.h"
|
||||
#include "efi_gpio.h"
|
||||
|
||||
|
@ -54,8 +54,8 @@ typedef enum {
|
|||
class PwmConfig {
|
||||
public:
|
||||
PwmConfig();
|
||||
PwmConfig(float *switchTimes, SingleWave *waves);
|
||||
void init(float *switchTimes, SingleWave *waves);
|
||||
PwmConfig(float *switchTimes, SingleChannelStateSequence *waves);
|
||||
void init(float *switchTimes, SingleChannelStateSequence *waves);
|
||||
void *arg = nullptr;
|
||||
|
||||
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
|
||||
OutputPin *outputPins[PWM_PHASE_MAX_WAVE_PER_PWM];
|
||||
MultiWave multiWave;
|
||||
MultiChannelStateSequence multiChannelStateSequence;
|
||||
efitimeus_t togglePwmState();
|
||||
void stop();
|
||||
|
||||
|
@ -120,10 +120,10 @@ public:
|
|||
explicit SimplePwm(const char *name);
|
||||
void setSimplePwmDutyCycle(float dutyCycle);
|
||||
pin_state_t pinStates[2];
|
||||
SingleWave sr[1];
|
||||
SingleChannelStateSequence sr[1];
|
||||
float _switchTimes[2];
|
||||
private:
|
||||
SingleWave waveInstance;
|
||||
SingleChannelStateSequence waveInstance;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -229,7 +229,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const channelIndex, t
|
|||
if (privateTriggerDefinitionSize == 0) {
|
||||
privateTriggerDefinitionSize = 1;
|
||||
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) {
|
||||
warning(CUSTOM_ERR_STATE_NULL, "wave pinStates is NULL");
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#ifndef TRIGGER_STRUCTURE_H_
|
||||
#define TRIGGER_STRUCTURE_H_
|
||||
|
||||
#include "state_sequence.h"
|
||||
#include "globalaccess.h"
|
||||
#include "engine_configuration_generated_structures.h"
|
||||
#include "efi_wave.h"
|
||||
|
||||
#define FOUR_STROKE_ENGINE_CYCLE 720
|
||||
|
||||
|
@ -59,7 +59,7 @@ class trigger_shape_helper {
|
|||
public:
|
||||
trigger_shape_helper();
|
||||
|
||||
SingleWave channels[TRIGGER_CHANNEL_COUNT];
|
||||
SingleChannelStateSequence channels[TRIGGER_CHANNEL_COUNT];
|
||||
private:
|
||||
pin_state_t pinStates[TRIGGER_CHANNEL_COUNT][PWM_PHASE_MAX_COUNT];
|
||||
};
|
||||
|
@ -187,7 +187,7 @@ public:
|
|||
int triggerSignals[PWM_PHASE_MAX_COUNT];
|
||||
#endif
|
||||
|
||||
MultiWave wave;
|
||||
MultiChannelStateSequence wave;
|
||||
|
||||
// todo: add a runtime validation which would verify that this field was set properly
|
||||
// todo: maybe even automate this flag calculation?
|
||||
|
|
|
@ -13,18 +13,18 @@
|
|||
* @date Mar 3, 2014
|
||||
* @author Andrey Belomutskiy, (c) 2012-2018
|
||||
*/
|
||||
#include "../core/state_sequence.h"
|
||||
#include "global.h"
|
||||
#include "efi_gpio.h"
|
||||
#include "efi_wave.h"
|
||||
|
||||
int getPreviousIndex(const int currentIndex, const int 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);
|
||||
pin_state_t previousValue = multiWave->getChannelState(channelIndex, /*phaseIndex*/prevIndex);
|
||||
pin_state_t currentValue = multiWave->getChannelState(channelIndex, /*phaseIndex*/currentIndex);
|
||||
pin_state_t previousValue = multiChannelStateSequence->getChannelState(channelIndex, /*phaseIndex*/prevIndex);
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(channelIndex, /*phaseIndex*/currentIndex);
|
||||
return previousValue != currentValue;
|
||||
}
|
||||
|
||||
|
@ -46,20 +46,20 @@ EXTERN_ENGINE
|
|||
|
||||
void TriggerEmulatorHelper::handleEmulatorCallback(PwmConfig *state, int stateIndex) {
|
||||
// todo: code duplication with TriggerStimulatorHelper::feedSimulatedEvent?
|
||||
MultiWave *multiWave = &state->multiWave;
|
||||
MultiChannelStateSequence *multiChannelStateSequence = &state->multiChannelStateSequence;
|
||||
|
||||
if (needEvent(stateIndex, state->phaseCount, &state->multiWave, 0)) {
|
||||
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/0, stateIndex);
|
||||
if (needEvent(stateIndex, state->phaseCount, &state->multiChannelStateSequence, 0)) {
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/0, stateIndex);
|
||||
hwHandleShaftSignal(currentValue ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING);
|
||||
}
|
||||
|
||||
if (needEvent(stateIndex, state->phaseCount, &state->multiWave, 1)) {
|
||||
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/1, stateIndex);
|
||||
if (needEvent(stateIndex, state->phaseCount, &state->multiChannelStateSequence, 1)) {
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/1, stateIndex);
|
||||
hwHandleShaftSignal(currentValue ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING);
|
||||
}
|
||||
|
||||
if (needEvent(stateIndex, state->phaseCount, &state->multiWave, 2)) {
|
||||
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/2, stateIndex);
|
||||
if (needEvent(stateIndex, state->phaseCount, &state->multiChannelStateSequence, 2)) {
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/2, stateIndex);
|
||||
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 pinStates2[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),
|
||||
SingleWave(pinStates3) };
|
||||
static SingleWave sr[PWM_PHASE_MAX_WAVE_PER_PWM] = { waves[0], waves[1], waves[2] };
|
||||
static SingleChannelStateSequence waves[PWM_PHASE_MAX_WAVE_PER_PWM] = { SingleChannelStateSequence(pinStates1), SingleChannelStateSequence(pinStates2),
|
||||
SingleChannelStateSequence(pinStates3) };
|
||||
static SingleChannelStateSequence sr[PWM_PHASE_MAX_WAVE_PER_PWM] = { waves[0], waves[1], waves[2] };
|
||||
|
||||
static float switchTimesBuffer[PWM_PHASE_MAX_COUNT];
|
||||
|
||||
|
|
|
@ -20,6 +20,6 @@ public:
|
|||
void initTriggerEmulatorLogic(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
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_ */
|
||||
|
|
|
@ -39,19 +39,19 @@ void TriggerStimulatorHelper::feedSimulatedEvent(TriggerState *state, TriggerSha
|
|||
|
||||
int time = (int) (SIMULATION_CYCLE_PERIOD * (loopIndex + shape->wave.getSwitchTime(stateIndex)));
|
||||
|
||||
MultiWave *multiWave = &shape->wave;
|
||||
MultiChannelStateSequence *multiChannelStateSequence = &shape->wave;
|
||||
|
||||
#if EFI_UNIT_TEST
|
||||
int prevIndex = getPreviousIndex(stateIndex, shape->getSize());
|
||||
|
||||
pin_state_t primaryWheelState = multiWave->getChannelState(0, prevIndex);
|
||||
pin_state_t newPrimaryWheelState = multiWave->getChannelState(0, stateIndex);
|
||||
pin_state_t primaryWheelState = multiChannelStateSequence->getChannelState(0, prevIndex);
|
||||
pin_state_t newPrimaryWheelState = multiChannelStateSequence->getChannelState(0, stateIndex);
|
||||
|
||||
pin_state_t secondaryWheelState = multiWave->getChannelState(1, prevIndex);
|
||||
pin_state_t newSecondaryWheelState = multiWave->getChannelState(1, stateIndex);
|
||||
pin_state_t secondaryWheelState = multiChannelStateSequence->getChannelState(1, prevIndex);
|
||||
pin_state_t newSecondaryWheelState = multiChannelStateSequence->getChannelState(1, stateIndex);
|
||||
|
||||
// pin_state_t thirdWheelState = multiWave->getChannelState(2, prevIndex);
|
||||
// pin_state_t new3rdWheelState = multiWave->getChannelState(2, stateIndex);
|
||||
// pin_state_t thirdWheelState = multiChannelStateSequence->getChannelState(2, prevIndex);
|
||||
// pin_state_t new3rdWheelState = multiChannelStateSequence->getChannelState(2, stateIndex);
|
||||
|
||||
if (printTriggerDebug) {
|
||||
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?
|
||||
|
||||
if (needEvent(stateIndex, size, multiWave, 0)) {
|
||||
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/0, stateIndex);
|
||||
if (needEvent(stateIndex, size, multiChannelStateSequence, 0)) {
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/0, stateIndex);
|
||||
trigger_event_e s = currentValue ? SHAFT_PRIMARY_RISING : SHAFT_PRIMARY_FALLING;
|
||||
if (isUsefulSignal(s PASS_ENGINE_PARAMETER_SUFFIX))
|
||||
state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
if (needEvent(stateIndex, size, multiWave, 1)) {
|
||||
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/1, stateIndex);
|
||||
if (needEvent(stateIndex, size, multiChannelStateSequence, 1)) {
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/1, stateIndex);
|
||||
trigger_event_e s = currentValue ? SHAFT_SECONDARY_RISING : SHAFT_SECONDARY_FALLING;
|
||||
if (isUsefulSignal(s PASS_ENGINE_PARAMETER_SUFFIX))
|
||||
state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
if (needEvent(stateIndex, size, multiWave, 2)) {
|
||||
pin_state_t currentValue = multiWave->getChannelState(/*phaseIndex*/2, stateIndex);
|
||||
if (needEvent(stateIndex, size, multiChannelStateSequence, 2)) {
|
||||
pin_state_t currentValue = multiChannelStateSequence->getChannelState(/*phaseIndex*/2, stateIndex);
|
||||
trigger_event_e s = currentValue ? SHAFT_3RD_RISING : SHAFT_3RD_FALLING;
|
||||
if (isUsefulSignal(s PASS_ENGINE_PARAMETER_SUFFIX))
|
||||
state->decodeTriggerEvent(s, time PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
|
|
@ -9,7 +9,7 @@ DEV_SRC_CPP = $(DEVELOPMENT_DIR)/trigger_emulator.cpp \
|
|||
$(DEVELOPMENT_DIR)/rfi_perftest.cpp \
|
||||
$(DEVELOPMENT_DIR)/engine_emulator.cpp \
|
||||
$(DEVELOPMENT_DIR)/engine_sniffer.cpp \
|
||||
$(DEVELOPMENT_DIR)/wave_analyzer.cpp \
|
||||
$(DEVELOPMENT_DIR)/logic_analyzer.cpp \
|
||||
$(DEVELOPMENT_DIR)/development/perf_trace.cpp
|
||||
|
||||
DEV_SIMULATOR_SRC_CPP = $(DEVELOPMENT_DIR)/engine_sniffer.cpp
|
|
@ -15,7 +15,7 @@
|
|||
#include "fuel_math.h"
|
||||
|
||||
#include "status_loop.h"
|
||||
#include "wave_analyzer.h"
|
||||
#include "logic_analyzer.h"
|
||||
#include "pin_repository.h"
|
||||
#include "pwm_generator_logic.h"
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 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.
|
||||
*
|
||||
* 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
|
||||
* @author Andrey Belomutskiy, (c) 2012-2019
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file wave_analyzer.cpp
|
||||
* @file logic_analyzer.cpp
|
||||
* @brief Initialization of Input Capture pins used for rusEfi console sniffer
|
||||
*
|
||||
* This file is responsible for sniffing of external digital signals and registering
|
||||
|
@ -11,9 +11,10 @@
|
|||
* @author Andrey Belomutskiy, (c) 2012-2019
|
||||
*/
|
||||
|
||||
#include "logic_analyzer.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "os_access.h"
|
||||
#include "wave_analyzer.h"
|
||||
#include "eficonsole.h"
|
||||
#include "data_buffer.h"
|
||||
#include "pin_repository.h"
|
||||
|
@ -26,7 +27,7 @@
|
|||
#include "rpm_calculator.h"
|
||||
#include "engine_sniffer.h"
|
||||
|
||||
#if EFI_WAVE_ANALYZER
|
||||
#if EFI_LOGIC_ANALYZER
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
|
@ -231,4 +232,4 @@ void initWaveAnalyzer(Logging *sharedLogger) {
|
|||
|
||||
}
|
||||
|
||||
#endif /* EFI_WAVE_ANALYZER */
|
||||
#endif /* EFI_LOGIC_ANALYZER */
|
|
@ -1,7 +1,5 @@
|
|||
/**
|
||||
* @file wave_analyzer.h
|
||||
*
|
||||
* todo: rename all this 'logic analyzer' is probably much more appropriate
|
||||
* @file logic_analyzer.h
|
||||
*
|
||||
* @date Jan 7, 2013
|
||||
* @author Andrey Belomutskiy, (c) 2012-2019
|
||||
|
@ -11,7 +9,7 @@
|
|||
|
||||
#include "global.h"
|
||||
|
||||
#if EFI_WAVE_ANALYZER
|
||||
#if EFI_LOGIC_ANALYZER
|
||||
|
||||
#include "digital_input_icu.h"
|
||||
#include "engine_sniffer.h"
|
||||
|
@ -56,5 +54,5 @@ void initWaveAnalyzer(Logging *sharedLogger);
|
|||
void printWave(Logging *logging);
|
||||
void showWaveInfo(void);
|
||||
|
||||
#endif /* EFI_WAVE_ANALYZER */
|
||||
#endif /* EFI_LOGIC_ANALYZER */
|
||||
|
|
@ -284,7 +284,7 @@ static void runChibioTest(void) {
|
|||
print("EFI_INTERNAL_ADC=%d\r\n", EFI_INTERNAL_ADC);
|
||||
print("EFI_HD44780_LCD=%d\r\n", EFI_HD44780_LCD);
|
||||
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_SENSOR_CHART=%d\r\n", EFI_SENSOR_CHART);
|
||||
print("EFI_SHAFT_POSITION_INPUT=%d\r\n", EFI_SHAFT_POSITION_INPUT);
|
||||
|
|
|
@ -122,7 +122,7 @@
|
|||
#define EFI_RTC FALSE
|
||||
#define EFI_MALFUNCTION_INDICATOR FALSE
|
||||
#define EFI_HD44780_LCD FALSE
|
||||
#define EFI_WAVE_ANALYZER FALSE
|
||||
#define EFI_LOGIC_ANALYZER FALSE
|
||||
#define EFI_PWM_TESTER FALSE
|
||||
#define TRIGGER_EXTREME_LOGGING FALSE
|
||||
#define SPARK_EXTREME_LOGGING FALSE
|
||||
|
|
|
@ -18,7 +18,7 @@ static int expectedTimeOfNextEvent;
|
|||
static int pinValue = -1;
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue