SZSPTP ez430-RF2480 1.0

ZigBee Sensor Network with synchronized time and time-stamped measurements.
PTP
+ Collaboration diagram for PTP:

Modules

 Configurable values
 PTP configurable values.
 
 PTP Clock
 PTP clock synchronization device.
 
 PTP Constants
 Constant values used by PTP.
 
 PTP data sets
 PTP data sets.
 
 PTP Messages
 Generation and processing of PTP messages.
 
 PTP Types
 
 PTP Utilities
 Utilities for use by the PTP implementation.
 

Files

file  ptp.c
 PTP implementation.
 
file  ptp.h
 PTP interface.
 
file  ptp_cfg.h
 PTP configuration values to compile.
 
file  ptp_clock.c
 PTP clock object for synchronization.
 
file  ptp_clock.h
 PTP clock object for synchronization.
 
file  ptp_const.h
 PTP constants that should not need to be modified.
 
file  ptp_datasets.h
 PTP datasets.
 
file  ptp_types.h
 PTP data types specifications.
 
file  ptp_util.c
 PTP functions specific to the implementation.
 
file  ptp_util.h
 PTP functions specific to the implementation.
 

Functions

void ptp_init ()
 PTP initialization. More...
 
void ptp_initEnd ()
 PTP initialization completion. More...
 
UInt16 ptp_process ()
 PTP process. More...
 
UInt16 ptp_processPDelayReq ()
 Process PDelayReq. More...
 
void ptp_rcvmessage (ptp_octet *pBuf, ptp_uinteger8 portNumber, ptp_uinteger16 size)
 Receive message. More...
 
void ptp_setNetTime (PTP_TimeStamp *time, ptp_uinteger8 clockClass, ptp_clockAccuracy clockAccuracy, ptp_timeSource timeSource)
 Set net time. More...
 
void ptp_setTickTime (ptp_uinteger32 *newTickSize)
 Set tick time. More...
 
void ptp_adjNetTime (ptp_integer64 *timeAdjust)
 Adjust net time. More...
 

Variables

ptp_clock ptpClock
 
ptp_uinteger64 ptp_meanPathDelay [PTP_NUMBERPORTS]
 
PTP_foreignMasterDS ptp_foreignMaster [PTP_NUMBERPORTS][1]
 
ptp_integer64 ptp_lastAdjust
 
ptp_uinteger64 ptp_meanDelayAtLastAdjust
 
PTP_TimeStamp ptp_lastAdjustTime
 

Detailed Description

Function Documentation

void ptp_adjNetTime ( ptp_integer64 timeAdjust)

Adjust net time.

Adjust the time when the time reference is external.

Parameters
[in]timeAdjustValue of adjust, signed

Definition at line 363 of file ptp.c.

References clock_adjTime(), PTP_TSTIMEOUT, and ptp_tsTimeout.

Referenced by uart_proccessCmd().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ptp_init ( )

PTP initialization.

This function initializes the PTP on the device. It must be called once when device starts before ptp_process. The end of initialization id done by ptp_initEnd. To reset the PTP clock, there is no need to call this function, only ptp_initEnd must be called. This function can be called to stop STATE_DECISION_EVENT inside ptp_process but ptp_initEnd must be called afterwards to return to normal operation.

Definition at line 95 of file ptp.c.

References ptp_clock_initialize(), ptp_flags, PTP_NUMBERPORTS, and ptp_tsTimeout.

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ptp_initEnd ( )

PTP initialization completion.

This function must be called to end the initialization state of the PTP clock. clochIdentity is read and ports' states are set to PTP_PS_LISTENING to run. IEC 61588-2009 / IEEE 1588-2008 9.2.5, Figure 23.

Definition at line 128 of file ptp.c.

References ptp_getClockIdentity(), and ptp_portsSetListening().

Referenced by nwk_getDeviceInfoRsp().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt16 ptp_process ( )

PTP process.

This function process pending messages and must be called periodically.

Returns
Time to run again (ms); 0 means 65536ms

Definition at line 145 of file ptp.c.

References clock_getTime(), clock_tickSize, nwk_getNeighborAddress(), PTP_DM_P2P, ptp_flags, PTP_LOG2ANNOUNCESYNCPDELEREQ, PTP_LOG2TSVERIFY, ptp_MsgAnnounceSnd(), ptp_MsgPdelayReqSnd(), PTP_NUMBERPORTS, ptp_state_decision_event(), ptp_tsTimeout, uart_endFrame(), uart_sndUInt16(), uart_sndUInt32(), and uart_startFrame().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UInt16 ptp_processPDelayReq ( )

Process PDelayReq.

This function checks for a PDelayReq awaiting to be processed.

Returns
Always 1

Definition at line 241 of file ptp.c.

References ptp_MsgPdelayReqCheck().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ptp_rcvmessage ( ptp_octet pBuf,
ptp_uinteger8  portNumber,
ptp_uinteger16  size 
)

Receive message.

This function handles PTP received messages. It must be called as soon as the packet being received is detected to be PTP. There were another function inside ptp_messages but the code whas moved here to lower stack use. Offsets from table 18 at IEC 61588-2009 / IEEE 1588-2008 13.3.1

Parameters
[in]pBuf- Message to be processed

Definition at line 257 of file ptp.c.

References ptp_clockIdentityCompare(), ptp_getCurrentTime(), ptp_MsgAnnounceRcv(), ptp_MsgPdelayReqRcv(), ptp_MsgPdelayRespRcv(), PTP_MSGTYPE_ANNOUNCE, PTP_MSGTYPE_DELAY_REQ, PTP_MSGTYPE_DELAY_RESP, PTP_MSGTYPE_FOLLOW_UP, PTP_MSGTYPE_MANAGEMENT, PTP_MSGTYPE_PDELAY_REQ, PTP_MSGTYPE_PDELAY_RESP, PTP_MSGTYPE_PDELAY_RESP_FOLLOW_UP, PTP_MSGTYPE_SIGNALING, PTP_MSGTYPE_SYNC, and ptp_rcvUInt16().

Referenced by nwk_rcv().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ptp_setNetTime ( PTP_TimeStamp time,
ptp_uinteger8  clockClass,
ptp_clockAccuracy  clockAccuracy,
ptp_timeSource  timeSource 
)

Set net time.

Set the time and the reference to external. May become the grand-master clock.

Parameters
[in]timeTime to write on the clock
[in]clockClassNew clock class
[in]clockAccuracyNew clock accuracy
[in]timeSourceNew time source code

Definition at line 328 of file ptp.c.

References clock_setTime(), ptp_flags, ptp_state_decision_event(), PTP_TSTIMEOUT, and ptp_tsTimeout.

Referenced by uart_proccessCmd().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ptp_setTickTime ( ptp_uinteger32 newTickSize)

Set tick time.

Set the time of each tick of the clock.

Parameters
[in]newTickSizeNew tick time, in nano-seconds

Definition at line 349 of file ptp.c.

References clock_tickSize.

Referenced by uart_proccessCmd().

+ Here is the caller graph for this function: