A GPS disciplined clock

Dependencies:   net lpc1768 crypto clock web log

Committer:
andrewboyson
Date:
Wed May 01 10:14:26 2019 +0000
Revision:
59:d2d25c2265f8
Parent:
web-derived/home/web-home-ajax.c@58:3f3e000151cc
Child:
60:7cab896b0fd4
Updated web library

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 28:7fb6b4e9ab80 5 #include "rtc.h"
andrewboyson 28:7fb6b4e9ab80 6 #include "clk.h"
andrewboyson 28:7fb6b4e9ab80 7 #include "clktime.h"
andrewboyson 28:7fb6b4e9ab80 8 #include "clkgov.h"
andrewboyson 28:7fb6b4e9ab80 9 #include "clkutc.h"
andrewboyson 28:7fb6b4e9ab80 10 #include "pps.h"
andrewboyson 34:d9586fc921dc 11 #include "nmea.h"
andrewboyson 27:eb5728b9052b 12
andrewboyson 55:a1bd0572c8b6 13 void WebHomeAjax()
andrewboyson 27:eb5728b9052b 14 {
andrewboyson 27:eb5728b9052b 15 HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL);
andrewboyson 27:eb5728b9052b 16
andrewboyson 38:b7879c0ae0d9 17 clktime now = ClkNowTai();
andrewboyson 38:b7879c0ae0d9 18 int32_t fraction = now & ((1UL << CLK_TIME_ONE_SECOND_SHIFT) - 1); //fraction is 30 bit so fits into 32 bits
andrewboyson 38:b7879c0ae0d9 19 int32_t ms = (fraction * 1000LL) >> CLK_TIME_ONE_SECOND_SHIFT; //fraction time in ms needs 40 bits so use 1000LL to promote to 64bit
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 35:a535b65203a9 27 if (NmeaTimeIsStable() ) nibble |= 8; //4
andrewboyson 27:eb5728b9052b 28 HttpAddNibbleAsHex(nibble);
andrewboyson 27:eb5728b9052b 29
andrewboyson 27:eb5728b9052b 30 nibble = 0;
andrewboyson 34:d9586fc921dc 31 if (ClkGovRateIsSynced ) nibble |= 1; //5
andrewboyson 34:d9586fc921dc 32 if (ClkGovTimeIsSynced ) nibble |= 2; //5
andrewboyson 34:d9586fc921dc 33 if (ClkUtcGetNextLeapEnable() ) nibble |= 4; //5
andrewboyson 34:d9586fc921dc 34 if (ClkUtcGetNextLeapForward()) nibble |= 8; //5
andrewboyson 27:eb5728b9052b 35 HttpAddNibbleAsHex(nibble);
andrewboyson 27:eb5728b9052b 36
andrewboyson 27:eb5728b9052b 37 HttpAddInt12AsHex(ClkUtcGetNextEpochMonth1970()); //6, 7, 8
andrewboyson 27:eb5728b9052b 38 HttpAddInt16AsHex(ClkUtcGetEpochOffset()); //9, 10, 11, 12
andrewboyson 27:eb5728b9052b 39 }
andrewboyson 27:eb5728b9052b 40