refactoring: better method name
This commit is contained in:
parent
7fc699fce2
commit
8a90297160
|
@ -79,14 +79,14 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
|
|||
if (CONFIG(timingMode) == TM_FIXED)
|
||||
return engineConfiguration->fixedTiming;
|
||||
|
||||
engine->m.beforeAdvance = GET_TIMESTAMP();
|
||||
engine->m.beforeAdvance = getTimeNowLowerNt();
|
||||
if (cisnan(engineLoad)) {
|
||||
warning(CUSTOM_NAN_ENGINE_LOAD, "NaN engine load");
|
||||
return NAN;
|
||||
}
|
||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(engineLoad), "invalid el", NAN);
|
||||
engine->m.beforeZeroTest = GET_TIMESTAMP();
|
||||
engine->m.zeroTestTime = GET_TIMESTAMP() - engine->m.beforeZeroTest;
|
||||
engine->m.beforeZeroTest = getTimeNowLowerNt();
|
||||
engine->m.zeroTestTime = getTimeNowLowerNt() - engine->m.beforeZeroTest;
|
||||
|
||||
if (isStep1Condition(rpm PASS_ENGINE_PARAMETER_SUFFIX)) {
|
||||
return engineConfiguration->step1timing;
|
||||
|
@ -108,7 +108,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME
|
|||
advanceAngle = interpolateClamped(0.0f, idleAdvance, CONFIGB(idlePidDeactivationTpsThreshold), advanceAngle, tps);
|
||||
}
|
||||
|
||||
engine->m.advanceLookupTime = GET_TIMESTAMP() - engine->m.beforeAdvance;
|
||||
engine->m.advanceLookupTime = getTimeNowLowerNt() - engine->m.beforeAdvance;
|
||||
return advanceAngle;
|
||||
}
|
||||
|
||||
|
|
|
@ -337,14 +337,14 @@ void Engine::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
engine->m.beforeFuelCalc = GET_TIMESTAMP();
|
||||
engine->m.beforeFuelCalc = getTimeNowLowerNt();
|
||||
int rpm = GET_RPM();
|
||||
/**
|
||||
* we have same assignment of 'getInjectionDuration' to 'injectionDuration' in handleFuel()
|
||||
* Open question why do we refresh that in two places?
|
||||
*/
|
||||
ENGINE(injectionDuration) = getInjectionDuration(rpm PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
engine->m.fuelCalcTime = GET_TIMESTAMP() - engine->m.beforeFuelCalc;
|
||||
engine->m.fuelCalcTime = getTimeNowLowerNt() - engine->m.beforeFuelCalc;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -165,11 +165,11 @@ uint32_t maxLockedDuration = 0;
|
|||
#endif
|
||||
*/
|
||||
void onLockHook(void) {
|
||||
lastLockTime = GET_TIMESTAMP();
|
||||
lastLockTime = getTimeNowLowerNt();
|
||||
}
|
||||
|
||||
void onUnlockHook(void) {
|
||||
uint32_t lockedDuration = GET_TIMESTAMP() - lastLockTime;
|
||||
uint32_t lockedDuration = getTimeNowLowerNt() - lastLockTime;
|
||||
if (lockedDuration > maxLockedDuration) {
|
||||
maxLockedDuration = lockedDuration;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ efitick_t getTimeNowNt(void) {
|
|||
efitime_t localH = halTime.state.highBits;
|
||||
uint32_t localLow = halTime.state.lowBits;
|
||||
|
||||
uint32_t value = GET_TIMESTAMP();
|
||||
uint32_t value = getTimeNowLowerNt();
|
||||
|
||||
if (value < localLow) {
|
||||
// new value less than previous value means there was an overflow in that 32 bit counter
|
||||
|
@ -184,7 +184,7 @@ efitick_t getTimeNowNt(void) {
|
|||
/**
|
||||
* We need to take current counter after making a local 64 bit snapshot
|
||||
*/
|
||||
uint32_t value = GET_TIMESTAMP();
|
||||
uint32_t value = getTimeNowLowerNt();
|
||||
|
||||
if (value < localLow) {
|
||||
// new value less than previous value means there was an overflow in that 32 bit counter
|
||||
|
@ -249,7 +249,7 @@ typedef FLStack<int, 16> irq_enter_timestamps_t;
|
|||
static irq_enter_timestamps_t irqEnterTimestamps;
|
||||
|
||||
void irqEnterHook(void) {
|
||||
irqEnterTimestamps.push(GET_TIMESTAMP());
|
||||
irqEnterTimestamps.push(getTimeNowLowerNt());
|
||||
}
|
||||
|
||||
static int currentIrqDurationAccumulator = 0;
|
||||
|
@ -261,7 +261,7 @@ int perSecondIrqDuration = 0;
|
|||
int perSecondIrqCounter = 0;
|
||||
void irqExitHook(void) {
|
||||
int enterTime = irqEnterTimestamps.pop();
|
||||
currentIrqDurationAccumulator += (GET_TIMESTAMP() - enterTime);
|
||||
currentIrqDurationAccumulator += (getTimeNowLowerNt() - enterTime);
|
||||
currentIrqCounter++;
|
||||
}
|
||||
#endif /* EFI_CLOCK_LOCKS */
|
||||
|
@ -283,7 +283,7 @@ static void periodicSlowCallback(Engine *engine) {
|
|||
* We need to push current value into the 64 bit counter often enough so that we do not miss an overflow
|
||||
*/
|
||||
bool alreadyLocked = lockAnyContext();
|
||||
updateAndSet(&halTime.state, GET_TIMESTAMP());
|
||||
updateAndSet(&halTime.state, getTimeNowLowerNt());
|
||||
if (!alreadyLocked) {
|
||||
unlockAnyContext();
|
||||
}
|
||||
|
|
|
@ -261,7 +261,7 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
|
|||
if (index != CONFIG(mapAveragingSchedulingAtIndex))
|
||||
return;
|
||||
|
||||
engine->m.beforeMapAveragingCb = GET_TIMESTAMP();
|
||||
engine->m.beforeMapAveragingCb = getTimeNowLowerNt();
|
||||
int rpm = GET_RPM_VALUE;
|
||||
if (!isValidRpm(rpm)) {
|
||||
return;
|
||||
|
@ -302,7 +302,7 @@ static void mapAveragingTriggerCallback(trigger_event_e ckpEventType,
|
|||
startAveraging, NULL, &engine->rpmCalculator);
|
||||
scheduleByAngle(rpm, &endTimer[i][structIndex], samplingEnd,
|
||||
endAveraging, NULL, &engine->rpmCalculator);
|
||||
engine->m.mapAveragingCbTime = GET_TIMESTAMP()
|
||||
engine->m.mapAveragingCbTime = getTimeNowLowerNt()
|
||||
- engine->m.beforeMapAveragingCb;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -165,7 +165,7 @@ int EventQueue::executeAll(efitime_t now) {
|
|||
LL_FOREACH_SAFE(executionList, current, tmp)
|
||||
{
|
||||
efiAssert(CUSTOM_ERR_ASSERT, current->callback != NULL, "callback==null2", 0);
|
||||
uint32_t before = GET_TIMESTAMP();
|
||||
uint32_t before = getTimeNowLowerNt();
|
||||
current->isScheduled = false;
|
||||
uint32_t howFarOff = now - current->momentX;
|
||||
maxSchedulingPrecisionLoss = maxI(maxSchedulingPrecisionLoss, howFarOff);
|
||||
|
@ -174,7 +174,7 @@ int EventQueue::executeAll(efitime_t now) {
|
|||
#endif
|
||||
current->callback(current->param);
|
||||
// even with overflow it's safe to subtract here
|
||||
lastEventCallbackDuration = GET_TIMESTAMP() - before;
|
||||
lastEventCallbackDuration = getTimeNowLowerNt() - before;
|
||||
if (lastEventCallbackDuration > maxEventCallbackDuration)
|
||||
maxEventCallbackDuration = lastEventCallbackDuration;
|
||||
if (lastEventCallbackDuration > 2000) {
|
||||
|
|
|
@ -154,9 +154,9 @@ void SingleTimerExecutor::scheduleTimerCallback() {
|
|||
if (nextEventTimeNt == EMPTY_QUEUE)
|
||||
return; // no pending events in the queue
|
||||
int32_t hwAlarmTime = NT2US((int32_t)nextEventTimeNt - (int32_t)nowNt);
|
||||
uint32_t beforeHwSetTimer = GET_TIMESTAMP();
|
||||
uint32_t beforeHwSetTimer = getTimeNowLowerNt();
|
||||
setHardwareUsTimer(hwAlarmTime == 0 ? 1 : hwAlarmTime);
|
||||
hwSetTimerDuration = GET_TIMESTAMP() - beforeHwSetTimer;
|
||||
hwSetTimerDuration = getTimeNowLowerNt() - beforeHwSetTimer;
|
||||
}
|
||||
|
||||
void initSingleTimerExecutorHardware(void) {
|
||||
|
|
|
@ -439,7 +439,7 @@ uint32_t *cyccnt = (uint32_t*) &DWT->CYCCNT;
|
|||
void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||
(void) ckpSignalType;
|
||||
|
||||
ENGINE(m.beforeMainTrigger) = GET_TIMESTAMP();
|
||||
ENGINE(m.beforeMainTrigger) = getTimeNowLowerNt();
|
||||
if (hasFirmwareError()) {
|
||||
/**
|
||||
* In case on a major error we should not process any more events.
|
||||
|
@ -538,7 +538,7 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
|
|||
#endif /* EFI_HISTOGRAMS */
|
||||
|
||||
if (trgEventIndex == 0) {
|
||||
ENGINE(m.mainTriggerCallbackTime) = GET_TIMESTAMP() - ENGINE(m.beforeMainTrigger);
|
||||
ENGINE(m.mainTriggerCallbackTime) = getTimeNowLowerNt() - ENGINE(m.beforeMainTrigger);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
|
|||
RpmCalculator *rpmState = &engine->rpmCalculator;
|
||||
|
||||
if (index == 0) {
|
||||
ENGINE(m.beforeRpmCb) = GET_TIMESTAMP();
|
||||
ENGINE(m.beforeRpmCb) = getTimeNowLowerNt();
|
||||
|
||||
bool hadRpmRecently = rpmState->checkIfSpinning(nowNt PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
|
@ -257,7 +257,7 @@ void rpmShaftPositionCallback(trigger_event_e ckpSignalType,
|
|||
}
|
||||
rpmState->onNewEngineCycle();
|
||||
rpmState->lastRpmEventTimeNt = nowNt;
|
||||
ENGINE(m.rpmCbTime) = GET_TIMESTAMP() - ENGINE(m.beforeRpmCb);
|
||||
ENGINE(m.rpmCbTime) = getTimeNowLowerNt() - ENGINE(m.beforeRpmCb);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ static void initializeIgnitionActions(IgnitionEventList *list DECLARE_ENGINE_PAR
|
|||
|
||||
static ALWAYS_INLINE void prepareIgnitionSchedule(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||
|
||||
engine->m.beforeIgnitionSch = GET_TIMESTAMP();
|
||||
engine->m.beforeIgnitionSch = getTimeNowLowerNt();
|
||||
/**
|
||||
* TODO: warning. there is a bit of a hack here, todo: improve.
|
||||
* currently output signals/times signalTimerUp from the previous revolutions could be
|
||||
|
@ -339,7 +339,7 @@ static ALWAYS_INLINE void prepareIgnitionSchedule(DECLARE_ENGINE_PARAMETER_SIGNA
|
|||
IgnitionEventList *list = &engine->ignitionEvents;
|
||||
|
||||
initializeIgnitionActions(list PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
engine->m.ignitionSchTime = GET_TIMESTAMP() - engine->m.beforeIgnitionSch;
|
||||
engine->m.ignitionSchTime = getTimeNowLowerNt() - engine->m.beforeIgnitionSch;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ void hwHandleShaftSignal(trigger_event_e signal) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
uint32_t triggerHandlerEntryTime = GET_TIMESTAMP();
|
||||
uint32_t triggerHandlerEntryTime = getTimeNowLowerNt();
|
||||
isInsideTriggerHandler = true;
|
||||
if (triggerReentraint > maxTriggerReentraint)
|
||||
maxTriggerReentraint = triggerReentraint;
|
||||
|
@ -200,7 +200,7 @@ void hwHandleShaftSignal(trigger_event_e signal) {
|
|||
efiAssertVoid(CUSTOM_ERR_6636, getCurrentRemainingStack() > 128, "lowstck#8");
|
||||
engine->triggerCentral.handleShaftSignal(signal PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
triggerReentraint--;
|
||||
triggerDuration = GET_TIMESTAMP() - triggerHandlerEntryTime;
|
||||
triggerDuration = getTimeNowLowerNt() - triggerHandlerEntryTime;
|
||||
isInsideTriggerHandler = false;
|
||||
if (triggerDuration > triggerMaxDuration)
|
||||
triggerMaxDuration = triggerDuration;
|
||||
|
|
|
@ -242,7 +242,7 @@ static void intHoldCallback(trigger_event_e ckpEventType, uint32_t index DECLARE
|
|||
// this callback is invoked on interrupt thread
|
||||
if (index != 0)
|
||||
return;
|
||||
engine->m.beforeHipCb = GET_TIMESTAMP();
|
||||
engine->m.beforeHipCb = getTimeNowLowerNt();
|
||||
|
||||
int rpm = GET_RPM_VALUE;
|
||||
if (!isValidRpm(rpm))
|
||||
|
@ -258,7 +258,7 @@ static void intHoldCallback(trigger_event_e ckpEventType, uint32_t index DECLARE
|
|||
scheduleByAngle(rpm, &endTimer[structIndex], engineConfiguration->knockDetectionWindowEnd,
|
||||
(schfunc_t) &endIntegration,
|
||||
NULL, &engine->rpmCalculator);
|
||||
engine->m.hipCbTime = GET_TIMESTAMP() - engine->m.beforeHipCb;
|
||||
engine->m.hipCbTime = getTimeNowLowerNt() - engine->m.beforeHipCb;
|
||||
}
|
||||
|
||||
void setMaxKnockSubDeg(int value) {
|
||||
|
|
|
@ -101,9 +101,9 @@ static void hwTimerCallback(GPTDriver *gptp) {
|
|||
}
|
||||
isTimerPending = false;
|
||||
|
||||
uint32_t before = GET_TIMESTAMP();
|
||||
uint32_t before = getTimeNowLowerNt();
|
||||
globalTimerCallback(NULL);
|
||||
uint32_t precisionCallbackDuration = GET_TIMESTAMP() - before;
|
||||
uint32_t precisionCallbackDuration = getTimeNowLowerNt() - before;
|
||||
if (precisionCallbackDuration > maxPrecisionCallbackDuration) {
|
||||
maxPrecisionCallbackDuration = precisionCallbackDuration;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,9 @@ efitimeus_t getTimeNowUs(void);
|
|||
|
||||
/**
|
||||
* 64-bit counter CPU cycles since MCU reset
|
||||
*
|
||||
* See getTimeNowLowerNt for a quicker version which returns only lower 32 bits
|
||||
* Lower 32 bits are enough if all we need is to measure relatively short time durations
|
||||
*/
|
||||
efitick_t getTimeNowNt(void);
|
||||
|
||||
|
@ -60,9 +63,9 @@ efitimesec_t getTimeNowSeconds(void);
|
|||
#endif /* __cplusplus */
|
||||
|
||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
||||
#define GET_TIMESTAMP() port_rt_get_counter_value()
|
||||
#define getTimeNowLowerNt() port_rt_get_counter_value()
|
||||
#else
|
||||
#define GET_TIMESTAMP() 0
|
||||
#define getTimeNowLowerNt() 0
|
||||
#endif
|
||||
|
||||
#endif /* EFITIME_H_ */
|
||||
|
|
|
@ -40,21 +40,21 @@ static void testBinary(void) {
|
|||
for (int v = 0; v <= 16; v++) {
|
||||
uint32_t timeOld;
|
||||
{
|
||||
uint32_t start = GET_TIMESTAMP();
|
||||
uint32_t start = getTimeNowLowerNt();
|
||||
int temp = 0;
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
temp += findIndex(array16, size16, v);
|
||||
}
|
||||
timeOld = GET_TIMESTAMP() - start;
|
||||
timeOld = getTimeNowLowerNt() - start;
|
||||
}
|
||||
uint32_t timeNew;
|
||||
{
|
||||
uint32_t start = GET_TIMESTAMP();
|
||||
uint32_t start = getTimeNowLowerNt();
|
||||
int temp = 0;
|
||||
for (int i = 0; i < COUNT; i++) {
|
||||
temp += findIndex2(array16, size16, v);
|
||||
}
|
||||
timeNew = GET_TIMESTAMP() - start;
|
||||
timeNew = getTimeNowLowerNt() - start;
|
||||
}
|
||||
scheduleMsg(logger, "for v=%d old=%d ticks", v, timeOld);
|
||||
scheduleMsg(logger, "for v=%d new=%d ticks", v, timeNew);
|
||||
|
|
Loading…
Reference in New Issue