A GPS disciplined clock
Dependencies: net lpc1768 crypto clock web log
gps/gps.c
- Committer:
- andrewboyson
- Date:
- 2019-02-12
- Revision:
- 35:a535b65203a9
- Parent:
- 34:d9586fc921dc
- Child:
- 36:2983e45eeb49
File content as of revision 35:a535b65203a9:
#include <stdint.h> #include <stdbool.h> #include <stdio.h> #include <stdarg.h> #include "log.h" #include "nmea.h" #include "pps.h" #include "led.h" #include "clkgov.h" #include "fault.h" bool GpsTrace = true; void GpsLog(const char *fmt, ...) { if (!GpsTrace) return; va_list argptr; va_start(argptr, fmt); LogTimeF("GPS %04d ", PpsMsSinceLastPulse); LogV(fmt, argptr); va_end(argptr); } void GpsHadPps() { NmeaTimeAlign(); if (NmeaTimeIsStable()) ClkGovSyncPpsN(NmeaTime); } static void mainConfidence() { ClkGovIsReceivingTime = PpsIsStable() && NmeaTimeIsStable() && NmeaFixIsStable() && NmeaModuleIsReady(); //Tell the clock gov module if confident Led1Set(PpsIsStable()); Led2Set(NmeaTimeIsStable()); Led3Set(NmeaFixIsStable()); Led4Set(NmeaModuleIsReady()); static bool wasStable = false; if (ClkGovIsReceivingTime && !wasStable) GpsLog("PPS and NMEA are stable - sync enabled\r\n"); wasStable = ClkGovIsReceivingTime; } void GpsMain() { NmeaMain(); PpsMain(); mainConfidence(); } void GpsInit() { NmeaInit(); PpsInit(); }