From 6b4f3e1c3b138e1bbc34ba917bdc99c79fd27ff0 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Fri, 2 Jan 2015 20:03:33 -0600 Subject: [PATCH] auto-sync --- firmware/controllers/math/efitime.h | 15 +++++++++++++-- firmware/main.h | 10 ++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/firmware/controllers/math/efitime.h b/firmware/controllers/math/efitime.h index 1285b29b94..7a7187b624 100644 --- a/firmware/controllers/math/efitime.h +++ b/firmware/controllers/math/efitime.h @@ -20,6 +20,17 @@ */ typedef uint32_t efitimems_t; +/** + * 64 bit time in microseconds, since boot + */ +typedef uint64_t efitimeus_t; + +/** + * platform-dependent tick since boot + * in case of stm32f4 that's a CPU tick + */ +typedef uint64_t efitick_t; + /** * numeric value from 0 to 100 */ @@ -49,12 +60,12 @@ extern "C" * WARNING: you should use getTimeNowNt where possible for performance reasons. * The heaviest part is '__aeabi_ildivmod' - non-native 64 bit division */ -uint64_t getTimeNowUs(void); +efitimeus_t getTimeNowUs(void); /** * 64-bit counter CPU cycles since MCU reset */ -uint64_t getTimeNowNt(void); +efitick_t getTimeNowNt(void); uint64_t getHalTimer(void); diff --git a/firmware/main.h b/firmware/main.h index ceb06a15ee..01d7f5ceb2 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -40,9 +40,15 @@ extern "C" // 168 ticks in microsecond #define US_TO_NT_MULTIPLIER 168 -#define US2NT(x) (((uint64_t)(x))*US_TO_NT_MULTIPLIER) +/** + * converts efitimeus_t to efitick_t + */ +#define US2NT(us) (((uint64_t)(us))*US_TO_NT_MULTIPLIER) -#define NT2US(x) ((x) / US_TO_NT_MULTIPLIER) +/** + * converts efitick_t to efitimeus_t + */ +#define NT2US(nt) ((nt) / US_TO_NT_MULTIPLIER) /**