SZSPTP ez430-RF2480 1.0

ZigBee Sensor Network with synchronized time and time-stamped measurements.
ptp_util.c File Reference

PTP functions specific to the implementation. More...

#include <stdlib.h>
#include "ptp_util.h"
#include "ptp.h"
#include "ptp_const.h"
#include "ptp_cfg.h"
#include "ptp_types.h"
#include "ptp_messages.h"
#include "clock.h"
#include "nwk.h"
+ Include dependency graph for ptp_util.c:

Go to the source code of this file.

Functions

void ptp_bmc ()
 Best master clock. More...
 
void ptp_portUpdateDS ()
 Port update data set. More...
 
void ptp_portUpdateStatus ()
 Port update status. More...
 
ptp_clockIdentityptp_getClockIdentity ()
 Get clock identity. More...
 
void ptp_getCurrentTime (PTP_TimeStamp *dest)
 Get cuttent time. More...
 
void ptp_adjTime (PTP_TimeStamp *t1, PTP_TimeStamp *t2, ptp_uinteger8 portIndex)
 Adjust the clock. More...
 
ptp_integer64 ptp_timeDiff (PTP_TimeStamp *t1, PTP_TimeStamp *t2)
 Time difference. More...
 
ptp_integer8 ptp_clockIdentityCompare (ptp_clockIdentity A, ptp_clockIdentity B)
 Clock identity compare. More...
 
void ptp_portsSetListening ()
 Ports set listening. More...
 
void ptp_state_decision_event ()
 State decision event. More...
 
ptp_integer8 ptp_dataSetComparisonEE (ptp_uinteger8 *iBetter, ptp_boolean *byTopology, PTP_announceDS *E1, PTP_announceDS *E2, ptp_uinteger8 i1, ptp_uinteger8 i2)
 Data set comparison. More...
 
ptp_integer8 ptp_dataSetComparisonDE (ptp_boolean *Dbetter, ptp_clock *D, PTP_announceDS *E, ptp_uinteger8 portNumber)
 Data set comparison self clock/announce message. More...
 
void ptp_storeForeignMaster (ptp_octet *pBuf, ptp_uinteger8 portNumber)
 Store foreign master. More...
 
ptp_uinteger8 ptp_startFrame (ptp_uinteger16 destination, ptp_uinteger8 len)
 Start Frame. More...
 
ptp_uinteger8 ptp_snd (ptp_uinteger8 len, void *pBuf)
 Send data. More...
 
void ptp_endFrame ()
 End frame. More...
 
ptp_uinteger8 ptp_sndUInt8 (ptp_uinteger8 v)
 Send unsigned 8 bits integer. More...
 
ptp_uinteger8 ptp_sndUInt16 (ptp_uinteger16 v)
 Send unsigned 16 bits integer. More...
 
ptp_uinteger8 ptp_sndUInt32 (ptp_uinteger32 *p)
 Send unsigned 32 bits integer. More...
 
ptp_uinteger8 ptp_sndUInt48 (ptp_uinteger48 *p)
 Send unsigned 48 bits integer. More...
 
ptp_uinteger8 ptp_sndUInt48sc (PTP_SecondsCount *p)
 Send a seconds count value. More...
 
ptp_uinteger8 ptp_sndUInt64 (ptp_uinteger64 *p)
 Send unsigned 64 bits integer. More...
 
ptp_uinteger8 ptp_sndInt64 (ptp_integer64 *p)
 Send 64 bits integer. More...
 
ptp_uinteger8 ptp_rcvUInt8 (ptp_octet *pBuf)
 Receive unsigned 8 bits integer. More...
 
ptp_uinteger16 ptp_rcvUInt16 (ptp_octet *pBuf)
 Receive unsigned 16 bits integer. More...
 
ptp_uinteger32 ptp_rcvUInt32 (ptp_octet *pBuf)
 Receive unsigned 32 bits integer. More...
 
ptp_uinteger48 ptp_rcvUInt48 (ptp_octet *pBuf)
 Receive unsigned 48 bits integer. More...
 
void ptp_rcvUInt48sc (ptp_octet *pBuf, PTP_SecondsCount *p)
 Receive seconds count value. More...
 
ptp_uinteger64 ptp_rcvUInt64 (ptp_octet *pBuf)
 Receive unsigned 64 bits integer. More...
 
ptp_integer64 ptp_rcvInt64 (ptp_octet *pBuf)
 Receive 64 bits integer. More...
 
void ptp_rcvOctets (ptp_uinteger8 len, ptp_octet *pBuf, ptp_octet *dest)
 Receive octets. More...
 
void ptp_copyOctets (ptp_uinteger8 len, ptp_octet *source, ptp_octet *dest)
 Copy octets. More...
 

Variables

ptp_recommendedState ptp_portRecommendedState [PTP_NUMBERPORTS]
 Recommended portState set by BMC (Best Master Clock) Algorithm.
 
PTP_announceDS ptp_announce [PTP_NUMBERPORTS]
 Last announce message received for each port.
 

Detailed Description

PTP functions specific to the implementation.

Definition in file ptp_util.c.

Function Documentation

void ptp_bmc ( )

Best master clock.

This function executes the BMC algorithm, this is not the standard algorithm specified on the IEC 61588/IEEE 1588 standard, it is an adaptation to PTP working on a ZigBee network with P2P where the master is always the parent node and the GrandMasterClock is the coordinator. If the port have no connection, the recommendation is to stay on listening state. IEC 61588-2009 / IEEE 1588-2008 9.3.1 b) doesn't describe the listening return value. IEC 61588-2009 / IEEE 1588-2008 9.2.6.8 and 9.3.1 b)

Definition at line 274 of file ptp_util.c.

References nwk_getNeighborAddress(), PTP_BMC_LISTENING, PTP_BMC_M1, PTP_BMC_M2, PTP_BMC_M3, PTP_BMC_P1, PTP_BMC_P2, PTP_BMC_S1, ptp_clockIdentityCompare(), ptp_dataSetComparisonDE(), ptp_dataSetComparisonEE(), ptp_portRecommendedState, and PTP_ZEROSEQ64.

Referenced by ptp_state_decision_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ptp_portUpdateDS ( )

Port update data set.

This function updates data sets for all ports. IEC 61588-2009 / IEEE 1588-2008 9.2.6.8 and 9.3.5

Definition at line 344 of file ptp_util.c.

References nwk_getNeighborAddress(), nwk_getNeighborForeignPort(), PTP_BMC_M1, PTP_BMC_M2, PTP_BMC_M3, PTP_BMC_P1, PTP_BMC_P2, PTP_BMC_S1, PTP_DESIGNTIME_UTCOFFSET, and ptp_portRecommendedState.

Referenced by ptp_state_decision_event().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ptp_portUpdateStatus ( )

Port update status.

This function updates the status for all ports.

Definition at line 445 of file ptp_util.c.

References PTP_BMC_M1, PTP_BMC_M2, PTP_BMC_M3, PTP_BMC_P1, PTP_BMC_P2, PTP_BMC_S1, and ptp_portRecommendedState.

Referenced by ptp_state_decision_event().

+ Here is the caller graph for this function: