Andrew Boyson / clock

Dependents:   oldheating gps motorhome heating

Revision:
17:927fc1eceb9d
Parent:
16:933cbe190bb0
Child:
18:207dd1474cd9
--- a/clock-ntp.cpp	Sat Dec 16 14:51:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-#include "mbed.h"
-
-#define SECONDS_BETWEEN_1900_AND_1970 2208988800ULL
-#define                   ONE_BILLION 1000000000LL
-
-#define ERA_BASE_LOW 1 //Adjust this from 0 to 1 between 1968 and 2036; 1 to 2 between 2104 and 2168
-#define ERA_BASE_HGH 0 //Adjust this from 0 to 1 between 2036 and 2104; 1 to 2 between 2172 and 2240
-
-const int64_t ERA_LOW_SECS = ERA_BASE_LOW * (1LL << 32);
-const int64_t ERA_HGH_SECS = ERA_BASE_HGH * (1LL << 32);
-const int64_t ERA_LOW_NS   = ERA_LOW_SECS * ONE_BILLION;
-const int64_t ERA_HGH_NS   = ERA_HGH_SECS * ONE_BILLION;
-
-uint64_t ClockNtpTimeStampFromNs(int64_t ns)
-{    
-    uint64_t timestamp = ns << 2;
-    timestamp /= 1000; timestamp <<= 10;
-    timestamp /= 1000; timestamp <<= 10;
-    timestamp /= 1000; timestamp <<= 10;
-    
-    timestamp += SECONDS_BETWEEN_1900_AND_1970 << 32; //This should just wrap around the unsigned timestamp removing the unwanted era.
-    
-    return timestamp;
-}
-int64_t ClockNtpTimeStampToNs(uint64_t timestamp)
-{
-    bool isHigh = timestamp & 0x8000000000000000;
-    
-    int64_t ns = timestamp - (SECONDS_BETWEEN_1900_AND_1970 << 32);
-    ns >>= 10; ns *= 1000;
-    ns >>= 10; ns *= 1000;
-    ns >>= 10; ns *= 1000;
-    
-    ns >>= 2;
-    
-    //Correct for era
-    if (isHigh) ns += ERA_HGH_NS;
-    else        ns += ERA_LOW_NS;
-    
-    return ns;
-}
-