SatCat5
cfgbus_ptpref.h
Go to the documentation of this file.
1 // Copyright 2022-2025 The Aerospace Corporation.
3 // This file is a part of SatCat5, licensed under CERN-OHL-W v2 or later.
16 
17 #pragma once
18 
19 #include <satcat5/cfgbus_core.h>
20 #include <satcat5/ptp_filters.h>
21 #include <satcat5/ptp_tracking.h>
22 
23 namespace satcat5 {
24  namespace cfg {
28  public:
32  constexpr PtpReference(
33  const satcat5::cfg::Register& reg,
34  double ref_clk_hz, unsigned scale=40)
35  : m_reg(reg), m_rate(ref_clk_hz, scale) {}
36 
37  // Implement rate-control only for the TrackingClock API.
39  const satcat5::ptp::Time& amount) override;
40  void clock_rate(s64 offset) override;
41  satcat5::ptp::Time clock_now() override;
42 
44  void clock_rate_raw(s64 rate);
45 
46  protected:
47  satcat5::cfg::Register m_reg; // Control register
48  const satcat5::ptp::RateConversion m_rate;
49  };
50 
54  public:
58  constexpr PtpRealtime(
59  const satcat5::cfg::Register& reg,
60  double ref_clk_hz, unsigned scale=40)
61  : m_reg(reg), m_rate(ref_clk_hz, scale) {}
62 
63  // Implement the full TrackingClock API.
65  const satcat5::ptp::Time& amount) override;
66  void clock_rate(s64 offset) override;
67  satcat5::ptp::Time clock_now() override;
68 
70  void clock_rate_raw(s64 rate);
71 
74 
76  void clock_set(const satcat5::ptp::Time& new_time);
77 
78  protected:
79  void load(const satcat5::ptp::Time& time);
80  satcat5::cfg::Register m_reg; // Base control register
81  const satcat5::ptp::RateConversion m_rate;
82  };
83  }
84 }
ConfigBus core definitions.
PTP reference with rate-control and coarse-adjust command.
Definition: cfgbus_ptpref.h:53
void clock_set(const satcat5::ptp::Time &new_time)
Coarse adjustment of the current time.
satcat5::ptp::Time clock_adjust(const satcat5::ptp::Time &amount) override
Make a one-time adjustment of the specified magnitude.
constexpr PtpRealtime(const satcat5::cfg::Register &reg, double ref_clk_hz, unsigned scale=40)
PtpRealtime uses a block of six control registers.
Definition: cfgbus_ptpref.h:58
void clock_rate_raw(s64 rate)
Legacy API for rate-control without additional scaling.
satcat5::ptp::Time clock_ext()
Read timestamp of external rising-edge signal.
satcat5::ptp::Time clock_now() override
Return the current time if available, TIME_ZERO otherwise.
void clock_rate(s64 offset) override
Adjust rate by a normalized frequency offset.
PTP reference counter with rate-control only.
Definition: cfgbus_ptpref.h:27
satcat5::ptp::Time clock_now() override
Return the current time if available, TIME_ZERO otherwise.
constexpr PtpReference(const satcat5::cfg::Register &reg, double ref_clk_hz, unsigned scale=40)
PtpReference is a thin-wrapper for a single control register.
Definition: cfgbus_ptpref.h:32
void clock_rate_raw(s64 rate)
Legacy API for rate-control without additional scaling.
satcat5::ptp::Time clock_adjust(const satcat5::ptp::Time &amount) override
Make a one-time adjustment of the specified magnitude.
void clock_rate(s64 offset) override
Adjust rate by a normalized frequency offset.
Pointer-like wrapper for one or more ConfigBus registers.
Definition: cfgbus_core.h:76
Convert normalized frequency offset to ticks-per-clock.
Definition: ptp_filters.h:545
High-precision timestamp for use with PTP / IEEE1588.
Definition: ptp_time.h:41
Generic interface to a numerically-controlled reference clock.
Definition: ptp_tracking.h:52
Chainable filters for use with ptp::TrackingController.
Closed-loop time-tracking clocks and tracking control.