A GPS disciplined clock

Dependencies:   net lpc1768 crypto clock web log

Committer:
andrewboyson
Date:
Sun Apr 28 08:31:50 2019 +0000
Revision:
55:a1bd0572c8b6
Parent:
http-derived/home/http-home-ajax.c@38:b7879c0ae0d9
Child:
58:3f3e000151cc
Update web-base library and renamed http-derived to web-derived

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 55:a1bd0572c8b6 5 #include "web-base.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 34:d9586fc921dc 12 #include "nmea.h"
andrewboyson 27:eb5728b9052b 13
andrewboyson 55:a1bd0572c8b6 14 void WebHomeAjax()
andrewboyson 27:eb5728b9052b 15 {
andrewboyson 27:eb5728b9052b 16 HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL);
andrewboyson 27:eb5728b9052b 17
andrewboyson 38:b7879c0ae0d9 18 clktime now = ClkNowTai();
andrewboyson 38:b7879c0ae0d9 19 int32_t fraction = now & ((1UL << CLK_TIME_ONE_SECOND_SHIFT) - 1); //fraction is 30 bit so fits into 32 bits
andrewboyson 38:b7879c0ae0d9 20 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 21 HttpAddInt16AsHex(ms); //0, 1, 2, 3
andrewboyson 27:eb5728b9052b 22
andrewboyson 27:eb5728b9052b 23 char nibble;
andrewboyson 27:eb5728b9052b 24 nibble = 0;
andrewboyson 27:eb5728b9052b 25 if (RtcIsSet() ) nibble |= 1; //4
andrewboyson 27:eb5728b9052b 26 if (ClkTimeIsSet() ) nibble |= 2; //4
andrewboyson 28:7fb6b4e9ab80 27 if (PpsIsStable() ) nibble |= 4; //4
andrewboyson 35:a535b65203a9 28 if (NmeaTimeIsStable() ) nibble |= 8; //4
andrewboyson 27:eb5728b9052b 29 HttpAddNibbleAsHex(nibble);
andrewboyson 27:eb5728b9052b 30
andrewboyson 27:eb5728b9052b 31 nibble = 0;
andrewboyson 34:d9586fc921dc 32 if (ClkGovRateIsSynced ) nibble |= 1; //5
andrewboyson 34:d9586fc921dc 33 if (ClkGovTimeIsSynced ) nibble |= 2; //5
andrewboyson 34:d9586fc921dc 34 if (ClkUtcGetNextLeapEnable() ) nibble |= 4; //5
andrewboyson 34:d9586fc921dc 35 if (ClkUtcGetNextLeapForward()) nibble |= 8; //5
andrewboyson 27:eb5728b9052b 36 HttpAddNibbleAsHex(nibble);
andrewboyson 27:eb5728b9052b 37
andrewboyson 27:eb5728b9052b 38 HttpAddInt12AsHex(ClkUtcGetNextEpochMonth1970()); //6, 7, 8
andrewboyson 27:eb5728b9052b 39 HttpAddInt16AsHex(ClkUtcGetEpochOffset()); //9, 10, 11, 12
andrewboyson 27:eb5728b9052b 40 }
andrewboyson 27:eb5728b9052b 41