A GPS disciplined clock
Dependencies: net lpc1768 crypto clock web log
web-this/home/web-home-ajax.c
- Committer:
- andrewboyson
- Date:
- 2019-05-01
- Revision:
- 59:d2d25c2265f8
- Parent:
- web-derived/home/web-home-ajax.c@ 58:3f3e000151cc
- Child:
- 60:7cab896b0fd4
File content as of revision 59:d2d25c2265f8:
#include <stdint.h> #include <stdio.h> #include "http.h" #include "rtc.h" #include "clk.h" #include "clktime.h" #include "clkgov.h" #include "clkutc.h" #include "pps.h" #include "nmea.h" void WebHomeAjax() { HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL); clktime now = ClkNowTai(); int32_t fraction = now & ((1UL << CLK_TIME_ONE_SECOND_SHIFT) - 1); //fraction is 30 bit so fits into 32 bits int32_t ms = (fraction * 1000LL) >> CLK_TIME_ONE_SECOND_SHIFT; //fraction time in ms needs 40 bits so use 1000LL to promote to 64bit HttpAddInt16AsHex(ms); //0, 1, 2, 3 char nibble; nibble = 0; if (RtcIsSet() ) nibble |= 1; //4 if (ClkTimeIsSet() ) nibble |= 2; //4 if (PpsIsStable() ) nibble |= 4; //4 if (NmeaTimeIsStable() ) nibble |= 8; //4 HttpAddNibbleAsHex(nibble); nibble = 0; if (ClkGovRateIsSynced ) nibble |= 1; //5 if (ClkGovTimeIsSynced ) nibble |= 2; //5 if (ClkUtcGetNextLeapEnable() ) nibble |= 4; //5 if (ClkUtcGetNextLeapForward()) nibble |= 8; //5 HttpAddNibbleAsHex(nibble); HttpAddInt12AsHex(ClkUtcGetNextEpochMonth1970()); //6, 7, 8 HttpAddInt16AsHex(ClkUtcGetEpochOffset()); //9, 10, 11, 12 }