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() { static bool isTriggerErrorNow() {
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT #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(); return justHadError || isTriggerDecoderError();
#else #else
return false; return false;

View File

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

View File

@ -19,6 +19,9 @@
#define MS2US(MS_TIME) ((MS_TIME) * 1000) #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 // todo: implement a function to work with times considering counter overflow
#define overflowDiff(now, time) ((now) - (time)) #define overflowDiff(now, time) ((now) - (time))