summaryrefslogtreecommitdiffstats
path: root/app/abs.c
diff options
context:
space:
mode:
authorroot <root@lab.panaceas.james.local>2019-02-19 18:08:31 +0000
committerroot <root@lab.panaceas.james.local>2019-02-19 18:08:31 +0000
commit9bbf1d200534cd946c4776e29457f989147b45b2 (patch)
tree6d167a3bede4ae9da3912562ad9fb5baf76d6770 /app/abs.c
parentb3c6320899d6b27899ab3c67c745e8d3b29af3a2 (diff)
downloadclock-9bbf1d200534cd946c4776e29457f989147b45b2.tar.gz
clock-9bbf1d200534cd946c4776e29457f989147b45b2.tar.bz2
clock-9bbf1d200534cd946c4776e29457f989147b45b2.zip
everything working, even with fucked phy
Diffstat (limited to 'app/abs.c')
-rw-r--r--app/abs.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/app/abs.c b/app/abs.c
index 769da7a..a91787c 100644
--- a/app/abs.c
+++ b/app/abs.c
@@ -3,28 +3,55 @@
static uint32_t high_tick;
+#define QUARTER (1UL << 29)
+#define HALF (1UL << 30)
+#define THREE_QUARTERS (HALF+QUARTER)
+#define ONE (~(uint32_t)0)
uint64_t abs_extend (uint32_t now)
{
- static uint32_t then;
+ static int m;
+ uint64_t ret;
- uint64_t ret;
+ if (!m) {
+ ret = high_tick;
+ ret <<= 32;
+ ret |= now;
- if (now < then)
- high_tick++;
+ if ((now>THREE_QUARTERS) &&( now<=ONE)) {
+ high_tick++;
+ m=1;
+ }
- then = now;
+ } else {
- ret = high_tick;
- ret <<= 32;
- ret |= now;
+ if (now<HALF) {
+ ret = high_tick;
+ ret <<= 32;
+ ret |= now;
+ } else {
+ ret = high_tick-1;
+ ret <<= 32;
+ ret |= now;
+ }
- return ret;
+ if ((now>QUARTER) &&( now<HALF))
+ m=0;
}
+ return ret;
+}
+
+
+void abs_meh(void)
+{
+printf("HT %d\n",(int) high_tick);
+}
+
+