32#include <flexptp_options.h>
41#define MIN(a, b) (((a) < (b)) ? (a) : (b))
46#define S (gPtpCoreState)
78 xTimerStop(S.timers.heartbeat, 0);
79 xTimerDelete(S.timers.heartbeat, 0);
83 xTimerStart(S.timers.heartbeat, 0);
87 xTimerStop(S.timers.heartbeat, 0);
97 srand(S.hwoptions.clockIdentity);
251 switch (event->
code) {
279 S.slave.syncCb = syncCb;
283 S.userEventCb = userEventCb;
void ptp_handle_announce_msg(PtpAnnounceBody *pAnn, PtpHeader *pHeader)
This module implements the Best Master Clock Algorithm.
void ptp_register_cli_commands()
void ptp_remove_cli_commands()
This module handles and registers CLI commands. Commands:
void ptp_create_clock_identity(const uint8_t *hwa)
This module defines clock identity related operations.
void ptp_send_pdelay_resp(const RawPtpMessage *pMsg)
This module defines messaging functions for both the slave and master modules.
In this module are the core and user events defined.
@ PTP_UEV_RESET_DONE
The flexPTP module has been reset.
@ PTP_UEV_PDELAY_RESP_SENT
A PDelay_Resp had been sent (master/slave)
@ PTP_UEV_INIT_DONE
The flexPTP core has been initialized.
@ PTP_UEV_BMCA_STATE_CHANGED
The BMCA state has changed.
@ PTP_UEV_ANNOUNCE_RECVED
An Announce message has been received (master/slave)
@ PTP_UEV_PDELAY_REQ_RECVED
A PDelay_Req had been received (master/slave)
@ PTP_CEV_BMCA_STATE_CHANGED
#define PTP_SET_ADDEND(addend)
#define PTP_HW_INIT(increment, addend)
#define PTP_SERVO_DEINIT()
#define PTP_SERVO_RESET()
#define PTP_INCREMENT_NSEC
This module handles various logging capabilities.
void ptp_master_disable()
void ptp_master_destroy()
void ptp_master_process_message(RawPtpMessage *pRawMsg, PtpHeader *pHeader)
This module implements the master clock functionality.
void ptp_extract_header(PtpHeader *pHeader, const void *pPayload)
void ptp_extract_announce_message(PtpAnnounceBody *pAnnounce, void *pPayload)
This module defines functions that deal with actual PTP messages; they can extract or insert headers,...
This file is a header for the employed Network Stack Driver (NSD). A NSD must define ALL four functio...
void ptp_nsd_init(PtpTransportType tp, PtpDelayMechanism dm)
void ptp_process_event(const PtpCoreEvent *event)
void ptp_init(const uint8_t *hwa)
static void ptp_common_init(const uint8_t *hwa)
void ptp_process_packet(RawPtpMessage *pRawMsg)
void ptp_set_sync_callback(PtpSyncCallback syncCb)
static void ptp_create_heartbeat_tmr()
static void ptp_start_heartbeat_tmr()
void ptp_set_user_event_callback(PtpUserEventCallback userEventCb)
static void ptp_stop_heartbeat_tmr()
static void ptp_heartbeat_tmr_cb(TimerHandle_t timer)
static void ptp_remove_heartbeat_tmr()
Core of the PTP implementation. Defines functions for message processing, clock tuning,...
In here reside a multitude of fundamental PTP-related constants and definitions.
#define PTP_HEARTBEAT_TICKRATE_MS
Heartbeat ticking period.
#define PTP_DEFAULT_SERVO_OFFSET
Default servo offset in nanoseconds.
#define PTP_ADDEND_INIT
Initial addend value.
This module defines the fundamental PTP message and state machine type, flags, bitfields and the PTP ...
void(* PtpUserEventCallback)(PtpUserEventCode uev)
void(* PtpSyncCallback)(int64_t time_error, const PtpSyncCycleData *pSCD, uint32_t freqCodeWord)
PtpMessageType
PTP packet type enumeration.
@ PTP_MT_PDelay_Req
Peer Delay Request.
@ PTP_MT_Announce
Announce.
@ PTP_DM_P2P
Peer-to-Peer Delay Mechanism.
PtpDelayMechanism ptp_get_delay_mechanism()
PtpTransportType ptp_get_transport_type()
This module features functions to tweak around the PTP engine's almost every property.
void ptp_slave_process_message(RawPtpMessage *pRawMsg, PtpHeader *pHeader)
This module implements the slave clock functionality.
This is the statistics module that gathers data of the operating PTP-engine.
Contents of a PTP Announce message without the common PTP header.
Giant PTP core state object.
Raw PTP message structure.
uint8_t data[(128)]
raw packet data
bool ptp_event_enqueue(const PtpCoreEvent *event)
The entry point of the whole PTP-implementation. Calling reg_task_ptp() initializes the PTP-engine,...
TimestampI * nsToTsI(TimestampI *r, int64_t ns)
This module defines storage classes for timestamps and operations on time values.