hopefully useful macro?

This commit is contained in:
rusefi 2019-12-21 21:18:38 -05:00
parent fde9a449cf
commit 609865da0f
3 changed files with 5 additions and 2 deletions

View File

@ -596,7 +596,7 @@ static void initStatusLeds(void) {
static bool isTriggerErrorNow() {
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
bool justHadError = (getTimeNowNt() - engine->triggerCentral.triggerState.lastDecodingErrorTime) < US2NT(MS2US(200));
bool justHadError = (getTimeNowNt() - engine->triggerCentral.triggerState.lastDecodingErrorTime) < MS2NT(200);
return justHadError || isTriggerDecoderError();
#else
return false;

View File

@ -87,7 +87,7 @@ private:
void PeriodicTask(efitick_t nowNt) override {
UNUSED(nowNt);
if (nowNt - engine->triggerCentral.triggerState.mostRecentSyncTime < US2NT(MS2US(500))) {
if (nowNt - engine->triggerCentral.triggerState.mostRecentSyncTime < MS2NT(500)) {
enginePins.checkEnginePin.setValue(1);
chThdSleepMilliseconds(500);
enginePins.checkEnginePin.setValue(0);

View File

@ -19,6 +19,9 @@
#define MS2US(MS_TIME) ((MS_TIME) * 1000)
// milliseconds to ticks
#define MS2NT(msTime) US2NT(MS2US(msTime))
// todo: implement a function to work with times considering counter overflow
#define overflowDiff(now, time) ((now) - (time))