Commit 2adf08e6 authored by John Robert Gill's avatar John Robert Gill

Added function to read back the VTU sync delays for each RF channel and also the…

Added function to read back the VTU sync delays for each RF channel and also the calibrated/reference delays.
parent e489af03
......@@ -1206,6 +1206,48 @@ int libwr2rf_vtu_rf_reset_offset (struct libwr2rf_dev *dev, unsigned id, unsigne
return 0;
}
int libwr2rf_vtu_sync_delays (struct libwr2rf_dev *dev, unsigned id,
unsigned *cdelay, unsigned *fdelay, unsigned *odelay, unsigned ref)
{
unsigned addr;
unsigned val;
addr = WR2RF_VME_REGS_INIT + WR2RF_INIT_REGS_RF + WR2RF_INIT_RF_CH_REGS_T1_SYNC_PROGDELAY;
switch (id) {
case LIBWR2RF_RF1_CHANNEL_ID:
addr = addr + WR2RF_INIT_RF_REGS_RF1;
break;
case LIBWR2RF_RF2_CHANNEL_ID:
addr = addr + WR2RF_INIT_RF_REGS_RF2;
break;
default:
return LIBWR2RF_ERROR_BAD_ID;
}
if (ref == 1) {
if (id == 1) {
*cdelay = LIBWR2RF_VTU_CH1_CDELAY;
*fdelay = LIBWR2RF_VTU_CH1_FDELAY;
*odelay = LIBWR2RF_VTU_CH1_ODELAY;
} else {
*cdelay = LIBWR2RF_VTU_CH2_CDELAY;
*fdelay = LIBWR2RF_VTU_CH2_FDELAY;
*odelay = LIBWR2RF_VTU_CH2_ODELAY;
}
} else {
val = libwr2rf_read16(dev, addr);
*cdelay = (val & WR2RF_INIT_RF_CH_REGS_T1_SYNC_PROGDELAY_CDELAY_MASK) >>
WR2RF_INIT_RF_CH_REGS_T1_SYNC_PROGDELAY_CDELAY_SHIFT;
*fdelay = (val & WR2RF_INIT_RF_CH_REGS_T1_SYNC_PROGDELAY_FDELAY_MASK) >>
WR2RF_INIT_RF_CH_REGS_T1_SYNC_PROGDELAY_FDELAY_SHIFT;
*odelay = (val & WR2RF_INIT_RF_CH_REGS_T1_SYNC_PROGDELAY_ODELAY_MASK) >>
WR2RF_INIT_RF_CH_REGS_T1_SYNC_PROGDELAY_ODELAY_SHIFT;
}
return 0;
}
int libwr2rf_ioupdate_delay (struct libwr2rf_dev *dev,
unsigned fdelay, unsigned odelay)
......
......@@ -245,6 +245,23 @@ int libwr2rf_vtu_program_invalidate (struct libwr2rf_dev *dev, unsigned id);
int libwr2rf_vtu_nco_reset_delay (struct libwr2rf_dev *dev, unsigned id,
unsigned cdelay, unsigned fdelay,
unsigned odelay);
#define LIBWR2RF_VTU_CH1_CDELAY 75
#define LIBWR2RF_VTU_CH1_FDELAY 5
#define LIBWR2RF_VTU_CH1_ODELAY 10
#define LIBWR2RF_VTU_CH2_CDELAY 75
#define LIBWR2RF_VTU_CH2_FDELAY 4
#define LIBWR2RF_VTU_CH2_ODELAY 20
/* Obtain the delays used for T1 trigger units to sync after an nco_reset. The ref
argument may be used to obtain the calibrated values, in the absence of this the
current values are returned.
CDELAY in 0..127 in 16ns steps,
FDELAY in 0..15ns,
ODELAY in 0..31 in ~78ps steps. */
int libwr2rf_vtu_sync_delays (struct libwr2rf_dev *dev, unsigned id,
unsigned *cdelay, unsigned *fdelay, unsigned *odelay,
unsigned ref );
/* Program the RFNCO to enable/disable local FTW configuration, rather than from the network.
lcfg is enable(1)/disable(0)
ftw is the 48 bit frev value. */
......
......@@ -3407,6 +3407,38 @@ api_vtu_invalidate (struct libwr2rf_dev *dev, int argc, char **argv)
printf ("ERROR\n");
}
static void
api_vtu_sync_delays (struct libwr2rf_dev *dev, int argc, char **argv)
{
unsigned cdelay = 0;
unsigned fdelay = 0;
unsigned odelay = 0;
unsigned cal;
unsigned id;
if (argc != 3)
goto usage;
id = strtoul (argv[1], NULL, 0);
if (id != 1 && id != 2)
goto usage;
cal = strtoul (argv[2], NULL, 0);
if (cal != 0 && cal != 1)
goto usage;
if (libwr2rf_vtu_sync_delays (dev, id, &cdelay, &fdelay, &odelay, cal) != 0)
printf("ERROR\n");
else
printf("VTU=%d.1 cdelay=%d(x16ns), fdelay=%d(x1ns) odelay=%d(x78ps)\n",
id, cdelay, fdelay, odelay);
return;
usage:
printf ("usage: %s RF_CH[1|2] Calibrated_Delays[0|1] \n", argv[0]);
}
static void
vtu_out (struct libwr2rf_dev *dev, int argc, char **argv)
{
......@@ -4133,6 +4165,7 @@ static struct cmds cmds[] =
{ "api-vtu-highfreq", api_vtu_highfreq, "program vtu in highfreq mode"},
{ "api-vtu-window", api_vtu_window, "program vtu in window mode"},
{ "api-vtu-invalidate", api_vtu_invalidate, "invalidate vtu program"},
{ "api-vtu-sync-delays", api_vtu_sync_delays, "Retrieve the reference or current delays that are applied to nco_reset for a VTU sync." },
{ "api-lemo-dbg-sel", api_lemo_dbg_sel, "Select the debug for the front panel lemos"},
{ "api-softstart-sel", api_softstart_sel, "configure which vtu soft start can be output to lemo"},
{ "api-softstop-sel", api_softstop_sel, "configure which vtu soft stop can be output to lemo"},
......
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