A GPS disciplined clock
Dependencies: net lpc1768 crypto clock web log
http-derived/home/http-home-ajax.c
- Committer:
- andrewboyson
- Date:
- 2019-02-28
- Revision:
- 38:b7879c0ae0d9
- Parent:
- 37:a4e57b7e29dc
File content as of revision 38:b7879c0ae0d9:
#include <stdint.h> #include <stdio.h> #include "http.h" #include "http-server.h" #include "rtc.h" #include "clk.h" #include "clktime.h" #include "clkgov.h" #include "clkutc.h" #include "pps.h" #include "nmea.h" void HttpHomeAjax() { 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 }