Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
ptp_clock.h File Reference

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

#include <errno.h>
#include <zephyr/kernel.h>
#include <stdint.h>
#include <zephyr/device.h>
#include <zephyr/sys/math_extras.h>
#include <zephyr/sys/util.h>
#include <zephyr/net/ptp_time.h>
#include <zephyr/syscalls/ptp_clock.h>

Go to the source code of this file.

Data Structures

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

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.

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.
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

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