auto-sync

This commit is contained in:
rusEfi 2015-04-29 00:07:08 -04:00
parent ce30439d68
commit d9563ed54d
6 changed files with 28 additions and 6 deletions

View File

@ -15,6 +15,7 @@
#include "efiGpio.h"
#include "trigger_central.h"
#include "fuel_math.h"
#include "engine_math.h"
#if EFI_PROD_CODE
#include "injector_central.h"
@ -158,6 +159,13 @@ void Engine::watchdog() {
#endif
}
void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
int rpm = rpmCalculator.rpmValue;
engineState.sparkDwell = getSparkDwellMsT(rpm PASS_ENGINE_PARAMETER);
dwellAngle = engineState.sparkDwell / getOneDegreeTimeMs(rpm);
}
StartupFuelPumping::StartupFuelPumping() {
isTpsAbove50 = false;
pumpsCounter = 0;

View File

@ -86,6 +86,15 @@ public:
angle_t mapAveragingStart;
angle_t mapAveragingDuration;
// spark-related
float sparkDwell;
float timingAdvance;
// fuel-related;
float iatFuelCorrection;
float cltFuelCorrection;
float injectorLag;
};
class RpmCalculator;
@ -163,6 +172,8 @@ public:
angle_t dwellAngle;
angle_t advance;
void periodicFastCallback(DECLARE_ENGINE_PARAMETER_F);
bool_t clutchUpState;
bool_t clutchDownState;

View File

@ -219,8 +219,6 @@ static void periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
if (isValidRpm(rpm)) {
MAP_sensor_config_s * c = &engineConfiguration->map;
engine->engineState.mapAveragingStart = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle, MAP_ANGLE_SIZE);
engine->engineState.mapAveragingDuration = interpolate2d(rpm, c->samplingWindowBins, c->samplingWindow, MAP_WINDOW_SIZE);
} else {
@ -228,6 +226,8 @@ static void periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
engine->engineState.mapAveragingDuration = NAN;
}
engine->engineState.sparkDwell = getSparkDwellMsT(rpm PASS_ENGINE_PARAMETER);
chVTSetAny(&periodicFastTimer, 20 * TICKS_IN_MS, (vtfunc_t) &periodicFastCallback, engine);
}

View File

@ -177,7 +177,7 @@ static ALWAYS_INLINE void handleFuel(uint32_t eventIndex, int rpm DECLARE_ENGINE
static ALWAYS_INLINE void handleSparkEvent(uint32_t eventIndex, IgnitionEvent *iEvent,
int rpm DECLARE_ENGINE_PARAMETER_S) {
float dwellMs = getSparkDwellMsT(rpm PASS_ENGINE_PARAMETER);
float dwellMs = engine->engineState.sparkDwell;
if (cisnan(dwellMs) || dwellMs < 0) {
firmwareError("invalid dwell: %f at %d", dwellMs, rpm);
return;
@ -256,7 +256,7 @@ static ALWAYS_INLINE void handleSpark(uint32_t eventIndex, int rpm,
scheduling_s * sDown = &current->signalTimerDown;
float timeTillIgnitionUs = engine->rpmCalculator.oneDegreeUs * current->sparkPosition.angleOffset;
float timeTillIgnitionUs = ENGINE(rpmCalculator.oneDegreeUs) * current->sparkPosition.angleOffset;
scheduleTask("spark 2down", sDown, (int) timeTillIgnitionUs, (schfunc_t) &turnPinLow, current->output);
}
}

View File

@ -290,5 +290,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 20150427;
return 20150428;
}

View File

@ -405,9 +405,12 @@ static void testRpmCalculator(void) {
debugSignalExecutor = true;
timeNow += 5000; // 5ms
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_F);
eth.triggerCentral.handleShaftSignal(SHAFT_PRIMARY_UP PASS_ENGINE_PARAMETER);
assertEquals(4.5, eth.engine.dwellAngle);
assertEqualsM("dwell", 4.5, eth.engine.dwellAngle);
assertEqualsM("fuel", 3.03, eth.engine.fuelMs);
assertEqualsM("one degree", 111.1111, eth.engine.rpmCalculator.oneDegreeUs);
assertEqualsM("size", 6, ilist->size);