Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
PTP Clock

Interfaces for Precision Time Protocol (PTP) clocks. More...

Topics

 PTP Clock Driver Backend API

Files

file  ptp_clock.h
 Main header file for PTP (Precision Time Protocol) clock driver API.

Macros

#define PTP_CLOCK_NAME   "PTP_CLOCK"
#define PTP_CLOCK_SCALED_PPM_SHIFT   16
 Number of fractional bits in a scaled parts-per-million rate adjustment.
#define PTP_CLOCK_SCALED_PPM_ONE   (INT64_C(1) << PTP_CLOCK_SCALED_PPM_SHIFT)
 One part per million in the scaled rate-adjustment representation.

Functions

static int ptp_clock_set (const struct device *dev, struct net_ptp_time *tm)
 Set the time of the PTP clock.
int ptp_clock_get (const struct device *dev, struct net_ptp_time *tm)
 Get the time of the PTP clock.
static int ptp_clock_adjust (const struct device *dev, int increment)
 Adjust the PTP clock time.
static int ptp_clock_rate_adjust (const struct device *dev, double rate)
 Adjust the PTP clock rate ratio based on its nominal frequency.
static int ptp_clock_adjust_rate (const struct device *dev, int64_t scaled_ppm)
 Adjust the PTP clock rate by an offset from its nominal frequency.

Detailed Description

Interfaces for Precision Time Protocol (PTP) clocks.

Since
1.13
Version
1.1.0

Macro Definition Documentation

◆ PTP_CLOCK_NAME

#define PTP_CLOCK_NAME   "PTP_CLOCK"

◆ PTP_CLOCK_SCALED_PPM_ONE

#define PTP_CLOCK_SCALED_PPM_ONE   (INT64_C(1) << PTP_CLOCK_SCALED_PPM_SHIFT)

#include <zephyr/drivers/ptp_clock.h>

One part per million in the scaled rate-adjustment representation.

◆ PTP_CLOCK_SCALED_PPM_SHIFT

#define PTP_CLOCK_SCALED_PPM_SHIFT   16

#include <zephyr/drivers/ptp_clock.h>

Number of fractional bits in a scaled parts-per-million rate adjustment.

Function Documentation

◆ ptp_clock_adjust()

int ptp_clock_adjust ( const struct device * dev,
int increment )
inlinestatic

#include <zephyr/drivers/ptp_clock.h>

Adjust the PTP clock time.

Parameters
devPTP clock device
incrementIncrement of the clock in nanoseconds
Returns
0 if ok, <0 if error

◆ ptp_clock_adjust_rate()

int ptp_clock_adjust_rate ( const struct device * dev,
int64_t scaled_ppm )
inlinestatic

#include <zephyr/drivers/ptp_clock.h>

Adjust the PTP clock rate by an offset from its nominal frequency.

The offset is not cumulative, it always refers to the nominal frequency of the clock. If the driver only implements the rate ratio operation, the offset is converted and passed to that one.

Parameters
devPTP clock device
scaled_ppmSigned frequency offset from nominal in parts per million with a 16-bit binary fractional field. For example, PTP_CLOCK_SCALED_PPM_ONE represents 1 ppm.
Return values
0Success
-errnoNegative errno code on failure

◆ ptp_clock_get()

int ptp_clock_get ( const struct device * dev,
struct net_ptp_time * tm )

#include <zephyr/drivers/ptp_clock.h>

Get the time of the PTP clock.

Parameters
devPTP clock device
tmWhere to store the current time.
Returns
0 if ok, <0 if error

◆ ptp_clock_rate_adjust()

int ptp_clock_rate_adjust ( const struct device * dev,
double rate )
inlinestatic

#include <zephyr/drivers/ptp_clock.h>

Adjust the PTP clock rate ratio based on its nominal frequency.

If the driver only implements the scaled parts-per-million operation, the ratio is converted and passed to that one.

Deprecated
Use ptp_clock_adjust_rate() instead.
Parameters
devPTP clock device
rateRate ratio based on its nominal frequency
Return values
0Success
-ERANGERate ratio is not representable as scaled parts per million
-errnoOther negative errno code on failure

◆ ptp_clock_set()

int ptp_clock_set ( const struct device * dev,
struct net_ptp_time * tm )
inlinestatic

#include <zephyr/drivers/ptp_clock.h>

Set the time of the PTP clock.

Parameters
devPTP clock device
tmTime to set
Returns
0 if ok, <0 if error