parent
efacf26554
commit
96a126d60f
|
@ -368,12 +368,9 @@ uint32_t *cyccnt = (uint32_t*) &DWT->CYCCNT;
|
||||||
* This is the main trigger event handler.
|
* This is the main trigger event handler.
|
||||||
* Both injection and ignition are controlled from this method.
|
* Both injection and ignition are controlled from this method.
|
||||||
*/
|
*/
|
||||||
void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
ScopePerf perf(PE::MainTriggerCallback);
|
ScopePerf perf(PE::MainTriggerCallback);
|
||||||
|
|
||||||
(void) ckpSignalType;
|
|
||||||
|
|
||||||
|
|
||||||
if (CONFIG(vvtMode) == MIATA_NB2 && ENGINE(triggerCentral.vvtSyncTimeNt) == 0) {
|
if (CONFIG(vvtMode) == MIATA_NB2 && ENGINE(triggerCentral.vvtSyncTimeNt) == 0) {
|
||||||
// this is a bit spaghetti code for sure
|
// this is a bit spaghetti code for sure
|
||||||
// do not spark & do not fuel until we have VVT sync. NB2 is a special case
|
// do not spark & do not fuel until we have VVT sync. NB2 is a special case
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
void initMainEventListener(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void initMainEventListener(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
void startPrimeInjectionPulse(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void startPrimeInjectionPulse(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
|
|
|
@ -267,14 +267,13 @@ void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
/**
|
/**
|
||||||
* Shaft Position callback used to schedule start and end of MAP averaging
|
* Shaft Position callback used to schedule start and end of MAP averaging
|
||||||
*/
|
*/
|
||||||
void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
|
void mapAveragingTriggerCallback(
|
||||||
uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
|
|
||||||
ScopePerf perf(PE::MapAveragingTriggerCallback);
|
ScopePerf perf(PE::MapAveragingTriggerCallback);
|
||||||
|
|
||||||
#if EFI_ENGINE_CONTROL
|
#if EFI_ENGINE_CONTROL
|
||||||
// this callback is invoked on interrupt thread
|
// this callback is invoked on interrupt thread
|
||||||
UNUSED(ckpEventType);
|
|
||||||
if (index != (uint32_t)CONFIG(mapAveragingSchedulingAtIndex))
|
if (index != (uint32_t)CONFIG(mapAveragingSchedulingAtIndex))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -290,12 +289,14 @@ void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
|
||||||
measurementsPerRevolution = measurementsPerRevolutionCounter;
|
measurementsPerRevolution = measurementsPerRevolutionCounter;
|
||||||
measurementsPerRevolutionCounter = 0;
|
measurementsPerRevolutionCounter = 0;
|
||||||
|
|
||||||
|
// todo: this could be pre-calculated
|
||||||
int samplingCount = CONFIG(measureMapOnlyInOneCylinder) ? 1 : engineConfiguration->specs.cylindersCount;
|
int samplingCount = CONFIG(measureMapOnlyInOneCylinder) ? 1 : engineConfiguration->specs.cylindersCount;
|
||||||
|
|
||||||
for (int i = 0; i < samplingCount; i++) {
|
for (int i = 0; i < samplingCount; i++) {
|
||||||
angle_t samplingStart = ENGINE(engineState.mapAveragingStart[i]);
|
angle_t samplingStart = ENGINE(engineState.mapAveragingStart[i]);
|
||||||
|
|
||||||
angle_t samplingDuration = ENGINE(engineState.mapAveragingDuration);
|
angle_t samplingDuration = ENGINE(engineState.mapAveragingDuration);
|
||||||
|
// todo: this assertion could be moved out of trigger handler
|
||||||
assertAngleRange(samplingDuration, "samplingDuration", CUSTOM_ERR_6563);
|
assertAngleRange(samplingDuration, "samplingDuration", CUSTOM_ERR_6563);
|
||||||
if (samplingDuration <= 0) {
|
if (samplingDuration <= 0) {
|
||||||
warning(CUSTOM_MAP_ANGLE_PARAM, "map sampling angle should be positive");
|
warning(CUSTOM_MAP_ANGLE_PARAM, "map sampling angle should be positive");
|
||||||
|
@ -310,6 +311,7 @@ void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: pre-calculate samplingEnd for each cylinder
|
||||||
fixAngle(samplingEnd, "samplingEnd", CUSTOM_ERR_6563);
|
fixAngle(samplingEnd, "samplingEnd", CUSTOM_ERR_6563);
|
||||||
// only if value is already prepared
|
// only if value is already prepared
|
||||||
int structIndex = getRevolutionCounter() % 2;
|
int structIndex = getRevolutionCounter() % 2;
|
||||||
|
|
|
@ -18,7 +18,7 @@ void mapAveragingAdcCallback(adcsample_t newValue);
|
||||||
void initMapAveraging(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void initMapAveraging(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
void refreshMapAveragingPreCalc(DECLARE_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
|
void mapAveragingTriggerCallback(
|
||||||
uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
|
|
|
@ -325,9 +325,8 @@ static void onTdcCallback(Engine *engine) {
|
||||||
/**
|
/**
|
||||||
* This trigger callback schedules the actual physical TDC callback in relation to trigger synchronization point.
|
* This trigger callback schedules the actual physical TDC callback in relation to trigger synchronization point.
|
||||||
*/
|
*/
|
||||||
void tdcMarkCallback(trigger_event_e ckpSignalType,
|
void tdcMarkCallback(
|
||||||
uint32_t index0, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
uint32_t index0, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
(void) ckpSignalType;
|
|
||||||
bool isTriggerSynchronizationPoint = index0 == 0;
|
bool isTriggerSynchronizationPoint = index0 == 0;
|
||||||
if (isTriggerSynchronizationPoint && ENGINE(isEngineChartEnabled)) {
|
if (isTriggerSynchronizationPoint && ENGINE(isEngineChartEnabled)) {
|
||||||
// two instances of scheduling_s are needed to properly handle event overlap
|
// two instances of scheduling_s are needed to properly handle event overlap
|
||||||
|
|
|
@ -156,7 +156,7 @@ private:
|
||||||
|
|
||||||
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void rpmShaftPositionCallback(trigger_event_e ckpSignalType, uint32_t index, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
void tdcMarkCallback(trigger_event_e ckpSignalType,
|
void tdcMarkCallback(
|
||||||
uint32_t index0, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
uint32_t index0, efitick_t edgeTimestamp DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -489,12 +489,12 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
||||||
rpmShaftPositionCallback(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
rpmShaftPositionCallback(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
#if !EFI_UNIT_TEST
|
#if !EFI_UNIT_TEST
|
||||||
tdcMarkCallback(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
tdcMarkCallback(triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !EFI_UNIT_TEST
|
#if !EFI_UNIT_TEST
|
||||||
#if EFI_SHAFT_POSITION_INPUT
|
#if EFI_SHAFT_POSITION_INPUT
|
||||||
mapAveragingTriggerCallback(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
mapAveragingTriggerCallback(triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
#endif /* EFI_SHAFT_POSITION_INPUT */
|
#endif /* EFI_SHAFT_POSITION_INPUT */
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
||||||
(listener)(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
(listener)(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
mainTriggerCallback(signal, triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
mainTriggerCallback(triggerIndexForListeners, timestamp PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue