VVT support for VAG trigger #883
This commit is contained in:
parent
3101475769
commit
10a6661fa5
|
@ -42,8 +42,6 @@
|
||||||
#include "gpio/tle8888.h"
|
#include "gpio/tle8888.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static TriggerState initState CCM_OPTIONAL;
|
|
||||||
|
|
||||||
LoggingWithStorage engineLogger("engine");
|
LoggingWithStorage engineLogger("engine");
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
@ -89,6 +87,8 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
void Engine::initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
static TriggerState initState;
|
||||||
|
|
||||||
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
|
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
|
||||||
// we have a confusing threading model so some synchronization would not hurt
|
// we have a confusing threading model so some synchronization would not hurt
|
||||||
bool alreadyLocked = lockAnyContext();
|
bool alreadyLocked = lockAnyContext();
|
||||||
|
@ -97,15 +97,6 @@ void Engine::initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_
|
||||||
engineConfiguration->ambiguousOperationMode,
|
engineConfiguration->ambiguousOperationMode,
|
||||||
engineConfiguration->useOnlyRisingEdgeForTrigger, &engineConfiguration->trigger));
|
engineConfiguration->useOnlyRisingEdgeForTrigger, &engineConfiguration->trigger));
|
||||||
|
|
||||||
if (TRIGGER_WAVEFORM(bothFrontsRequired) && engineConfiguration->useOnlyRisingEdgeForTrigger) {
|
|
||||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
|
||||||
firmwareError(CUSTOM_ERR_BOTH_FRONTS_REQUIRED, "trigger: both fronts required");
|
|
||||||
#else
|
|
||||||
warning(CUSTOM_ERR_BOTH_FRONTS_REQUIRED, "trigger: both fronts required");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!TRIGGER_WAVEFORM(shapeDefinitionError)) {
|
if (!TRIGGER_WAVEFORM(shapeDefinitionError)) {
|
||||||
/**
|
/**
|
||||||
* 'initState' instance of TriggerState is used only to initialize 'this' TriggerWaveform instance
|
* 'initState' instance of TriggerState is used only to initialize 'this' TriggerWaveform instance
|
||||||
|
@ -130,10 +121,11 @@ void Engine::initializeTriggerWaveform(Logging *logger DECLARE_ENGINE_PARAMETER_
|
||||||
engineConfiguration->ambiguousOperationMode,
|
engineConfiguration->ambiguousOperationMode,
|
||||||
engineConfiguration->useOnlyRisingEdgeForTrigger, &config);
|
engineConfiguration->useOnlyRisingEdgeForTrigger, &config);
|
||||||
|
|
||||||
|
ENGINE(triggerCentral).vvtShape.initializeSyncPoint(&initState,
|
||||||
|
&engine->primaryTriggerConfiguration,
|
||||||
|
&config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!alreadyLocked) {
|
if (!alreadyLocked) {
|
||||||
unlockAnyContext();
|
unlockAnyContext();
|
||||||
}
|
}
|
||||||
|
@ -250,11 +242,11 @@ void Engine::onTriggerSignalEvent(efitick_t nowNt) {
|
||||||
lastTriggerToothEventTimeNt = nowNt;
|
lastTriggerToothEventTimeNt = nowNt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Engine() : primaryTriggerConfiguration(this) {
|
Engine::Engine() : primaryTriggerConfiguration(this), vvtTriggerConfiguration(this) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::Engine(persistent_config_s *config) : primaryTriggerConfiguration(this) {
|
Engine::Engine(persistent_config_s *config) : primaryTriggerConfiguration(this), vvtTriggerConfiguration(this) {
|
||||||
setConfig(config);
|
setConfig(config);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,18 @@ private:
|
||||||
Engine *engine;
|
Engine *engine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VvtTriggerConfiguration : public TriggerConfiguration {
|
||||||
|
public:
|
||||||
|
VvtTriggerConfiguration(Engine *engine);
|
||||||
|
bool isUseOnlyRisingEdgeForTrigger() const;
|
||||||
|
bool isSilentTriggerError() const;
|
||||||
|
bool isVerboseTriggerSynchDetails() const;
|
||||||
|
debug_mode_e getDebugMode() const;
|
||||||
|
trigger_type_e getType() const;
|
||||||
|
private:
|
||||||
|
Engine *engine;
|
||||||
|
};
|
||||||
|
|
||||||
class Engine : public TriggerStateListener {
|
class Engine : public TriggerStateListener {
|
||||||
public:
|
public:
|
||||||
explicit Engine(persistent_config_s *config);
|
explicit Engine(persistent_config_s *config);
|
||||||
|
@ -81,6 +93,7 @@ public:
|
||||||
cyclic_buffer<int> triggerErrorDetection;
|
cyclic_buffer<int> triggerErrorDetection;
|
||||||
|
|
||||||
PrimaryTriggerConfiguration primaryTriggerConfiguration;
|
PrimaryTriggerConfiguration primaryTriggerConfiguration;
|
||||||
|
VvtTriggerConfiguration vvtTriggerConfiguration;
|
||||||
|
|
||||||
TCU tcu;
|
TCU tcu;
|
||||||
|
|
||||||
|
|
|
@ -305,3 +305,26 @@ bool PrimaryTriggerConfiguration::isVerboseTriggerSynchDetails() const {
|
||||||
return engine->engineConfigurationPtr->verboseTriggerSynchDetails;
|
return engine->engineConfigurationPtr->verboseTriggerSynchDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VvtTriggerConfiguration::VvtTriggerConfiguration(Engine *engine) {
|
||||||
|
this->engine = engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VvtTriggerConfiguration::isUseOnlyRisingEdgeForTrigger() const {
|
||||||
|
return engine->engineConfigurationPtr->useOnlyRisingEdgeForTrigger;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug_mode_e VvtTriggerConfiguration::getDebugMode() const {
|
||||||
|
return engine->engineConfigurationPtr->debugMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger_type_e VvtTriggerConfiguration::getType() const {
|
||||||
|
return engine->engineConfigurationPtr->trigger.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VvtTriggerConfiguration::isSilentTriggerError() const {
|
||||||
|
return engine->engineConfigurationPtr->silentTriggerError;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VvtTriggerConfiguration::isVerboseTriggerSynchDetails() const {
|
||||||
|
return engine->engineConfigurationPtr->verboseTriggerSynchDetails;
|
||||||
|
}
|
||||||
|
|
|
@ -134,6 +134,8 @@ angle_t TriggerWaveform::getCycleDuration() const {
|
||||||
/**
|
/**
|
||||||
* Trigger event count equals engine cycle event count if we have a cam sensor.
|
* Trigger event count equals engine cycle event count if we have a cam sensor.
|
||||||
* Two trigger cycles make one engine cycle in case of a four stroke engine If we only have a cranksensor.
|
* Two trigger cycles make one engine cycle in case of a four stroke engine If we only have a cranksensor.
|
||||||
|
*
|
||||||
|
* 'engine->engineCycleEventCount' hold a pre-calculated copy of this value as a performance optimization
|
||||||
*/
|
*/
|
||||||
size_t TriggerWaveform::getLength() const {
|
size_t TriggerWaveform::getLength() const {
|
||||||
/**
|
/**
|
||||||
|
@ -674,4 +676,13 @@ void TriggerWaveform::initializeTriggerWaveform(Logging *logger, operation_mode_
|
||||||
wave.checkSwitchTimes(getSize(), getCycleDuration());
|
wave.checkSwitchTimes(getSize(), getCycleDuration());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bothFrontsRequired && useOnlyRisingEdgeForTrigger) {
|
||||||
|
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||||
|
firmwareError(CUSTOM_ERR_BOTH_FRONTS_REQUIRED, "trigger: both fronts required");
|
||||||
|
#else
|
||||||
|
warning(CUSTOM_ERR_BOTH_FRONTS_REQUIRED, "trigger: both fronts required");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue