Commit 19a1a285 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk Committed by Alessandro Rubini

new t24p calibration fixed

parent 6de5d4af
......@@ -225,7 +225,11 @@ static int calib_t24p_master(uint32_t *value)
int rv;
rv = eeprom_phtrans(WRPC_FMC_I2C, FMC_EEPROM_ADR, value, 0);
printf("t24p read from EEPROM: %d ps\n", *value);
if(rv < 0)
printf("Something went wrong while reading from EEPROM: %d\n", rv);
else
printf("t24p read from EEPROM: %d ps\n", *value);
return rv;
}
......
......@@ -13,6 +13,6 @@
void rxts_calibration_start();
int rxts_calibration_update(int *t24p_value);
int measure_t24p(uint32_t *value);
int calib_t24p(int mode, int *value);
int calib_t24p(int mode, uint32_t *value);
#endif
......@@ -31,7 +31,7 @@ static int read_phase_val(hexp_port_state_t *state)
return 0;
}
extern int32_t cal_phase_transition;
extern uint32_t cal_phase_transition;
extern int32_t sfp_alpha;
int halexp_get_port_state(hexp_port_state_t *state, const char *port_name)
......
......@@ -11,6 +11,8 @@
#include "../PTPWRd/datatypes.h"
#include "wrc_ptp.h"
#include <syscon.h>
#include <rxts_calibrator.h>
#include <wrc.h>
uint64_t ptpd_netif_get_msec_tics(void)
{
......@@ -74,7 +76,7 @@ static int read_phase_val(hexp_port_state_t *state)
return 0;
}
extern int32_t cal_phase_transition;
extern uint32_t cal_phase_transition;
extern int32_t sfp_alpha;
int halexp_get_port_state(hexp_port_state_t *state, const char *port_name)
......@@ -131,7 +133,22 @@ int ptpd_netif_locking_enable(int txrx, const char *ifaceName, int priority)
int ptpd_netif_locking_poll(int txrx, const char *ifaceName, int priority)
{
return spll_check_lock(0) ? PTPD_NETIF_READY : PTPD_NETIF_ERROR;
int locked;
static int t24p_calibrated = 0;
locked = spll_check_lock(0);
if(!locked) {
t24p_calibrated = 0;
}
else if(locked && !t24p_calibrated) {
/*run t24p calibration if needed*/
mprintf("running t24p calibration\n");
calib_t24p(WRC_MODE_SLAVE, &cal_phase_transition);
t24p_calibrated = 1;
}
return locked ? PTPD_NETIF_READY : PTPD_NETIF_ERROR;
}
int ptpd_netif_read_calibration_data(const char *ifaceName, uint64_t *deltaTx,
......
ppsi @ 70d8dbec
Subproject commit cc84c606faeb506404fe63dcd219bd77e7dd6a3f
Subproject commit 70d8dbecf2a6cf72dbac93078c42dc8a83decfe1
......@@ -22,13 +22,14 @@
#include "ptpd.h"
#include "ptpd_netif.h"
#include "i2c.h"
//#include "eeprom.h"
#include "eeprom.h"
#include "softpll_ng.h"
#include "onewire.h"
#include "pps_gen.h"
#include "sockitowm.h"
#include "shell.h"
#include "lib/ipv4.h"
#include "rxts_calibrator.h"
#include "wrc_ptp.h"
......@@ -61,6 +62,11 @@ static void wrc_initialize()
w1_scan_bus(&wrpc_w1_bus);
#endif
/*initialize I2C bus*/
mi2c_init(WRPC_FMC_I2C);
/*check if EEPROM is onboard*/
eeprom_present(WRPC_FMC_I2C, FMC_EEPROM_ADR);
mac_addr[0] = 0x08; //
mac_addr[1] = 0x00; // CERN OUI
mac_addr[2] = 0x30; //
......@@ -85,6 +91,8 @@ static void wrc_initialize()
minic_init();
shw_pps_gen_init();
wrc_ptp_init();
//try reading t24 phase transition from EEPROM
calib_t24p(WRC_MODE_MASTER, &cal_phase_transition);
#ifdef CONFIG_ETHERBONE
ipv4_init("wru1");
......
......@@ -18,9 +18,6 @@
#include "wrc_ptp.h"
#include "pps_gen.h"
#include "uart.h"
#include "rxts_calibrator.h"
extern int32_t cal_phase_transition;
static RunTimeOpts rtOpts = {
.ifaceName = {"wr1"},
......@@ -141,9 +138,6 @@ int wrc_ptp_set_mode(int mode)
}
mprintf("\n");
/*t24p calibration here*/
calib_t24p(mode, &cal_phase_transition);
if (mode == WRC_MODE_MASTER || mode == WRC_MODE_GM)
shw_pps_gen_enable_output(1);
......
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