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
1400d2bc
Commit
1400d2bc
authored
Apr 03, 2023
by
John Robert Gill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Software changes to support RF timestamps, IQdac timing, and version increment
parent
2ca38be9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
3 deletions
+130
-3
board.c
software/libwr2rf/board.c
+74
-1
dac_timing.c
software/libwr2rf/dac_timing.c
+2
-2
api.h
software/libwr2rf/libwr2rf/api.h
+14
-0
wr2rf.c
software/libwr2rf/wr2rf.c
+40
-0
No files found.
software/libwr2rf/board.c
View file @
1400d2bc
...
...
@@ -343,7 +343,7 @@ unsigned libwr2rf_read_fwversion(struct libwr2rf_dev *dev)
int
libwr2rf_check_fwversion
(
struct
libwr2rf_dev
*
dev
)
{
return
!
(
libwr2rf_read_fwversion
(
dev
)
==
0x00001
5
00
);
return
!
(
libwr2rf_read_fwversion
(
dev
)
==
0x00001
6
00
);
}
void
libwr2rf_read_nco_ipinfo
(
struct
libwr2rf_dev
*
dev
,
...
...
@@ -1481,3 +1481,76 @@ libwr2rf_rfframerx_ts(struct libwr2rf_dev *dev, unsigned ts_nco_reset, uint64_t
*
ts_cycles
=
cyc
;
return
0
;
}
int
libwr2rf_wr_leapsec
(
struct
libwr2rf_dev
*
dev
,
uint32_t
*
ts_leapsec
)
{
*
ts_leapsec
=
LIBWR2RF_LEAPSEC
;
return
0
;
}
int
libwr2rf_vtu_timestamps
(
struct
libwr2rf_dev
*
dev
,
unsigned
id
,
uint64_t
*
ts_vtu_tai_first
,
uint32_t
*
ts_vtu_cycles_first
,
uint64_t
*
ts_vtu_tai_last
,
uint32_t
*
ts_vtu_cycles_last
)
{
unsigned
baddr
;
unsigned
val
;
uint64_t
secs
=
0
;
uint32_t
cycles
=
0
;
switch
(
id
)
{
case
LIBWR2RF_TRIG_ID_RF_1_TRIG_1
:
baddr
=
WR2RF_VME_REGS_CTRL
+
WR2RF_CTRL_REGS_RF1_VTUS
+
WR2RF_RFTRIGGER_REGS_T1
;
break
;
case
LIBWR2RF_TRIG_ID_RF_1_TRIG_2
:
baddr
=
WR2RF_VME_REGS_CTRL
+
WR2RF_CTRL_REGS_RF1_VTUS
+
WR2RF_RFTRIGGER_REGS_T2
;
break
;
case
LIBWR2RF_TRIG_ID_RF_2_TRIG_1
:
baddr
=
WR2RF_VME_REGS_CTRL
+
WR2RF_CTRL_REGS_RF2_VTUS
+
WR2RF_RFTRIGGER_REGS_T1
;
break
;
case
LIBWR2RF_TRIG_ID_RF_2_TRIG_2
:
baddr
=
WR2RF_VME_REGS_CTRL
+
WR2RF_CTRL_REGS_RF2_VTUS
+
WR2RF_RFTRIGGER_REGS_T2
;
break
;
default:
return
LIBWR2RF_ERROR_BAD_ID
;
}
secs
=
0
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_FIRSTTRIGTAISEC
);
secs
=
secs
|
((
uint64_t
)
val
)
<<
48
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_FIRSTTRIGTAISEC
+
2
);
secs
=
secs
|
((
uint64_t
)
val
)
<<
32
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_FIRSTTRIGTAISEC
+
4
);
secs
=
secs
|
((
uint64_t
)
val
)
<<
16
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_FIRSTTRIGTAISEC
+
6
);
secs
=
secs
|
((
uint64_t
)
val
)
<<
0
;
*
ts_vtu_tai_first
=
secs
;
cycles
=
0
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_FIRSTTRIGTAICYCLES
+
0
);
cycles
=
cycles
|
((
uint64_t
)
val
)
<<
16
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_FIRSTTRIGTAICYCLES
+
2
);
cycles
=
cycles
|
((
uint64_t
)
val
)
<<
0
;
*
ts_vtu_cycles_first
=
cycles
;
secs
=
0
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_LASTTRIGTAISEC
);
secs
=
secs
|
((
uint64_t
)
val
)
<<
48
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_LASTTRIGTAISEC
+
2
);
secs
=
secs
|
((
uint64_t
)
val
)
<<
32
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_LASTTRIGTAISEC
+
4
);
secs
=
secs
|
((
uint64_t
)
val
)
<<
16
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_LASTTRIGTAISEC
+
6
);
secs
=
secs
|
((
uint64_t
)
val
)
<<
0
;
*
ts_vtu_tai_last
=
secs
;
cycles
=
0
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_LASTTRIGTAICYCLES
+
0
);
cycles
=
cycles
|
((
uint64_t
)
val
)
<<
16
;
val
=
libwr2rf_read16
(
dev
,
baddr
+
TRIGUNIT_REGS_TS_LASTTRIGTAICYCLES
+
2
);
cycles
=
cycles
|
((
uint64_t
)
val
)
<<
0
;
*
ts_vtu_cycles_last
=
cycles
;
return
0
;
}
software/libwr2rf/dac_timing.c
View file @
1400d2bc
...
...
@@ -258,13 +258,13 @@ int libwr2rf_dac_port_timing(struct libwr2rf_dev *dev, unsigned ch)
best
=
32
;
for
(
i
=
1
;
i
<
31
;
i
++
)
{
if
(
results
[
i
].
seek
==
1
)
{
if
(
results
[
i
].
seek
==
0
)
{
// this is inverted, to avoid two acceptable windows
diff
=
results
[
i
].
hld
-
results
[
i
].
set
;
sum
=
results
[
i
].
hld
+
results
[
i
].
set
;
if
(
results
[
i
].
set
<
results
[
i
].
hld
)
{
if
(
(
results
[
i
].
set
+
results
[
i
].
hld
)
>
8
)
{
printf
(
"set=%02u hld=%02u diff=%02d, sum=%02u
\n
"
,
results
[
i
].
set
,
results
[
i
].
hld
,
diff
,
sum
);
if
((
diff
<
min_diff
)
&&
(
sum
>
max_sum
))
{
if
((
diff
<
min_diff
)
&&
(
sum
>
=
max_sum
))
{
min_diff
=
diff
;
max_sum
=
sum
;
best
=
i
;
...
...
software/libwr2rf/libwr2rf/api.h
View file @
1400d2bc
...
...
@@ -305,4 +305,18 @@ that have elapsed in the current TAI epoch and cycles is the number of WR clock
(16 ns) that have elapsed within the current second. */
int
libwr2rf_rfframerx_ts
(
struct
libwr2rf_dev
*
dev
,
unsigned
ts_nco_reset
,
uint64_t
*
ts_tai
,
uint32_t
*
ts_cycles
);
#define LIBWR2RF_LEAPSEC 37
/* Read the current leapsecond value utilised by White Rabbit. This is the offset between
the TAI seconds and UTC seconds, such that; utc = tai + leapsecs */
int
libwr2rf_wr_leapsec
(
struct
libwr2rf_dev
*
dev
,
uint32_t
*
ts_leapsec
);
/* Returns timestamps of the first VTU trigger output after a start pulse and also a
timestamp of the last trigger pulse output from the VTU. Timestamps have two components:
tai in seconds and cycles in 8 ns*/
int
libwr2rf_vtu_timestamps
(
struct
libwr2rf_dev
*
dev
,
unsigned
id
,
uint64_t
*
ts_vtu_tai_first
,
uint32_t
*
ts_vtu_cycles_first
,
uint64_t
*
ts_vtu_tai_last
,
uint32_t
*
ts_vtu_cycles_last
);
#endif
/* __LIBWR2RF__API__H_ */
software/libwr2rf/wr2rf.c
View file @
1400d2bc
...
...
@@ -4080,6 +4080,44 @@ api_tmgio (struct libwr2rf_dev *dev, int argc, char **argv)
printf
(
"ERROR
\n
"
);
}
static
void
api_wr_leapsec
(
struct
libwr2rf_dev
*
dev
,
int
argc
,
char
**
argv
)
{
unsigned
leapsec
;
if
(
libwr2rf_wr_leapsec
(
dev
,
&
leapsec
))
printf
(
"ERROR
\n
"
);
printf
(
"WR leapsec val=%d
\n
"
,
leapsec
);
}
static
void
api_vtu_timestamps
(
struct
libwr2rf_dev
*
dev
,
int
argc
,
char
**
argv
)
{
int
res
;
unsigned
long
id
;
uint64_t
tai_first
;
uint32_t
cycles_first
;
uint64_t
tai_last
;
uint32_t
cycles_last
;
if
(
argc
!=
2
)
{
printf
(
"usage: %s VTU-ID
\n
"
,
argv
[
0
]);
return
;
}
id
=
parse_api_vtu
(
argv
[
1
]);
if
(
id
==
BADADDR
)
return
;
res
=
libwr2rf_vtu_timestamps
(
dev
,
id
,
&
tai_first
,
&
cycles_first
,
&
tai_last
,
&
cycles_last
);
if
(
res
!=
0
)
printf
(
"%s: failed (status=%d)
\n
"
,
__FUNCTION__
,
res
);
printf
(
"%s:
\n
"
,
__FUNCTION__
);
printf
(
"FIRST TAI: %010lu, cycles: %08u
\n
"
,
tai_first
,
cycles_first
);
printf
(
"LAST TAI: %010lu, cycles: %08u
\n
"
,
tai_last
,
cycles_last
);
}
static
void
calib_dds_ioupdate
(
struct
libwr2rf_dev
*
dev
,
int
argc
,
char
**
argv
)
{
...
...
@@ -4187,6 +4225,8 @@ static struct cmds cmds[] =
{
"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-wr-leapsec"
,
api_wr_leapsec
,
"retrieve the current leapsec information"
},
{
"api-vtu-timestamps"
,
api_vtu_timestamps
,
"Return timestamps of the first and last vtu trigger output pulses after the VTU has been started"
},
{
"api-nco-reset-ignore"
,
api_nco_reset_ignore
,
"ignore (or not) nco reset"
},
{
"ftw-show"
,
ftw_show
,
"show received ftw"
},
{
"ftw-last"
,
framerxtx_last
,
"display last ftw"
},
...
...
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