Commit 90411237 authored by Aurelio Colosimo's avatar Aurelio Colosimo

fix master/slave selection to be selected by wrpc-sw

When ppsi is used as a module for wr-pc, Master/Slave selection is no more
defined at compile time, but selected by 'mode' shell cmd. The obsolete
WRMODE is hence relevant only when ppsi-bin main is compiled.
Signed-off-by: Aurelio Colosimo's avatarAurelio Colosimo <aurelio@aureliocolosimo.it>
parent 22c7e74f
......@@ -43,10 +43,13 @@ else
include proto-standard/Makefile
endif
WRMODE = slave
# WRMODE - Update 2012-11-24
# obsolete compilation parameter. No used when ppsi is compiled inside wrpc-sw.
# Still used only by ppsi standalone main. In this case, set WRMODE=master|slave
WRMODE = none
ifeq ($(WRMODE), master)
CFLAGS += -DPPSI_MASTER
else
else ifeq ($(WRMODE), slave)
CFLAGS += -DPPSI_SLAVE
endif
......
......@@ -5,6 +5,7 @@
#include <uart.h>
#include <ppsi/ppsi.h>
#include <ppsi/diag.h>
#include "../proto-ext-whiterabbit/wr-api.h" /* FIXME: ugly */
#include "spec.h"
......@@ -67,6 +68,7 @@ void ppsi_main(void)
#ifdef PPSI_SLAVE
OPTS(ppi)->slave_only = 1;
DSPOR(ppi)->wrConfig = WR_S_ONLY;
#endif
spec_main_loop(ppi);
......
......@@ -38,6 +38,7 @@ struct pp_runtime_opts {
Integer32 ttl;
char *unicast_addr;
UInteger32 slave_only:1,
master_only:1,
no_adjust:1,
display_stats:1,
csv_stats:1,
......
......@@ -254,6 +254,11 @@ UInteger8 bmc_state_decision( struct pp_instance *ppi,
{
int cmpres;
if (OPTS(ppi)->master_only) {
m1(ppi);
return PPS_MASTER;
}
if (OPTS(ppi)->slave_only) {
s1(ppi, hdr, ann);
return PPS_SLAVE;
......
......@@ -68,10 +68,6 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
DSPOR(ppi)->logMinPdelayReqInterval = PP_DEFAULT_PDELAYREQ_INTERVAL;
DSPOR(ppi)->versionNumber = PP_VERSION_PTP;
/* FIXME: should be autodetected */
#ifdef PPSI_SLAVE
DSPOR(ppi)->wrConfig = WR_S_ONLY;
#else
int lock_timeout, start_tics;
start_tics = timer_get_tics();
......@@ -92,7 +88,6 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
}
PP_PRINTF("\nLocking end.\n");
shw_pps_gen_enable_output(1);
#endif
DSPOR(ppi)->wrStateTimeout = WR_DEFAULT_STATE_TIMEOUT_MS;
DSPOR(ppi)->wrStateRetry = WR_DEFAULT_STATE_REPEAT;
DSPOR(ppi)->calPeriod = WR_DEFAULT_CAL_PERIOD;
......@@ -109,7 +104,10 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
msg_pack_header(ppi, ppi->buf_out);
ppi->next_state = PPS_LISTENING;
if (!OPTS(ppi)->master_only)
ppi->next_state = PPS_LISTENING;
else
ppi->next_state = PPS_MASTER;
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment