Пример #1
0
/*SoftPLL must be locked prior calling this function*/
static int calib_t24p_slave(uint32_t *value)
{
	int rv;
	uint32_t prev;

	rxts_calibration_start();
	while (!(rv = rxts_calibration_update(value)))
		/* FIXME: timeout */;
	if (rv < 0) {
		/* Fall back on master == eeprom-or-error */
		return calib_t24p_master(value);
	}

	/*
	 * Let's see if we have a matching value in EEPROM:
	 * accept a 200ps difference, otherwise rewrite eeprom
	 */
	rv = storage_phtrans(&prev, 0 /* rd */);
	if (rv < 0 || (prev < *value - 200) || (prev > *value + 200)) {
		rv = storage_phtrans(value, 1);
		pp_printf("Wrote new t24p value: %d ps (%s)\n", *value,
			  rv < 0 ? "Failed" : "Success");
	}
	return rv;
}
Пример #2
0
/*SoftPLL must be locked prior calling this function*/
static int calib_t24p_slave(uint32_t *value)
{
	int rv;

	rxts_calibration_start();
	while (!(rv = rxts_calibration_update(value))) ;

	if (rv < 0) {
		printf("Could not calibrate t24p, trying to read from EEPROM\n");
		if(eeprom_phtrans(WRPC_FMC_I2C, FMC_EEPROM_ADR, value, 0) < 0) {
			printf("Something went wrong while writing EEPROM\n");
			return -1;
		}

	}
	else {
		printf("t24p value is %d ps, storing to EEPROM\n", *value);
		if(eeprom_phtrans(WRPC_FMC_I2C, FMC_EEPROM_ADR, value, 1) < 0) {
			printf("Something went wrong while writing EEPROM\n");
			return -1;
		}
	}

	return 0;
}
Пример #3
0
/* legacy function for 'calibration force' command */
int measure_t24p(uint32_t *value)
{
	int rv;
	pp_printf("Waiting for link...\n");
	while (!ep_link_up(NULL))
		timer_delay_ms(100);

	spll_init(SPLL_MODE_SLAVE, 0, 1);
	pp_printf("Locking PLL...\n");
	while (!spll_check_lock(0))
		timer_delay_ms(100);
	pp_printf("\n");

	pp_printf("Calibrating RX timestamper...\n");
	rxts_calibration_start();

	while (!(rv = rxts_calibration_update(value))) ;
	return rv;
}