A GPS disciplined clock
Dependencies: net lpc1768 crypto clock web log
gps/nmea/nmea.c
- Committer:
- andrewboyson
- Date:
- 2019-11-18
- Revision:
- 84:baec7c1f5618
- Parent:
- 81:a1de28caf11a
- Child:
- 86:7959accd9679
File content as of revision 84:baec7c1f5618:
#include "nmea.h" #include "mstimer.h" #include "gps.h" #define WATCHDOG_TIMEOUT_MS 5 * 60 * 1000 int NmeaModuleReadiness = 0; bool NmeaModuleIsReady() { return NmeaModuleReadiness == NMEA_READINESS_READY; } static int msTimerMsgWatchdog = 0; void NmeaMain() { NmeaCmdMain(); //Run the message loop and see if have had a message bool hadMessage = NmeaMsgMain(); //Feed the watchdog each time a message is received if (hadMessage) msTimerMsgWatchdog = MsTimerCount; //If had no messages assume the module has done a cold reset (loses baud etc) static bool watchdogWasElapsed = false; bool watchdogHasElapsed = MsTimerRelative(msTimerMsgWatchdog, WATCHDOG_TIMEOUT_MS); if (watchdogHasElapsed) { if (!watchdogWasElapsed) GpsLog("NMEA messages watchdog timed out - restarting serial link to module\r\n"); NmeaCmdSetup(); //This won't keep repeating as NmeaCmdSeup will only do something if not already busy } watchdogWasElapsed = watchdogHasElapsed; NmeaTimeMain(); NmeaFixMain(); } void NmeaInit() { NmeaFixInit(); NmeaTimeInit(); NmeaCmdInit(); NmeaCmdStartup(); }