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

Data Structures

struct  ptp_clock_driver_api
  Driver Operations PTP Clock driver operations More...

Typedefs

typedef int(* ptp_clock_api_set_t) (const struct device *dev, struct net_ptp_time *tm)
 Set the time of the PTP clock.
typedef int(* ptp_clock_api_get_t) (const struct device *dev, struct net_ptp_time *tm)
 Get the time of the PTP clock.
typedef int(* ptp_clock_api_adjust_t) (const struct device *dev, int increment)
 Adjust the PTP clock time.
typedef int(* ptp_clock_api_rate_adjust_t) (const struct device *dev, double ratio)
 Adjust the PTP clock rate ratio based on its nominal frequency.
typedef int(* ptp_clock_api_adjust_rate_t) (const struct device *dev, int64_t scaled_ppm)
 Adjust the PTP clock rate by an offset from its nominal frequency.

Functions

static int64_t ptp_clock_scaled_ppm_to_ppb (int64_t scaled_ppm)
 Convert a scaled parts-per-million rate offset to parts per billion.
static int ptp_clock_adjust_by_scaled_ppm (uint32_t base, int64_t scaled_ppm, uint32_t *result)
 Apply a scaled parts-per-million rate offset to a nominal value.

Detailed Description

This group contains the API type definitions, callback signatures, and other helpers required to implement a PTP Clock driver.

Typedef Documentation

◆ ptp_clock_api_adjust_rate_t

typedef int(* ptp_clock_api_adjust_rate_t) (const struct device *dev, int64_t scaled_ppm)

#include <zephyr/drivers/ptp_clock.h>

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

See ptp_clock_adjust_rate() for argument description.

◆ ptp_clock_api_adjust_t

typedef int(* ptp_clock_api_adjust_t) (const struct device *dev, int increment)

#include <zephyr/drivers/ptp_clock.h>

Adjust the PTP clock time.

See ptp_clock_adjust() for argument description.

◆ ptp_clock_api_get_t

typedef int(* ptp_clock_api_get_t) (const struct device *dev, struct net_ptp_time *tm)

#include <zephyr/drivers/ptp_clock.h>

Get the time of the PTP clock.

See ptp_clock_get() for argument description.

◆ ptp_clock_api_rate_adjust_t

typedef int(* ptp_clock_api_rate_adjust_t) (const struct device *dev, double ratio)

#include <zephyr/drivers/ptp_clock.h>

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

See ptp_clock_rate_adjust() for argument description.

Deprecated
Use ptp_clock_api_adjust_rate_t instead.

◆ ptp_clock_api_set_t

typedef int(* ptp_clock_api_set_t) (const struct device *dev, struct net_ptp_time *tm)

#include <zephyr/drivers/ptp_clock.h>

Set the time of the PTP clock.

See ptp_clock_set() for argument description.

Function Documentation

◆ ptp_clock_adjust_by_scaled_ppm()

int ptp_clock_adjust_by_scaled_ppm ( uint32_t base,
int64_t scaled_ppm,
uint32_t * result )
inlinestatic

#include <zephyr/drivers/ptp_clock.h>

Apply a scaled parts-per-million rate offset to a nominal value.

Computes base * (1 + scaled_ppm / (1000000 * 2^16)) with integer arithmetic, rounded to nearest. Meant for drivers that tune the clock rate through an addend register.

Parameters
baseNominal value
scaled_ppmRate offset in parts per million with a 16-bit binary fractional field
resultWhere to store the adjusted value
Return values
0Success
-ERANGERate offset is beyond +-100 % or the adjusted value does not fit in 32 bits

◆ ptp_clock_scaled_ppm_to_ppb()

int64_t ptp_clock_scaled_ppm_to_ppb ( int64_t scaled_ppm)
inlinestatic

#include <zephyr/drivers/ptp_clock.h>

Convert a scaled parts-per-million rate offset to parts per billion.

Parameters
scaled_ppmRate offset in parts per million with a 16-bit binary fractional field
Returns
Rate offset in parts per billion, rounded to nearest