summaryrefslogtreecommitdiffstats
path: root/app/abs.c
blob: 769da7aa741050a6630df3e131f8c8f9f15f2731 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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();
}