SZSPTP ez430-RF2480 1.0

ZigBee Sensor Network with synchronized time and time-stamped measurements.
Clock

Software clock based on periodic calls to his tick function. More...

Files

file  clock.c
 Clock implementation.
 
file  clock.h
 Clock interface.
 

Classes

struct  clock_secondsCount
 Seconds count. More...
 
struct  clock_timeStamp
 Time stamp. More...
 

Typedefs

typedef struct clock_secondsCount clock_secondsCount
 Seconds count. More...
 
typedef struct clock_timeStamp clock_timeStamp
 Time stamp. More...
 

Functions

void clock_init ()
 Clock Initialization. More...
 
void clock_tick ()
 Clock tick. More...
 
void clock_checkDelayedTick ()
 Check delayed tick. More...
 
void clock_getTime (clock_timeStamp *destTime)
 Get time. More...
 
void clock_setTime (clock_timeStamp *sourceTime)
 Set time. More...
 
void clock_adjTime (int64_t *adjValue)
 Adjust time. More...
 
void clock_adjTimeValues (int64_t *adjValue, clock_timeStamp *time)
 Adjust time values. More...
 
void clock_adjTick (Int32 adjValue)
 Adjust tick. More...
 
int64_t clock_timeDiff (clock_timeStamp *t1, clock_timeStamp *t2)
 Time difference. More...
 

Variables

UInt32 clock_tickSize
 Tick size (ns) More...
 

Detailed Description

Software clock based on periodic calls to his tick function.

The tick size can be adjusted to compensate oscillator constant error. The clock can be adjusted and there is external functions to get current time from an epoch, initially the power up of the device or last reset.

Typedef Documentation

Seconds count.

The seconds count is split into 2 parts, the lower one with 32 bits and the higher one with 16 bits, forming 48 bits total. They are easily put together to represent a 48 bits integer, observing the bit order.

Time stamp.

Representation of a time stamp, the range allows representation of UTC, TAI, and may be other time references.

Function Documentation

void clock_adjTick ( Int32  adjValue)

Adjust tick.

This function adjusts the tick size.

Parameters
[in]adjValueAmount of ns to add to the tick size.

Definition at line 511 of file clock.c.

References CLOCK_TICK_SIZE_MAX, and clock_tickSize.

Referenced by clock_adjTime().

+ Here is the caller graph for this function:

void clock_adjTime ( int64_t *  adjValue)

Adjust time.

This function adjusts the clock time.

Parameters
[in]adjValuePointer to amount of ns to add to the clock time (signed).

Definition at line 256 of file clock.c.

References clock_adjSumSinceSint, clock_adjTick(), clock_adjTimeValues(), and clock_ticksSinceSint.

Referenced by ptp_adjNetTime(), and ptp_adjTime().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void clock_adjTimeValues ( int64_t *  adjValue,
clock_timeStamp time 
)

Adjust time values.

This function adjusts a given time stamp.

Parameters
[in]adjValuePointer to amount of ns to add to the time stamp (signed).
[in,out]timeTime stamp that will be adjusted.

Definition at line 304 of file clock.c.

References clock_checkDelayedTick(), CLOCK_CLEARADJUSTING, CLOCK_NS_IN_ONE_S, and CLOCK_SETADJUSTING.

Referenced by clock_adjTime(), and ptp_adjTime().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void clock_checkDelayedTick ( )

Check delayed tick.

This function checks for a delayed tick call and executes it if needed.

Definition at line 202 of file clock.c.

References CLOCK_CLEARCALLTICK, CLOCK_GETCALLTICK, and clock_tick().

Referenced by clock_adjTimeValues(), clock_getTime(), and clock_setTime().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void clock_getTime ( clock_timeStamp destTime)

Get time.

This function reads the current time.

Parameters
[out]destTimePointer to variable that will receive the time

Definition at line 218 of file clock.c.

References clock_checkDelayedTick(), CLOCK_CLEARADJUSTING, and CLOCK_SETADJUSTING.

Referenced by ADC10_ISR(), ptp_getCurrentTime(), and ptp_process().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void clock_init ( )

Clock Initialization.

This function initializes the clock variables.

Definition at line 148 of file clock.c.

References clock_adjSumSinceSint, CLOCK_CLEARADJUSTING, CLOCK_CLEARCALLTICK, CLOCK_DEFAULT_TICK_SIZE, clock_tickSize, clock_ticksSinceSint, im_disable_interrupt(), and im_enable_interrupt().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void clock_setTime ( clock_timeStamp sourceTime)

Set time.

This function sets the current time.

Parameters
[in]sourceTimePointer to variable containing the time to which the clock time will be set.

Definition at line 237 of file clock.c.

References clock_checkDelayedTick(), CLOCK_CLEARADJUSTING, and CLOCK_SETADJUSTING.

Referenced by ptp_adjTime(), and ptp_setNetTime().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void clock_tick ( )

Clock tick.

This function advances the clock in tick size.

Definition at line 171 of file clock.c.

References CLOCK_GETADJUSTING, CLOCK_NS_IN_ONE_S, CLOCK_SETCALLTICK, clock_tickSize, and clock_ticksSinceSint.

Referenced by clock_checkDelayedTick(), and TMRB0_ISR().

+ Here is the caller graph for this function:

int64_t clock_timeDiff ( clock_timeStamp t1,
clock_timeStamp t2 
)

Time difference.

This function calculates the difference between two given times.

Parameters
[in]t1Pointer to the supposedly initial time.
[in]t2Pointer to the supposedly final time.
Returns
Time difference, in ns, t2 - t1. May be negative.

Definition at line 533 of file clock.c.

Referenced by ptp_adjTime(), and ptp_timeDiff().

+ Here is the caller graph for this function:

Variable Documentation

UInt32 clock_tickSize

Tick size (ns)

Size of the tick of the clock, it can be adjusted to compensate oscillator error.

Definition at line 102 of file clock.c.

Referenced by clock_adjTick(), clock_init(), clock_tick(), ptp_process(), ptp_setTickTime(), and rep_proccess().