#include "project.h" #define WARM_UP 30 void pll_set_offset (EPOCH epoch, uint64_t abs, uint64_t ptp) { ref_set_offset (epoch, abs); ptp_set_offset (epoch, ptp); } void pll_dispatch (uint64_t happy, uint64_t edge, uint64_t ptp_edge, const char *src) { // int64_t delta_f; if (((!gps_last_happy) && (!dcf77_last_happy) && (!msf_last_happy)) || (happy < gps_last_happy) || (happy < dcf77_last_happy) || (happy < msf_last_happy) || (edge < ((uint64_t) WARM_UP * (uint64_t) HW_CLOCK_HZ))) return; led_blink (100); ref_dispatch (edge, src); ptp_dispatch (ptp_edge, src); } void pll_check (void) { uint64_t ptp = ptp_get(); uint64_t ref = ref_get(); EPOCH re, pe; UTC ru, pu; static unsigned m; re = ref_decompose (ref); ru = time_epoch_to_utc (re); if (m == ru.minute) return; m = ru.minute; pe = ptp_decompose (ptp); pu = time_epoch_to_utc (pe); printf ("PLL checks: R %04d-%02d-%02d %02d:%02d:%02d.%09d P %04d-%02d-%02d %02d:%02d:%02d.%09d\r\n", ru.year, ru.month + 1, ru.mday, ru.hour, ru.minute, ru.second, ru.nanosecond, pu.year, pu.month + 1, pu.mday, pu.hour, pu.minute, pu.second, pu.nanosecond); }