From decbaaef4a9fbc1afdcee0e0e7529b319d1a4162 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Thu, 25 Apr 2024 22:01:46 -0700 Subject: [PATCH] common getTimeNowUs --- firmware/util/efitime.cpp | 4 ++-- unit_tests/global_mocks.cpp | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/firmware/util/efitime.cpp b/firmware/util/efitime.cpp index 6f3d26b659..9134531763 100644 --- a/firmware/util/efitime.cpp +++ b/firmware/util/efitime.cpp @@ -11,6 +11,8 @@ efitick_t getTimeNowNt() { return timeNt.update(getTimeNowLowerNt()); } +#endif /* !EFI_UNIT_TEST */ + /** * 64-bit result would not overflow, but that's complex stuff for our 32-bit MCU */ @@ -19,8 +21,6 @@ efitimeus_t getTimeNowUs() { return NT2US(getTimeNowNt()); } -#endif /* !EFI_UNIT_TEST */ - /** * Integer number of seconds since ECU boot. * 31,710 years - would not overflow during our life span. diff --git a/unit_tests/global_mocks.cpp b/unit_tests/global_mocks.cpp index e8ac0f3519..9d966f7d35 100644 --- a/unit_tests/global_mocks.cpp +++ b/unit_tests/global_mocks.cpp @@ -11,12 +11,8 @@ bool verboseMode = false; int timeNowUs = 0; -efitimeus_t getTimeNowUs() { - return timeNowUs; -} - efitick_t getTimeNowNt() { - return getTimeNowUs() * US_TO_NT_MULTIPLIER; + return (efitimeus_t)timeNowUs * US_TO_NT_MULTIPLIER; } void initLogging(LoggingWithStorage *logging, const char *name) {