60 #include "periph_cpu.h" 
   68 #if !defined(HAVE_PTP_CLOCK_READ) && !defined(HAVE_PTP_CLOCK_READ_U64) 
   69 #error "Neither ptp_clock_read() nor ptp_clock_read_u64() implemented" 
   72 #if !defined(HAVE_PTP_CLOCK_SET) && !defined(HAVE_PTP_CLOCK_SET_U64) 
   73 #error "Neither ptp_clock_set() nor ptp_clock_set_u64() implemented" 
   77     !defined(HAVE_PTP_TIMER_SET_ABSOLUTE) && \ 
   78     !defined(HAVE_PTP_TIMER_SET_ABSOLUTE_U64) && \ 
   79     IS_USED(MODULE_PERIPH_PTP_TIMER) 
   80 #error "Neither ptp_timer_set_absolute() nor ptp_timer_set_absolute_u64() implemented" 
  148         uint64_t abs_offset = offset;
 
  158         uint64_t abs_offset = -offset;
 
  242 #if defined(HAVE_PTP_CLOCK_READ) || defined(DOXYGEN) 
  252 #if defined(HAVE_PTP_CLOCK_READ_U64) || defined(DOXYGEN) 
  266 #if defined(HAVE_PTP_CLOCK_SET) || defined(DOXYGEN) 
  277 #if defined(HAVE_PTP_CLOCK_SET_U64) || defined(DOXYGEN) 
  300 #if defined(HAVE_PTP_TIMER_SET_ABSOLUTE) || defined(DOXYGEN) 
  316 #if defined(HAVE_PTP_TIMER_SET_ABSOLUTE_U64) || defined(DOXYGEN) 
  354 #ifndef HAVE_PTP_CLOCK_READ 
  361 #ifndef HAVE_PTP_CLOCK_READ_U64 
  370 #ifndef HAVE_PTP_CLOCK_SET 
  377 #ifndef HAVE_PTP_CLOCK_SET_U64 
  386 #ifndef HAVE_PTP_TIMER_SET_ABSOLUTE 
  393 #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.