icE1usb fw/gpsdo: If no PPS present for >= 3s, go to hold over mode

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Change-Id: Ia85a8bb0e146cb117ea6e2704c6a4dedf215c75a
This commit is contained in:
Sylvain Munaut 2022-09-01 18:15:42 +02:00
parent b8fc8a6a64
commit da395cc922
1 changed files with 11 additions and 0 deletions

View File

@ -15,6 +15,8 @@
#include "ice1usb_proto.h"
#include "config.h"
struct {
/* Configuration */
@ -275,6 +277,14 @@ gpsdo_poll(void)
uint32_t tick_now, tick_diff;
bool valid;
/* If more than 3 sec elapsed since last PPS, go to hold-over */
if (time_elapsed(g_gpsdo.meas.tick_prev, 3 * SYS_CLK_FREQ)) {
g_gpsdo.state = STATE_HOLD_OVER;
g_gpsdo.meas.invalid = 0;
g_gpsdo.meas.skip = 0;
return;
}
/* Get current tick and check if there was a PPS and estimate frequency */
tick_now = time_pps_read();
@ -299,6 +309,7 @@ gpsdo_poll(void)
/* No GPS fix, go to hold-over */
g_gpsdo.state = STATE_HOLD_OVER;
g_gpsdo.meas.invalid = 0;
g_gpsdo.meas.skip = 0;
return;
}