A GPS disciplined clock

Dependencies:   net lpc1768 crypto clock web log

Committer:
andrewboyson
Date:
Fri Jan 18 14:37:57 2019 +0000
Revision:
28:7fb6b4e9ab80
Parent:
27:eb5728b9052b
Child:
34:d9586fc921dc
Updated libraries

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 27:eb5728b9052b 1 #include <stdint.h>
andrewboyson 27:eb5728b9052b 2 #include <stdio.h>
andrewboyson 27:eb5728b9052b 3
andrewboyson 28:7fb6b4e9ab80 4 #include "http.h"
andrewboyson 27:eb5728b9052b 5 #include "http-server.h"
andrewboyson 28:7fb6b4e9ab80 6 #include "rtc.h"
andrewboyson 28:7fb6b4e9ab80 7 #include "clk.h"
andrewboyson 28:7fb6b4e9ab80 8 #include "clktime.h"
andrewboyson 28:7fb6b4e9ab80 9 #include "clkgov.h"
andrewboyson 28:7fb6b4e9ab80 10 #include "clkutc.h"
andrewboyson 28:7fb6b4e9ab80 11 #include "pps.h"
andrewboyson 27:eb5728b9052b 12
andrewboyson 27:eb5728b9052b 13 void HttpHomeAjax()
andrewboyson 27:eb5728b9052b 14 {
andrewboyson 27:eb5728b9052b 15 HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL);
andrewboyson 27:eb5728b9052b 16
andrewboyson 27:eb5728b9052b 17 int64_t now = ClkNowTime();
andrewboyson 27:eb5728b9052b 18 int64_t fraction = now & ((1UL << CLK_TIME_ONE_SECOND_SHIFT) - 1);
andrewboyson 27:eb5728b9052b 19 int64_t ms = (fraction * 1000) >> CLK_TIME_ONE_SECOND_SHIFT;
andrewboyson 27:eb5728b9052b 20 HttpAddInt16AsHex(ms); //0, 1, 2, 3
andrewboyson 27:eb5728b9052b 21
andrewboyson 27:eb5728b9052b 22 char nibble;
andrewboyson 27:eb5728b9052b 23 nibble = 0;
andrewboyson 27:eb5728b9052b 24 if (RtcIsSet() ) nibble |= 1; //4
andrewboyson 27:eb5728b9052b 25 if (ClkTimeIsSet() ) nibble |= 2; //4
andrewboyson 28:7fb6b4e9ab80 26 if (PpsIsStable() ) nibble |= 4; //4
andrewboyson 27:eb5728b9052b 27 if (ClkGovRateIsSynced ) nibble |= 8; //4
andrewboyson 27:eb5728b9052b 28 HttpAddNibbleAsHex(nibble);
andrewboyson 27:eb5728b9052b 29
andrewboyson 27:eb5728b9052b 30 nibble = 0;
andrewboyson 27:eb5728b9052b 31 if (ClkGovTimeIsSynced ) nibble |= 1; //5
andrewboyson 27:eb5728b9052b 32 if (ClkUtcGetNextLeapEnable() ) nibble |= 2; //5
andrewboyson 27:eb5728b9052b 33 if (ClkUtcGetNextLeapForward()) nibble |= 4; //5
andrewboyson 27:eb5728b9052b 34 HttpAddNibbleAsHex(nibble);
andrewboyson 27:eb5728b9052b 35
andrewboyson 27:eb5728b9052b 36 HttpAddInt12AsHex(ClkUtcGetNextEpochMonth1970()); //6, 7, 8
andrewboyson 27:eb5728b9052b 37 HttpAddInt16AsHex(ClkUtcGetEpochOffset()); //9, 10, 11, 12
andrewboyson 27:eb5728b9052b 38 }
andrewboyson 27:eb5728b9052b 39