From b28f93a793e2e4f7ec0413df0d5b2e5093788f4e Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Wed, 18 Sep 2024 22:06:08 -0700 Subject: [PATCH] SD log: avoid getTimeNowUs --- firmware/console/binary_log/binary_logging.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/firmware/console/binary_log/binary_logging.cpp b/firmware/console/binary_log/binary_logging.cpp index e70a95e7fb..3d0e8d1aca 100644 --- a/firmware/console/binary_log/binary_logging.cpp +++ b/firmware/console/binary_log/binary_logging.cpp @@ -112,16 +112,17 @@ void writeSdBlock(Writer& outBuffer) { // Offset 1 = rolling counter sequence number buffer[1] = blockRollCounter++; + auto nowNt = getTimeNowNt(); + // Offset 2, size 2 = Timestamp at 10us resolution - efitimeus_t nowUs = getTimeNowUs(); - uint16_t timestamp = nowUs / 10; + uint16_t timestamp = (nowNt / (US_TO_NT_MULTIPLIER * 10)); buffer[2] = timestamp >> 8; buffer[3] = timestamp & 0xFF; outBuffer.write(buffer, 4); // Sigh. - *reinterpret_cast(&packedTime) = getTimeNowNt() / TicksPerCount; + *reinterpret_cast(&packedTime) = nowNt / TicksPerCount; uint8_t sum = 0; for (size_t fieldIndex = 0; fieldIndex < efi::size(fields); fieldIndex++) {