auto-sync
This commit is contained in:
parent
deee9ccb7f
commit
9ce2113f9d
|
@ -18,6 +18,8 @@ void setDodgeStratus(DECLARE_ENGINE_PARAMETER_F) {
|
|||
engineConfiguration->specs.cylindersCount = 6;
|
||||
engineConfiguration->specs.firingOrder = FO_1_THEN_2_THEN_3_THEN_4_THEN_5_THEN_6;
|
||||
|
||||
engineConfiguration->map.sensor.type = MT_DODGE_NEON_2003;
|
||||
engineConfiguration->algorithm = LM_SPEED_DENSITY;
|
||||
engineConfiguration->ignitionMode = IM_INDIVIDUAL_COILS;
|
||||
|
||||
boardConfiguration->ignitionPins[0] = GPIOC_9;
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
*/
|
||||
|
||||
#include "main.h"
|
||||
#if EFI_PROD_CODE
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
#include <nvic.h>
|
||||
#endif
|
||||
|
||||
#if !EFI_PROD_CODE && !EFI_SIMULATOR
|
||||
#if (!EFI_PROD_CODE && !EFI_SIMULATOR) || defined(__DOXYGEN__)
|
||||
|
||||
#define chThdSelf() 0
|
||||
#define getRemainingStack(x) (999999)
|
||||
|
@ -49,7 +49,7 @@
|
|||
#include "histogram.h"
|
||||
#include "fuel_math.h"
|
||||
#include "histogram.h"
|
||||
#if EFI_PROD_CODE
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
#include "rfiutil.h"
|
||||
#endif /* EFI_HISTOGRAMS */
|
||||
#include "LocalVersionHolder.h"
|
||||
|
@ -199,7 +199,7 @@ static ALWAYS_INLINE void handleSparkEvent(uint32_t eventIndex, IgnitionEvent *i
|
|||
int isIgnitionError = chargeDelayUs < 0;
|
||||
ignitionErrorDetection.add(isIgnitionError);
|
||||
if (isIgnitionError) {
|
||||
#if EFI_PROD_CODE
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
scheduleMsg(logger, "Negative spark delay=%f", chargeDelayUs);
|
||||
#endif
|
||||
chargeDelayUs = 0;
|
||||
|
@ -285,12 +285,13 @@ static ALWAYS_INLINE void handleSpark(uint32_t eventIndex, int rpm,
|
|||
static histogram_s mainLoopHisto;
|
||||
|
||||
void showMainHistogram(void) {
|
||||
#if EFI_PROD_CODE
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
printHistogram(logger, &mainLoopHisto);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ignitionCalc(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
// todo: the method name is not correct any more - no calc is done here anymore
|
||||
static ALWAYS_INLINE void ignitionMathCalc(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
||||
/**
|
||||
* Within one engine cycle all cylinders are fired with same timing advance.
|
||||
* todo: one day we can control cylinders individually?
|
||||
|
@ -305,73 +306,14 @@ static void ignitionCalc(int rpm DECLARE_ENGINE_PARAMETER_S) {
|
|||
engine->engineState.advance = -ENGINE(engineState.timingAdvance);
|
||||
}
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
/**
|
||||
* this field is used as an Expression in IAR debugger
|
||||
*/
|
||||
uint32_t *cyccnt = (uint32_t*)&DWT_CYCCNT;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is the main trigger event handler.
|
||||
* Both injection and ignition are controlled from this method.
|
||||
*/
|
||||
void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECLARE_ENGINE_PARAMETER_S) {
|
||||
engine->m.beforeMainTrigger = GET_TIMESTAMP();
|
||||
if (hasFirmwareError()) {
|
||||
/**
|
||||
* In case on a major error we should not process any more events.
|
||||
* TODO: add 'pin shutdown' invocation somewhere
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
(void) ckpSignalType;
|
||||
efiAssertVoid(eventIndex < 2 * engine->triggerShape.getSize(), "trigger/event index");
|
||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#2");
|
||||
|
||||
int rpm = getRpmE(engine);
|
||||
if (rpm == 0) {
|
||||
// this happens while we just start cranking
|
||||
// todo: check for 'trigger->is_synchnonized?'
|
||||
return;
|
||||
}
|
||||
if (rpm == NOISY_RPM) {
|
||||
warning(OBD_Camshaft_Position_Sensor_Circuit_Range_Performance, "noisy trigger");
|
||||
return;
|
||||
}
|
||||
if (rpm > engineConfiguration->rpmHardLimit) {
|
||||
warning(OBD_PCM_Processor_Fault, "skipping stroke due to rpm=%d", rpm);
|
||||
return;
|
||||
}
|
||||
|
||||
#if EFI_HISTOGRAMS && EFI_PROD_CODE
|
||||
int beforeCallback = hal_lld_get_counter_value();
|
||||
#endif
|
||||
|
||||
int revolutionIndex = engine->rpmCalculator.getRevolutionCounter() % 2;
|
||||
|
||||
if (eventIndex == 0) {
|
||||
if (triggerVersion.isOld())
|
||||
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
|
||||
}
|
||||
|
||||
if (engineConfiguration->useOnlyFrontForTrigger && engineConfiguration->ignMathCalculateAtIndex % 2 != 0) {
|
||||
firmwareError("invalid ignMathCalculateAtIndex %d", engineConfiguration->ignMathCalculateAtIndex);
|
||||
}
|
||||
|
||||
if (eventIndex == engineConfiguration->ignMathCalculateAtIndex) {
|
||||
if (engineConfiguration->externalKnockSenseAdc != EFI_ADC_NONE) {
|
||||
float externalKnockValue = getVoltageDivided("knock", engineConfiguration->externalKnockSenseAdc);
|
||||
engine->knockLogic(externalKnockValue);
|
||||
}
|
||||
|
||||
engine->m.beforeIgnitionMath = GET_TIMESTAMP();
|
||||
ignitionCalc(rpm PASS_ENGINE_PARAMETER);
|
||||
engine->m.ignitionMathTime = GET_TIMESTAMP() - engine->m.beforeIgnitionMath;
|
||||
}
|
||||
|
||||
if (eventIndex == 0) {
|
||||
static ALWAYS_INLINE void scheduleIgnitionAndFuelEvents(int rpm, int revolutionIndex DECLARE_ENGINE_PARAMETER_S) {
|
||||
engine->m.beforeFuelCalc = GET_TIMESTAMP();
|
||||
ENGINE(fuelMs) = getFuelMs(rpm PASS_ENGINE_PARAMETER) * engineConfiguration->globalFuelCorrection;
|
||||
engine->m.fuelCalcTime = GET_TIMESTAMP() - engine->m.beforeFuelCalc;
|
||||
|
@ -381,7 +323,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL
|
|||
* TODO: warning. there is a bit of a hack here, todo: improve.
|
||||
* currently output signals/times signalTimerUp from the previous revolutions could be
|
||||
* still used because they have crossed the revolution boundary
|
||||
* but we are already repurposing the output signals, but everything works because we
|
||||
* but we are already re-purposing the output signals, but everything works because we
|
||||
* are not affecting that space in memory. todo: use two instances of 'ignitionSignals'
|
||||
*/
|
||||
float maxAllowedDwellAngle = (int) (engineConfiguration->engineCycle / 2); // the cast is about making Coverity happy
|
||||
|
@ -420,13 +362,77 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECL
|
|||
engineConfiguration->injectionMode PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
engine->m.injectonSchTime = GET_TIMESTAMP() - engine->m.beforeInjectonSch;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main trigger event handler.
|
||||
* Both injection and ignition are controlled from this method.
|
||||
*/
|
||||
void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t eventIndex DECLARE_ENGINE_PARAMETER_S) {
|
||||
engine->m.beforeMainTrigger = GET_TIMESTAMP();
|
||||
if (hasFirmwareError()) {
|
||||
/**
|
||||
* In case on a major error we should not process any more events.
|
||||
* TODO: add 'pin shutdown' invocation somewhere
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
(void) ckpSignalType;
|
||||
efiAssertVoid(eventIndex < 2 * engine->triggerShape.getSize(), "trigger/event index");
|
||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#2");
|
||||
|
||||
int rpm = getRpmE(engine);
|
||||
if (rpm == 0) {
|
||||
// this happens while we just start cranking
|
||||
// todo: check for 'trigger->is_synchnonized?'
|
||||
return;
|
||||
}
|
||||
if (rpm == NOISY_RPM) {
|
||||
warning(OBD_Camshaft_Position_Sensor_Circuit_Range_Performance, "noisy trigger");
|
||||
return;
|
||||
}
|
||||
if (rpm > engineConfiguration->rpmHardLimit) {
|
||||
warning(OBD_PCM_Processor_Fault, "skipping stroke due to rpm=%d", rpm);
|
||||
return;
|
||||
}
|
||||
|
||||
#if (EFI_HISTOGRAMS && EFI_PROD_CODE) || defined(__DOXYGEN__)
|
||||
int beforeCallback = hal_lld_get_counter_value();
|
||||
#endif
|
||||
|
||||
int revolutionIndex = engine->rpmCalculator.getRevolutionCounter() % 2;
|
||||
|
||||
if (eventIndex == 0) {
|
||||
if (triggerVersion.isOld())
|
||||
prepareOutputSignals(PASS_ENGINE_PARAMETER_F);
|
||||
}
|
||||
|
||||
if (engineConfiguration->useOnlyFrontForTrigger && engineConfiguration->ignMathCalculateAtIndex % 2 != 0) {
|
||||
firmwareError("invalid ignMathCalculateAtIndex %d", engineConfiguration->ignMathCalculateAtIndex);
|
||||
}
|
||||
|
||||
if (eventIndex == engineConfiguration->ignMathCalculateAtIndex) {
|
||||
if (engineConfiguration->externalKnockSenseAdc != EFI_ADC_NONE) {
|
||||
float externalKnockValue = getVoltageDivided("knock", engineConfiguration->externalKnockSenseAdc);
|
||||
engine->knockLogic(externalKnockValue);
|
||||
}
|
||||
|
||||
engine->m.beforeIgnitionMath = GET_TIMESTAMP();
|
||||
ignitionMathCalc(rpm PASS_ENGINE_PARAMETER);
|
||||
engine->m.ignitionMathTime = GET_TIMESTAMP() - engine->m.beforeIgnitionMath;
|
||||
}
|
||||
|
||||
if (eventIndex == 0) {
|
||||
scheduleIgnitionAndFuelEvents(rpm, revolutionIndex PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
// triggerEventsQueue.executeAll(getCrankEventCounter());
|
||||
|
||||
handleFuel(eventIndex, rpm PASS_ENGINE_PARAMETER);
|
||||
handleSpark(eventIndex, rpm, &engine->engineConfiguration2->ignitionEvents[revolutionIndex] PASS_ENGINE_PARAMETER);
|
||||
#if EFI_HISTOGRAMS && EFI_PROD_CODE
|
||||
#if (EFI_HISTOGRAMS && EFI_PROD_CODE) || defined(__DOXYGEN__)
|
||||
int diff = hal_lld_get_counter_value() - beforeCallback;
|
||||
if (diff > 0)
|
||||
hsAdd(&mainLoopHisto, diff);
|
||||
|
|
|
@ -291,5 +291,5 @@ int getRusEfiVersion(void) {
|
|||
return 123; // this is here to make the compiler happy about the unused array
|
||||
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
||||
return 3211; // this is here to make the compiler happy about the unused array
|
||||
return 20150903;
|
||||
return 20150906;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue