refactoring trigger system
This commit is contained in:
parent
2df38cdd91
commit
5ccc3bbef5
|
@ -30,6 +30,7 @@ typedef int8_t pin_state_t;
|
||||||
*
|
*
|
||||||
* @brief PWM configuration for the specific output pin
|
* @brief PWM configuration for the specific output pin
|
||||||
*/
|
*/
|
||||||
|
// todo: rename to SingleWave
|
||||||
class single_wave_s {
|
class single_wave_s {
|
||||||
public:
|
public:
|
||||||
single_wave_s();
|
single_wave_s();
|
||||||
|
@ -42,16 +43,20 @@ public:
|
||||||
int getState(int index);
|
int getState(int index);
|
||||||
void setState(int index, int state);
|
void setState(int index, int state);
|
||||||
|
|
||||||
// todo: make this private
|
// todo: make this private by using 'getState' and 'setState' methods
|
||||||
pin_state_t *pinStates;
|
pin_state_t *pinStates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents multi-channel logical signals with shared time axis
|
||||||
|
*
|
||||||
|
*/
|
||||||
class MultiWave {
|
class MultiWave {
|
||||||
public:
|
public:
|
||||||
void baseConstructor();
|
void baseConstructor();
|
||||||
MultiWave();
|
MultiWave();
|
||||||
MultiWave(float *st, single_wave_s *waves);
|
MultiWave(float *switchTimes, single_wave_s *waves);
|
||||||
void init(float *st, single_wave_s *waves);
|
void init(float *switchTimes, single_wave_s *waves);
|
||||||
void reset(void);
|
void reset(void);
|
||||||
float getSwitchTime(int phaseIndex) const;
|
float getSwitchTime(int phaseIndex) const;
|
||||||
void setSwitchTime(int phaseIndex, float value);
|
void setSwitchTime(int phaseIndex, float value);
|
||||||
|
|
|
@ -294,6 +294,14 @@ extern bool printTriggerDebug;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void TriggerShape::addEvent2(angle_t angle, trigger_wheel_e const waveIndex, trigger_value_e const stateParam DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
void TriggerShape::addEvent2(angle_t angle, trigger_wheel_e const waveIndex, trigger_value_e const stateParam DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
/**
|
||||||
|
* While '720' value works perfectly it has not much sense for crank sensor-only scenario.
|
||||||
|
*/
|
||||||
|
addEvent(angle / getEngineCycle(operationMode), engineConfiguration->useOnlyRisingEdgeForTrigger, waveIndex, stateParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriggerShape::addEvent(angle_t angle, bool useOnlyRisingEdgeForTrigger, trigger_wheel_e const waveIndex, trigger_value_e const stateParam) {
|
||||||
|
|
||||||
efiAssertVoid(CUSTOM_OMODE_UNDEF, operationMode != OM_NONE, "operationMode not set");
|
efiAssertVoid(CUSTOM_OMODE_UNDEF, operationMode != OM_NONE, "operationMode not set");
|
||||||
|
|
||||||
efiAssertVoid(CUSTOM_ERR_6598, waveIndex!= T_SECONDARY || needSecondTriggerInput, "secondary needed or not?");
|
efiAssertVoid(CUSTOM_ERR_6598, waveIndex!= T_SECONDARY || needSecondTriggerInput, "secondary needed or not?");
|
||||||
|
@ -316,15 +324,8 @@ void TriggerShape::addEvent2(angle_t angle, trigger_wheel_e const waveIndex, tri
|
||||||
triggerSignals[privateTriggerDefinitionSize] = signal;
|
triggerSignals[privateTriggerDefinitionSize] = signal;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float engineCycle = getEngineCycle(operationMode);
|
|
||||||
|
|
||||||
/**
|
if (!useOnlyRisingEdgeForTrigger || stateParam == TV_RISE) {
|
||||||
* While '720' value works perfectly it has not much sense for crank sensor-only scenario.
|
|
||||||
* todo: accept angle as a value in the 0..1 range?
|
|
||||||
*/
|
|
||||||
angle /= engineCycle;
|
|
||||||
|
|
||||||
if (!engineConfiguration->useOnlyRisingEdgeForTrigger || stateParam == TV_RISE) {
|
|
||||||
expectedEventCount[waveIndex]++;
|
expectedEventCount[waveIndex]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#include "EfiWave.h"
|
#include "EfiWave.h"
|
||||||
|
// todo: this header should know nothing about engine or engine configuration. todo: refactor
|
||||||
#include "engine_configuration.h"
|
#include "engine_configuration.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,6 +173,7 @@ public:
|
||||||
*/
|
*/
|
||||||
int privateTriggerDefinitionSize;
|
int privateTriggerDefinitionSize;
|
||||||
|
|
||||||
|
void addEvent(angle_t angle, bool useOnlyRisingEdgeForTrigger, trigger_wheel_e const waveIndex, trigger_value_e const state);
|
||||||
void addEvent2(angle_t angle, trigger_wheel_e const waveIndex, trigger_value_e const state DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void addEvent2(angle_t angle, trigger_wheel_e const waveIndex, trigger_value_e const state DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
void addEvent2(angle_t angle, trigger_wheel_e const waveIndex, trigger_value_e const stateParam, float filterLeft, float filterRight DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void addEvent2(angle_t angle, trigger_wheel_e const waveIndex, trigger_value_e const stateParam, float filterLeft, float filterRight DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
*
|
*
|
||||||
* Global utility header file for firmware
|
* Global utility header file for firmware
|
||||||
*
|
*
|
||||||
|
* Simulator and unit tests have their own version of this header
|
||||||
|
*
|
||||||
|
* While this header contains 'EXTERN_ENGINE' and 'DECLARE_ENGINE_PARAMETER_SIGNATURE' magic,
|
||||||
|
* this header is not allowed to actually include higher-level engine related headers
|
||||||
|
*
|
||||||
* @date May 27, 2013
|
* @date May 27, 2013
|
||||||
* @author Andrey Belomutskiy, (c) 2012-2017
|
* @author Andrey Belomutskiy, (c) 2012-2017
|
||||||
*/
|
*/
|
||||||
|
@ -86,8 +91,6 @@ typedef unsigned int time_t;
|
||||||
#define CCM_OPTIONAL
|
#define CCM_OPTIONAL
|
||||||
#endif /* EFI_USE_CCM */
|
#endif /* EFI_USE_CCM */
|
||||||
|
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The following obscurantism is a hack to reduce stack usage, maybe even a questionable performance
|
* The following obscurantism is a hack to reduce stack usage, maybe even a questionable performance
|
||||||
* optimization.
|
* optimization.
|
||||||
|
@ -127,11 +130,6 @@ typedef unsigned int time_t;
|
||||||
#define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x
|
#define CONFIG(x) persistentState.persistentConfiguration.engineConfiguration.x
|
||||||
#define ENGINE(x) _engine.x
|
#define ENGINE(x) _engine.x
|
||||||
|
|
||||||
#else
|
|
||||||
#define EXTERN_ENGINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* low-level function is used here to reduce stack usage
|
* low-level function is used here to reduce stack usage
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue