Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
wr2rf-vme
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
wr2rf-vme
Commits
164912af
Commit
164912af
authored
Jun 04, 2021
by
John Robert Gill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added option to set RFNCO frequency from API and ignore incoming beam control RFframes.
parent
7fa5e847
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
1 deletion
+146
-1
ad9910_init.c
software/libwr2rf/ad9910_init.c
+21
-0
board.c
software/libwr2rf/board.c
+76
-0
api.h
software/libwr2rf/libwr2rf/api.h
+5
-0
wr2rf.c
software/libwr2rf/wr2rf.c
+44
-1
No files found.
software/libwr2rf/ad9910_init.c
View file @
164912af
...
...
@@ -129,6 +129,27 @@ libwr2rf_dds_init(struct libwr2rf_dev *dev, unsigned io_update)
return
0
;
}
int
libwr2rf_dds_freq_init
(
struct
libwr2rf_dev
*
dev
,
uint64_t
freq
,
unsigned
io_update
)
{
int
res
;
/* Probe. */
res
=
ad9910_probe
(
dev
);
if
(
res
!=
0
)
return
res
;
/* Configure sync. */
/* TODO. */
libwr2rf_dds_configure_sync
(
dev
,
0
,
0
,
0
);
/* Program. */
uint64_t
ftw
=
ad9910_frequency_to_ftw
(
freq
);
ad9910_program
(
dev
,
ftw
,
0
,
0x0
,
io_update
);
return
0
;
}
void
libwr2rf_dds_sync_calibrate
(
struct
libwr2rf_dev
*
dev
,
int
verbose
)
{
...
...
software/libwr2rf/board.c
View file @
164912af
...
...
@@ -1010,6 +1010,82 @@ int libwr2rf_vtu_nco_reset_delay (struct libwr2rf_dev *dev, unsigned id,
return
0
;
}
int
libwr2rf_nco_lcfg
(
struct
libwr2rf_dev
*
dev
,
unsigned
ch
,
unsigned
lcfg
,
unsigned
long
long
ftw
)
{
unsigned
long
long
LO
=
0x1C9BA5E300000
;
//223.5 MHz
unsigned
off
=
0
;
unsigned
harmonic
=
4620
;
unsigned
control
=
RFNCO_CONTROL_SOFTLOAD
;
// | RFNCO_CONTROL_SELFTWH1;// | RFNCO_CONTROL_SELWRFTWH1;
unsigned
nco_ftw_addr
=
RFNCO_FTW_H1
;
unsigned
nco_harmonic_addr
=
RFNCO_FTW_H
;
unsigned
nco_LO0_addr
=
RFNCO_FTW_LO0
;
unsigned
nco_LO1_addr
=
RFNCO_FTW_LO1
;
unsigned
nco_control_addr
=
RFNCO_CONTROL
;
unsigned
ftw_src
;
switch
(
ch
)
{
case
LIBWR2RF_RF1_CHANNEL_ID
:
off
=
WR2RF_VME_REGS_CTRL
+
WR2RF_CTRL_REGS_RF1_RFNCO
;
break
;
case
LIBWR2RF_RF2_CHANNEL_ID
:
off
=
WR2RF_VME_REGS_CTRL
+
WR2RF_CTRL_REGS_RF2_RFNCO
;
break
;
default:
return
LIBWR2RF_ERROR_BAD_ID
;
}
nco_ftw_addr
+=
off
;
nco_LO0_addr
+=
off
;
nco_LO1_addr
+=
off
;
nco_harmonic_addr
+=
off
;
nco_control_addr
+=
off
;
printf
(
"nco_ftw_addr=%x nco_L00_addr=%x nco_LO1_addr=%x nco_harmonic_addr=%x nco_control_addr=%x
\n
"
,
nco_ftw_addr
,
nco_LO0_addr
,
nco_LO1_addr
,
nco_harmonic_addr
,
nco_control_addr
);
ftw_src
=
libwr2rf_read16
(
dev
,
WR2RF_VME_REGS_INIT
+
WR2RF_INIT_REGS_NCO_LOC_OR_WRS
);
if
(
lcfg
==
0
)
{
printf
(
"lcfg == 0
\n
"
);
unsigned
val
=
libwr2rf_16x32_read32
(
dev
,
nco_control_addr
);
val
=
val
&
~
control
;
libwr2rf_16x32_write32
(
dev
,
nco_control_addr
,
val
);
ftw_src
&=
~
WR2RF_INIT_REGS_NCO_LOC_OR_WRS_PARAMS_SEL
;
libwr2rf_write16
(
dev
,
WR2RF_VME_REGS_INIT
+
WR2RF_INIT_REGS_NCO_LOC_OR_WRS
,
ftw_src
);
return
0
;
}
ftw_src
|=
WR2RF_INIT_REGS_NCO_LOC_OR_WRS_PARAMS_SEL
;
libwr2rf_write16
(
dev
,
WR2RF_VME_REGS_INIT
+
WR2RF_INIT_REGS_NCO_LOC_OR_WRS
,
ftw_src
);
libwr2rf_16x32_write32
(
dev
,
nco_ftw_addr
+
0
,
ftw
);
libwr2rf_16x32_write32
(
dev
,
nco_ftw_addr
+
4
,
ftw
>>
32
);
libwr2rf_16x32_write32
(
dev
,
nco_LO0_addr
+
0
,
LO
);
libwr2rf_16x32_write32
(
dev
,
nco_LO0_addr
+
4
,
LO
>>
32
);
libwr2rf_16x32_write32
(
dev
,
nco_LO1_addr
+
0
,
LO
);
libwr2rf_16x32_write32
(
dev
,
nco_LO1_addr
+
4
,
LO
>>
32
);
libwr2rf_16x32_write32
(
dev
,
nco_harmonic_addr
,
harmonic
);
libwr2rf_16x32_write32
(
dev
,
nco_control_addr
,
control
);
printf
(
"ftw=%08x.%08x LO=%08x.%08x L1=%08x.%08x harmonic=%08x control=%08x
\n
"
,
libwr2rf_16x32_read32
(
dev
,
nco_ftw_addr
+
4
),
libwr2rf_16x32_read32
(
dev
,
nco_ftw_addr
+
0
),
libwr2rf_16x32_read32
(
dev
,
nco_LO0_addr
+
4
),
libwr2rf_16x32_read32
(
dev
,
nco_LO0_addr
+
0
),
libwr2rf_16x32_read32
(
dev
,
nco_LO1_addr
+
4
),
libwr2rf_16x32_read32
(
dev
,
nco_LO1_addr
+
0
),
libwr2rf_16x32_read32
(
dev
,
nco_harmonic_addr
),
libwr2rf_16x32_read32
(
dev
,
nco_control_addr
)
);
return
0
;
}
int
libwr2rf_vtu_rf_reset_offset
(
struct
libwr2rf_dev
*
dev
,
unsigned
id
,
unsigned
wr_cycles
)
{
unsigned
addr
=
0
;
...
...
software/libwr2rf/libwr2rf/api.h
View file @
164912af
...
...
@@ -237,6 +237,11 @@ 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
);
/* 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. */
int
libwr2rf_nco_lcfg
(
struct
libwr2rf_dev
*
dev
,
unsigned
ch
,
unsigned
lcfg
,
unsigned
long
long
ftw
);
/* Dump (on stdout) the state of VTU ID. Return < 0 in case of error (bad ID).
This is a debug function. */
...
...
software/libwr2rf/wr2rf.c
View file @
164912af
...
...
@@ -639,6 +639,9 @@ nco_lcfg (struct libwr2rf_dev *dev, int argc, char **argv)
libwr2rf_16x32_write32
(
dev
,
nco_harmonic_addr
,
harmonic
);
libwr2rf_16x32_write32
(
dev
,
nco_control_addr
,
control
);
printf
(
"nco_ftw_addr=%x nco_L00_addr=%x nco_LO1_addr=%x nco_harmonic_addr=%x nco_control_addr=%x
\n
"
,
nco_ftw_addr
,
nco_LO0_addr
,
nco_LO1_addr
,
nco_harmonic_addr
,
nco_control_addr
);
printf
(
"ftw=%08x.%08x LO=%08x.%08x L1=%08x.%08x harmonic=%08x control=%08x
\n
"
,
libwr2rf_16x32_read32
(
dev
,
nco_ftw_addr
+
4
),
libwr2rf_16x32_read32
(
dev
,
nco_ftw_addr
+
0
),
...
...
@@ -699,7 +702,8 @@ nco_wrcfg (struct libwr2rf_dev *dev, int argc, char **argv)
unsigned
long
long
LO1
=
0x1C9BA5E300000
;
//223.5 MHz
unsigned
off
=
0
;
unsigned
harmonic
=
4620
;
unsigned
control
=
RFNCO_CONTROL_SELFTWH1
|
RFNCO_CONTROL_EXTRESETENABLE
|
RFNCO_CONTROL_SELLOAD
|
RFNCO_CONTROL_SELWRFTWH1
;
unsigned
control
=
RFNCO_CONTROL_SELFTWH1
|
RFNCO_CONTROL_EXTRESETENABLE
|
RFNCO_CONTROL_SELLOAD
|
RFNCO_CONTROL_SELWRFTWH1
;
unsigned
nco_harmonic_addr
=
RFNCO_FTW_H
;
unsigned
nco_LO0_addr
=
RFNCO_FTW_LO0
;
unsigned
nco_LO1_addr
=
RFNCO_FTW_LO1
;
...
...
@@ -1482,6 +1486,21 @@ dds_ioupdate (struct libwr2rf_dev *dev, int argc, char **argv)
libwr2rf_dds_ioupdate
(
dev
);
}
static
void
dds_freq
(
struct
libwr2rf_dev
*
dev
,
int
argc
,
char
**
argv
)
{
if
(
argc
!=
2
)
{
printf
(
"usage: %s dds_freq
\n
"
,
argv
[
0
]);
return
;
}
uint64_t
freq
=
strtoull
(
argv
[
1
],
NULL
,
0
);
libwr2rf_dds_freq_init
(
dev
,
freq
,
1
);
return
;
}
static
void
set_rfout
(
struct
libwr2rf_dev
*
dev
,
int
argc
,
char
**
argv
)
{
...
...
@@ -3784,6 +3803,28 @@ api_nco_reset_delay (struct libwr2rf_dev *dev, int argc, char **argv)
printf
(
"ERROR
\n
"
);
}
static
void
api_nco_lcfg
(
struct
libwr2rf_dev
*
dev
,
int
argc
,
char
**
argv
)
{
unsigned
ch
;
unsigned
lcfg
;
unsigned
long
long
ftw
;
if
(
argc
!=
4
)
{
printf
(
"usage: %s CH lcfg_enable ftw
\n
"
,
argv
[
0
]);
return
;
}
ch
=
strtoul
(
argv
[
1
],
NULL
,
0
);
lcfg
=
strtoul
(
argv
[
2
],
NULL
,
0
);
ftw
=
strtoull
(
argv
[
3
],
NULL
,
0
);
printf
(
"ch=%d lcfg=%d ftw=%llx
\n
"
,
ch
,
lcfg
,
ftw
);
if
(
libwr2rf_nco_lcfg
(
dev
,
ch
,
lcfg
,
ftw
)
!=
0
)
printf
(
"ERROR
\n
"
);
}
static
void
api_nco_reset_ignore
(
struct
libwr2rf_dev
*
dev
,
int
argc
,
char
**
argv
)
{
...
...
@@ -3964,6 +4005,7 @@ static struct cmds cmds[] =
{
"api-diag-enable"
,
api_diag_enable
,
"configure diag unit"
},
{
"api-diag-read"
,
api_diag_read
,
"read diag unit"
},
{
"api-nco-reset-delay"
,
api_nco_reset_delay
,
"set nco reset delay"
},
{
"api-nco-lcfg"
,
api_nco_lcfg
,
"configures the RFNCO to output a local fixed frequency."
},
{
"api-tmgio"
,
api_tmgio
,
"set lemo io output enable and termination"
},
{
"api-tmgclk"
,
api_tmgclk
,
"set lemo clk output enable and termination"
},
{
"api-nco-reset-ignore"
,
api_nco_reset_ignore
,
"ignore (or not) nco reset"
},
...
...
@@ -4007,6 +4049,7 @@ static struct cmds cmds[] =
{
"dds-sync-set"
,
dds_sync_set
,
"writes the ad9910's sync_receiver_delay and sync_validation_delay values"
},
{
"dds-sync-status"
,
dds_sync_status
,
"Reads the dds sync error status"
},
{
"dds-ioupdate"
,
dds_ioupdate
,
"Resets the output phase of the RF (if already preprogrammed)"
},
{
"dds-freq"
,
dds_freq
,
"control the DDS output frequency - useful for standalone DDS rf signal output"
},
{
"dac-xdds"
,
dac_xdds
,
"control the xilinx DDS for testing the IQdac"
},
{
"dac-iqsetpoint"
,
dac_iqsetpoint
,
"configures the amplitude and phase for the IQdacs"
},
{
"dac-iqctrl"
,
dac_iqctrl
,
"Selects the IQdata lines between RFNCO+IQMod or debug DDS"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment