auto-sync

This commit is contained in:
rusEfi 2015-01-02 20:03:33 -06:00
parent d004ac4d75
commit 6b4f3e1c3b
2 changed files with 21 additions and 4 deletions

View File

@ -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);

View File

@ -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)
/**