From 3991db4f011d8741115f015797543ca2d1cc7cdf Mon Sep 17 00:00:00 2001 From: rusEfi Date: Thu, 6 Nov 2014 21:03:12 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/algo/wave_chart.cpp | 9 ++++++--- firmware/controllers/trigger/main_trigger_callback.cpp | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/firmware/controllers/algo/wave_chart.cpp b/firmware/controllers/algo/wave_chart.cpp index b36f0585fa..a7dbf862f2 100644 --- a/firmware/controllers/algo/wave_chart.cpp +++ b/firmware/controllers/algo/wave_chart.cpp @@ -157,12 +157,12 @@ void WaveChart::addWaveChartEvent3(const char *name, const char * msg, const cha int beforeCallback = hal_lld_get_counter_value(); #endif - uint64_t nowUs = getTimeNowUs(); + uint64_t nowNt = getTimeNowNt(); bool alreadyLocked = lockOutputBuffer(); // we have multiple threads writing to the same output buffer if (counter == 0) { - startTimeNt = US2NT(nowUs); + startTimeNt = nowNt; } counter++; @@ -172,8 +172,11 @@ void WaveChart::addWaveChartEvent3(const char *name, const char * msg, const cha /** * todo: migrate to binary fractions in order to eliminate * this division? I do not like division + * + * at least that's 32 bit division now */ - uint64_t time100 = (nowUs - NT2US(startTimeNt)) / 10; + uint32_t diffNt = nowNt - startTimeNt; + uint32_t time100 = diffNt / 10 / 168; if (remainingSize(&logging) > 30) { diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index fa7c89490e..159c4d9672 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -76,6 +76,9 @@ static cyclic_buffer ignitionErrorDetection; static Logging logger; static void handleFuelInjectionEvent(MainTriggerCallback *mainTriggerCallback, ActuatorEvent *event, int rpm) { + /** + * todo: we do not really need to calculate fuel for each individual cylinder + */ float fuelMs = getFuelMs(rpm, mainTriggerCallback->engine) * mainTriggerCallback->engineConfiguration->globalFuelCorrection; if (cisnan(fuelMs)) { @@ -301,7 +304,6 @@ void onTriggerEvent(trigger_event_e ckpSignalType, uint32_t eventIndex, MainTrig triggerEventsQueue.executeAll(getCrankEventCounter()); -//todo handleFuel(mainTriggerCallback->engine, mainTriggerCallback, eventIndex, rpm); handleFuel(&engine, mainTriggerCallback, eventIndex, rpm); handleSpark(mainTriggerCallback, eventIndex, rpm, &mainTriggerCallback->engineConfiguration2->engineEventConfiguration.ignitionEvents[revolutionIndex]);