flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
slave.c File Reference
#include "slave.h"
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include "common.h"
#include "format_utils.h"
#include "msg_utils.h"
#include "ptp_types.h"
#include "settings_interface.h"
#include "stats.h"
#include "task_ptp.h"
#include "timeutils.h"
#include "ptp_core.h"
#include "ptp_defs.h"
#include "minmax.h"

Go to the source code of this file.

Macros

#define PTP_FC_SKEW_CORRECTION_CYCLES   (4)
 Fast compensation: no. of skew correction cycles.
 
#define PTP_FC_TIME_CORRECTION_CYCLES   (1)
 Fast compensation: no. of time correction cycles.
 
#define PTP_FC_TIME_PROPAGATION_CYCLES   (2)
 

Functions

static void ptp_tune_clock (float tuning_ppb)
 
static void ptp_perform_correction ()
 
static void ptp_commence_e2e_correction ()
 
static void ptp_commence_p2p_correction (uint32_t pdelRespSeqId)
 
void ptp_slave_process_message (RawPtpMessage *pRawMsg, PtpHeader *pHeader)
 
void ptp_slave_init ()
 
void ptp_slave_destroy ()
 
void ptp_slave_reset ()
 
void ptp_slave_tick ()
 
void ptp_slave_enable ()
 
void ptp_slave_disable ()
 

Macro Definition Documentation

◆ PTP_FC_SKEW_CORRECTION_CYCLES

#define PTP_FC_SKEW_CORRECTION_CYCLES   (4)

Fast compensation: no. of skew correction cycles.

Definition at line 45 of file slave.c.

◆ PTP_FC_TIME_CORRECTION_CYCLES

#define PTP_FC_TIME_CORRECTION_CYCLES   (1)

Fast compensation: no. of time correction cycles.

Definition at line 46 of file slave.c.

◆ PTP_FC_TIME_PROPAGATION_CYCLES

#define PTP_FC_TIME_PROPAGATION_CYCLES   (2)

Definition at line 47 of file slave.c.

Function Documentation

◆ ptp_commence_e2e_correction()

static void ptp_commence_e2e_correction ( )
static

Initiate the E2E correction. This piece of code has been extracted from the ptp_slave_process_message() to prevent code duplication.

Definition at line 258 of file slave.c.

◆ ptp_commence_p2p_correction()

static void ptp_commence_p2p_correction ( uint32_t  pdelRespSeqId)
static

Initiate the P2P correction. This piece of code has been extracted from the ptp_slave_process_message() to prevent code duplication.

Parameters
pdelRespSeqIdsequence ID of the last completed PDel_Req...PDel_Resp(_Follow_Up) cycle

Definition at line 287 of file slave.c.

◆ ptp_perform_correction()

static void ptp_perform_correction ( )
static

Perform clock correction based on gathered timestamps.

Definition at line 52 of file slave.c.

◆ ptp_slave_destroy()

void ptp_slave_destroy ( )

Destroy the PTP slave.

Definition at line 484 of file slave.c.

◆ ptp_slave_disable()

void ptp_slave_disable ( )

Stop PTP slave (autonomous) operation.

Definition at line 555 of file slave.c.

◆ ptp_slave_enable()

void ptp_slave_enable ( )

Start PTP slave (autonomous) operation.

Definition at line 547 of file slave.c.

◆ ptp_slave_init()

void ptp_slave_init ( )

Initialize the PTP slave.

Definition at line 476 of file slave.c.

◆ ptp_slave_process_message()

void ptp_slave_process_message ( RawPtpMessage pRawMsg,
PtpHeader pHeader 
)

Process PTP packet addressed to a slave clock.

Parameters
pRawMsgpointer to the raw PTP message
pHeaderpointer to the extracted PTP header

Definition at line 300 of file slave.c.

◆ ptp_slave_reset()

void ptp_slave_reset ( )

Reset the PTP slave.

Definition at line 488 of file slave.c.

◆ ptp_slave_tick()

void ptp_slave_tick ( )

Tick the slave module.

Definition at line 520 of file slave.c.

◆ ptp_tune_clock()

static void ptp_tune_clock ( float  tuning_ppb)
static

Clock tuning.

Parameters
tuning_ppbclock tuning in PPB

Definition at line 34 of file slave.c.