44 #define PTP_FLAGRUNNING 0x01
100 ptpClock.portDS[0].portState = PTP_PS_INITIALIZING;
103 ptp_meanDelayAtLastAdjust = 0;
104 ptp_lastAdjustTime.secondsField.secondsLow = 0;
105 ptp_lastAdjustTime.secondsField.secondsHigh = 0;
106 ptp_lastAdjustTime.nanoSecondsField = 0;
110 ptpClock.defaultDS.numberPorts = 1;
114 ptp_meanPathDelay[portIndex] = 0;
130 ptpClock.parentDS.parentPortIdentity.clockIdentity =
131 ptpClock.defaultDS.clockIdentity;
132 ptpClock.parentDS.grandMasterIdentity = ptpClock.defaultDS.clockIdentity;
151 if ((ptpClock.defaultDS.clockQuality.clockClass == 13)
152 || (ptpClock.defaultDS.clockQuality.clockClass == 14))
158 ptpClock.timePropertiesDS.timeSource =
159 PTP_TS_INTERNAL_OSCILLATOR;
179 portIndex = ptpClock.defaultDS.numberPorts;
182 if (ptpClock.portDS[portIndex].portState == PTP_PS_INITIALIZING){
205 portIndex = portNumber - 1;
207 && (ptpClock.portDS[portIndex].delayMechanism ==
PTP_DM_P2P)) {
209 portNumber = portIndex;
211 portNumber = portIndex;
217 portNumber = ptpClock.defaultDS.numberPorts;
219 if (ptpClock.defaultDS.numberPorts == 1) {
267 if ((pBuf[1] & 0x0F) != 2)
277 *(ptpClock.defaultDS.clockIdentity)) == 0)
281 switch (pBuf[0] & 0x0F) {
331 ptpClock.defaultDS.clockQuality.clockClass = clockClass;
332 ptpClock.defaultDS.clockQuality.clockAccuracy = clockAccuracy;
333 ptpClock.timePropertiesDS.timeSource = timeSource;
367 if (*timeAdjust < 0) {
368 *timeAdjust = -*timeAdjust;
371 if (*timeAdjust < 1000000)
372 ptpClock.defaultDS.clockQuality.clockAccuracy = PTP_CA_001MS;
373 else if (*timeAdjust < 10000000)
374 ptpClock.defaultDS.clockQuality.clockAccuracy = PTP_CA_010MS;
375 else if (*timeAdjust < 100000000)
376 ptpClock.defaultDS.clockQuality.clockAccuracy = PTP_CA_100MS;
377 else if (*timeAdjust < 1000000000)
378 ptpClock.defaultDS.clockQuality.clockAccuracy = PTP_CA_001US;
379 else if (*timeAdjust < 10000000000)
380 ptpClock.defaultDS.clockQuality.clockAccuracy = PTP_CA_010S;
383 *timeAdjust = -*timeAdjust;
unsigned char ptp_boolean
void ptp_clock_initialize()
PTP clock initialization.
ptp_uinteger8 ptp_MsgAnnounceSnd()
Send Announce message.
UInt16 ptp_process()
PTP process.
unsigned long long ptp_uinteger64
void ptp_init()
PTP initialization.
ptp_integer8 ptp_clockIdentityCompare(ptp_clockIdentity A, ptp_clockIdentity B)
Clock identity compare.
void ptp_initEnd()
PTP initialization completion.
void ptp_MsgPdelayReqRcv(ptp_octet *pBuf, PTP_TimeStamp *t2, ptp_uinteger8 portNumber)
Receive PDelay_Req message.
void ptp_MsgAnnounceRcv(ptp_octet *pBuf, ptp_uinteger8 portNumber)
Receive Announce message.
UInt32 clock_tickSize
Tick size (ns)
unsigned long ptp_uinteger32
ptp_clockIdentity * ptp_getClockIdentity()
Get clock identity.
UInt8 uart_startFrame(UInt8 len, UInt8 cmd0, UInt8 cmd1)
Start frame.
UInt8 uart_sndUInt16(UInt16 v)
Send UInt16.
PTP functions specific to the implementation.
UInt8 uart_sndUInt32(UInt32 *p)
Send UInt32.
UInt16 ptp_processPDelayReq()
Process PDelayReq.
Pdelay_Resp_Follow_Up message.
void ptp_state_decision_event()
State decision event.
ptp_uinteger8 ptp_tsTimeout
#define PTP_LOG2ANNOUNCESYNCPDELEREQ
unsigned char ptp_uinteger8
void ptp_portsSetListening()
Ports set listening.
void ptp_MsgPdelayReqCheck()
Check for PDelay_Req message.
void ptp_adjNetTime(ptp_integer64 *timeAdjust)
Adjust net time.
void ptp_setNetTime(PTP_TimeStamp *time, ptp_uinteger8 clockClass, ptp_clockAccuracy clockAccuracy, ptp_timeSource timeSource)
Set net time.
void ptp_getCurrentTime(PTP_TimeStamp *dest)
Get cuttent time.
ptp_uinteger8 ptp_MsgPdelayReqSnd(ptp_uinteger8 portNumber)
Send PDelay_Req message.
void ptp_rcvmessage(ptp_octet *pBuf, ptp_uinteger8 portNumber, ptp_uinteger16 size)
Receive message.
void uart_endFrame()
End frame.
void ptp_setTickTime(ptp_uinteger32 *newTickSize)
Set tick time.
UInt16 nwk_getNeighborAddress(UInt8 portNumber)
Get neighbor address.
void clock_setTime(clock_timeStamp *sourceTime)
Set time.
void ptp_MsgPdelayRespRcv(ptp_octet *pBuf, PTP_TimeStamp *t4, ptp_uinteger8 portNumber)
Receive Pdelay_Resp message.
ptp_uinteger16 ptp_rcvUInt16(ptp_octet *pBuf)
Receive unsigned 16 bits integer.
void clock_adjTime(int64_t *adjValue)
Adjust time.
unsigned short ptp_uinteger16
void clock_getTime(clock_timeStamp *destTime)
Get time.