diff options
Diffstat (limited to 'app/abs.c')
-rw-r--r-- | app/abs.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/abs.c b/app/abs.c new file mode 100644 index 0000000..769da7a --- /dev/null +++ b/app/abs.c @@ -0,0 +1,41 @@ +#include "project.h" + + +static uint32_t high_tick; + + +uint64_t abs_extend (uint32_t now) +{ + static uint32_t then; + + + uint64_t ret; + + + if (now < then) + high_tick++; + + then = now; + + + ret = high_tick; + ret <<= 32; + ret |= now; + + return ret; +} + + + + +uint64_t abs_get (void) +{ + uint32_t now = SCS_DWT_CYCCNT; + return abs_extend (now); +} + + +void abs_slow_tick() +{ + abs_get(); +} |