2022-09-11 10:06:03 -07:00
|
|
|
#include "pch.h"
|
|
|
|
|
|
|
|
#if !EFI_UNIT_TEST
|
|
|
|
|
|
|
|
static WrapAround62 timeNt;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 64-bit counter CPU/timer cycles since MCU reset
|
|
|
|
*/
|
|
|
|
efitick_t getTimeNowNt() {
|
|
|
|
return timeNt.update(getTimeNowLowerNt());
|
|
|
|
}
|
|
|
|
|
2024-04-25 22:01:46 -07:00
|
|
|
#endif /* !EFI_UNIT_TEST */
|
|
|
|
|
2022-09-11 10:06:03 -07:00
|
|
|
/**
|
|
|
|
* 64-bit result would not overflow, but that's complex stuff for our 32-bit MCU
|
|
|
|
*/
|
|
|
|
efitimeus_t getTimeNowUs() {
|
|
|
|
ScopePerf perf(PE::GetTimeNowUs);
|
|
|
|
return NT2US(getTimeNowNt());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Integer number of seconds since ECU boot.
|
|
|
|
* 31,710 years - would not overflow during our life span.
|
|
|
|
*/
|
2024-04-25 14:19:01 -07:00
|
|
|
int64_t getTimeNowS() {
|
2022-09-11 10:06:03 -07:00
|
|
|
return getTimeNowUs() / US_PER_SECOND;
|
|
|
|
}
|