File syn_timesync.c¶
FileList > drivers > syn_timesync.c
Go to the source code of this file
High-precision time discipline and clock synchronization implementation.
#include "../util/syn_assert.h"#include "syn_timesync.h"#include <stdlib.h>#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_timesync_bind_pps (SYN_TimeSync * tsync, const SYN_HPTimestamp * pps_ts, uint64_t utc_sec) Bind a captured PPS timestamp to its corresponding UTC second. |
| void | syn_timesync_init (SYN_TimeSync * tsync) Initialize a time discipline context. |
| bool | syn_timesync_is_pps_locked (const SYN_TimeSync * tsync) Check if active PPS lock is present. |
| SYN_Status | syn_timesync_resolve_utc (const SYN_TimeSync * tsync, const SYN_HPTimestamp * event_ts, SYN_UTCTimestamp * out_utc) Resolve an arbitrary high-precision timestamp into UTC. |
| uint64_t | syn_timesync_to_epoch_ns (const SYN_TimeSync * tsync, const SYN_HPTimestamp * event_ts) Helper: resolve event timestamp directly to total 64-bit UTC nanoseconds. |
Public Functions Documentation¶
function syn_timesync_bind_pps¶
Bind a captured PPS timestamp to its corresponding UTC second.
SYN_Status syn_timesync_bind_pps (
SYN_TimeSync * tsync,
const SYN_HPTimestamp * pps_ts,
uint64_t utc_sec
)
Call this when an asynchronous epoch time sentence (e.g. NMEA $GPZDA) is received, pairing the integer UTC second with the PPS timestamp captured at the top of that second.
Measures crystal drift PPM against nominal syn_port_hpclock_freq_hz().
Parameters:
tsyncTimeSync context. Must not be NULL.pps_tsTimestamp snapshot captured by ISR at PPS rising edge.utc_secUniversal UTC epoch second corresponding to this PPS pulse.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if pps_ts is NULL.
function syn_timesync_init¶
Initialize a time discipline context.
Sets default jitter (50 ns) and max holdover (60 s). If hardware RTC is enabled (SYN_USE_RTC), checks if the RTC is valid.
Parameters:
tsyncContext to initialize. Must not be NULL.
function syn_timesync_is_pps_locked¶
Check if active PPS lock is present.
Parameters:
tsyncTimeSync context.
Returns:
true if PPS lock is active (received within last 1.1s).
function syn_timesync_resolve_utc¶
Resolve an arbitrary high-precision timestamp into UTC.
SYN_Status syn_timesync_resolve_utc (
const SYN_TimeSync * tsync,
const SYN_HPTimestamp * event_ts,
SYN_UTCTimestamp * out_utc
)
Converts a raw SYN_HPTimestamp (captured in an ISR or main thread) into absolute UTC time, calculating the sub-second offset, active quality tier, and linear error accumulation bound (uncertainty_ns).
Handles event timestamps occurring before or after the reference PPS pulse.
Parameters:
tsyncTimeSync context. Must not be NULL.event_tsEvent timestamp to resolve. Must not be NULL.out_utcOutput UTC timestamp. Must not be NULL.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if args are NULL.
function syn_timesync_to_epoch_ns¶
Helper: resolve event timestamp directly to total 64-bit UTC nanoseconds.
Parameters:
tsyncTimeSync context.event_tsEvent timestamp to resolve.
Returns:
Total nanoseconds since Unix epoch (1970-01-01 00:00:00 UTC).
The documentation for this class was generated from the following file src/syntropic/drivers/syn_timesync.c