static void printInfo(systime_t nowSeconds) { /** * we report the version every 4 seconds - this way the console does not need to * request it and we will display it pretty soon */ if (overflowDiff(nowSeconds, timeOfPreviousPrintVersion) < 4) { return; } timeOfPreviousPrintVersion = nowSeconds; appendPrintf(&logger, "%s%s%d@%s %s %d%s", RUS_EFI_VERSION_TAG, DELIMETER, getRusEfiVersion(), VCS_VERSION, getConfigurationName(engineConfiguration->engineType), getTimeNowSeconds(), DELIMETER); #if EFI_PROD_CODE || defined(__DOXYGEN__) printOutPin(CRANK1, boardConfiguration->triggerInputPins[0]); printOutPin(CRANK2, boardConfiguration->triggerInputPins[1]); #if EFI_WAVE_ANALYZER || defined(__DOXYGEN__) printOutPin(WA_CHANNEL_1, boardConfiguration->logicAnalyzerPins[0]); printOutPin(WA_CHANNEL_2, boardConfiguration->logicAnalyzerPins[1]); #endif for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { printOutPin(enginePins.coils[i].name, boardConfiguration->ignitionPins[i]); printOutPin(enginePins.injectors[i].name, boardConfiguration->injectionPins[i]); } #endif }
/** * @return Current crankshaft angle, 0 to 720 for four-stroke */ float getCrankshaftAngle(time_t time) { int timeSinceZeroAngle = overflowDiff(time, rpmState.lastRpmEventTime); float cRevolutionTime = getCrankshaftRevolutionTime(rpmState.rpm); return 360 * timeSinceZeroAngle / cRevolutionTime; }
/** * this method is lock-free thread-safe if invoked only from one thread */ void saveTpsState(time_t now, float curValue) { int tpsNextIndex = (tpsRocIndex + 1) % 2; tps_roc_s *cur = &states[tpsRocIndex]; tps_roc_s *next = &states[tpsNextIndex]; next->prevTime = cur->curTime; next->prevValue = cur->curValue; next->curTime = now; next->curValue = curValue; int diffSysticks = overflowDiff(now, cur->curTime); float diffSeconds = diffSysticks * 1.0 / CH_FREQUENCY; next->rateOfChange = (curValue - cur->curValue) / diffSeconds; // here we update volatile index tpsRocIndex = tpsNextIndex; }
/** * Checks for noise on the trigger input line. Noise is detected by an unexpectedly small time gap between * current and previous trigger input events. * * @return TRUE if noise is detected */ static int isNoisySignal(rpm_s * rpmState, int now) { int diff = overflowDiff(now, rpmState->lastRpmEventTime); return diff == 0; }
/** * @return true if there was a full shaft revolution within the last second */ int isRunning() { time_t now = chTimeNow(); return overflowDiff(now, rpmState.lastRpmEventTime) < CH_FREQUENCY; }