flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
bmca.c File Reference
#include "bmca.h"
#include "clock_utils.h"
#include "event.h"
#include "format_utils.h"
#include "ptp_core.h"
#include "ptp_defs.h"
#include "ptp_types.h"
#include "task_ptp.h"
#include <flexptp_options.h>
#include <stdint.h>
#include <string.h>

Go to the source code of this file.

Macros

#define COMPARE_AND_RETURN(pmp1, pmp2, field)
 
#define SBMC_PRINT_LOG(p, c)
 

Functions

int ptp_select_better_master (PtpMasterProperties *pMP1, PtpMasterProperties *pMP2)
 
static void ptp_bmca_handle_state_change (PtpBmcaFsmState state)
 
void ptp_bmca_tick ()
 
void ptp_handle_announce_msg (PtpAnnounceBody *pAnn, PtpHeader *pHeader)
 
void ptp_bmca_init ()
 
void ptp_bmca_destroy ()
 
void ptp_bmca_reset ()
 

Variables

static char * BMCA_HINTS []
 

Macro Definition Documentation

◆ COMPARE_AND_RETURN

#define COMPARE_AND_RETURN (   pmp1,
  pmp2,
  field 
)
Value:
{ \
if (pmp1->field < pmp2->field) { \
return 0; \
} else if (pmp1->field > pmp2->field) { \
return 1; \
} \
}

Definition at line 22 of file bmca.c.

◆ SBMC_PRINT_LOG

#define SBMC_PRINT_LOG (   p,
 
)
Value:
if (S.logging.bmca) \
MSG("%s -> %s\n", BMCA_HINTS[(p)], BMCA_HINTS[(c)]);
static char * BMCA_HINTS[]
Definition: bmca.c:41

Definition at line 52 of file bmca.c.

Function Documentation

◆ ptp_bmca_destroy()

void ptp_bmca_destroy ( )

Destroy SBMC module.

Definition at line 205 of file bmca.c.

◆ ptp_bmca_handle_state_change()

static void ptp_bmca_handle_state_change ( PtpBmcaFsmState  state)
static

Definition at line 57 of file bmca.c.

◆ ptp_bmca_init()

void ptp_bmca_init ( )

Initialize SBMC module.

Definition at line 191 of file bmca.c.

◆ ptp_bmca_reset()

void ptp_bmca_reset ( )

Reset the SBMC module.

Definition at line 209 of file bmca.c.

◆ ptp_bmca_tick()

void ptp_bmca_tick ( )

Call this to notify SBMC about the time passing.

Definition at line 72 of file bmca.c.

◆ ptp_handle_announce_msg()

void ptp_handle_announce_msg ( PtpAnnounceBody pAnn,
PtpHeader pHeader 
)

Handle announce messages.

Parameters
pAnnpointer to PtpAnnounceBody object
pHeaderpointer to Announce message header

Definition at line 135 of file bmca.c.

◆ ptp_select_better_master()

int ptp_select_better_master ( PtpMasterProperties pMP1,
PtpMasterProperties pMP2 
)

Select better master. (Not "best", with intent!)

Parameters
pMP1pointer to the first master's PtpMasterProperites object
pMP2pointer to the second master's PtpMasterProperites object
Returns
0: if pMP1 is better than pMP2, 1: if reversed

Definition at line 31 of file bmca.c.

Variable Documentation

◆ BMCA_HINTS

char* BMCA_HINTS[]
static
Initial value:
= {
"INITIALIZING",
"LISTENING",
"PRE_MASTER",
"MASTER",
"SLAVE",
"PASSIVE",
"UNCALIBRATED",
"FAULTY",
"DISABLED"}

Definition at line 41 of file bmca.c.