61#include "periph_cpu.h"
69#if !defined(HAVE_PTP_CLOCK_READ) && !defined(HAVE_PTP_CLOCK_READ_U64)
70#error "Neither ptp_clock_read() nor ptp_clock_read_u64() implemented"
73#if !defined(HAVE_PTP_CLOCK_SET) && !defined(HAVE_PTP_CLOCK_SET_U64)
74#error "Neither ptp_clock_set() nor ptp_clock_set_u64() implemented"
78 !defined(HAVE_PTP_TIMER_SET_ABSOLUTE) && \
79 !defined(HAVE_PTP_TIMER_SET_ABSOLUTE_U64) && \
80 IS_USED(MODULE_PERIPH_PTP_TIMER)
81#error "Neither ptp_timer_set_absolute() nor ptp_timer_set_absolute_u64() implemented"
149 uint64_t abs_offset = offset;
159 uint64_t abs_offset = -offset;
243#if defined(HAVE_PTP_CLOCK_READ) || defined(DOXYGEN)
253#if defined(HAVE_PTP_CLOCK_READ_U64) || defined(DOXYGEN)
267#if defined(HAVE_PTP_CLOCK_SET) || defined(DOXYGEN)
278#if defined(HAVE_PTP_CLOCK_SET_U64) || defined(DOXYGEN)
301#if defined(HAVE_PTP_TIMER_SET_ABSOLUTE) || defined(DOXYGEN)
317#if defined(HAVE_PTP_TIMER_SET_ABSOLUTE_U64) || defined(DOXYGEN)
355#ifndef HAVE_PTP_CLOCK_READ
362#ifndef HAVE_PTP_CLOCK_READ_U64
371#ifndef HAVE_PTP_CLOCK_SET
378#ifndef HAVE_PTP_CLOCK_SET_U64
387#ifndef HAVE_PTP_TIMER_SET_ABSOLUTE
394#ifndef HAVE_PTP_TIMER_SET_ABSOLUTE_U64
void ptp_timer_set_u64(uint64_t target)
Set an relative timeout value, possibly overwriting an existing timeout.
static void ptp_add(ptp_timestamp_t *t, int64_t offset)
Add a given offset onto the given timestamp.
static void ptp_ns2ts(ptp_timestamp_t *dest, uint64_t ns_since_epoch)
Convert time from nanoseconds since epoch to ptp_timestamp_t format.
uint32_t ptp_seconds_t
Unsigned integer type to store seconds since epoch for use in PTP.
void ptp_clock_set_u64(uint64_t ns_since_epoch)
Set the current system time in nanosecond since UNIX epoch.
static int ptp_cmp(const ptp_timestamp_t *a, const ptp_timestamp_t *b)
Compare two PTP timestamps.
uint64_t ptp_clock_read_u64(void)
Get the current system time in nanosecond since UNIX epoch.
void ptp_timer_set_absolute_u64(uint64_t target)
Set an absolute timeout value, possibly overwriting an existing timeout.
void ptp_clock_adjust_speed(int32_t correction)
Adjust the PTP clock speed as given.
void ptp_clock_read(ptp_timestamp_t *timestamp)
Get the current system time as PTP timestamp.
void ptp_timer_set_absolute(const ptp_timestamp_t *target)
Set an absolute timeout value, possibly overwriting an existing timeout.
void ptp_clock_set(const ptp_timestamp_t *time)
Set the current system time.
void ptp_timer_cb(void)
External function to call when the PTP clock timer fired.
void ptp_timer_clear(void)
Clears any pending timeout on the PTP timer.
void ptp_clock_adjust(int64_t offset)
Adjust the PTP clock as given.
void ptp_init(void)
Initialize the given PTP peripheral.
static uint64_t ptp_ts2ns(const ptp_timestamp_t *t)
Convert time from nanoseconds since epoch to ptp_timestamp_t format.
#define NS_PER_SEC
The number of nanoseconds per second.
A PTP timestamp in seconds + nanoseconds since UNIX epoch.
uint32_t nanoseconds
Nanoseconds part.
ptp_seconds_t seconds
Seconds since UNIX epoch.
Utility library for comparing and computing timestamps.