Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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
FMC DEL 1ns 4cha
Commits
52ffc463
Commit
52ffc463
authored
May 18, 2012
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/lib/fdelay_lib.c: raw readout mode, ATMCR value tweaking
parent
96c89af6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
9 deletions
+60
-9
fdelay_lib.c
software/lib/fdelay_lib.c
+60
-9
No files found.
software/lib/fdelay_lib.c
View file @
52ffc463
...
@@ -871,6 +871,7 @@ int fdelay_init(fdelay_device_t *dev)
...
@@ -871,6 +871,7 @@ int fdelay_init(fdelay_device_t *dev)
dev
->
priv_fd
=
(
void
*
)
hw
;
dev
->
priv_fd
=
(
void
*
)
hw
;
hw
->
raw_mode
=
0
;
hw
->
base_addr
=
dev
->
base_addr
;
hw
->
base_addr
=
dev
->
base_addr
;
hw
->
base_i2c
=
0x100
;
hw
->
base_i2c
=
0x100
;
hw
->
base_onewire
=
dev
->
base_addr
+
0x500
;
hw
->
base_onewire
=
dev
->
base_addr
+
0x500
;
...
@@ -913,7 +914,8 @@ int fdelay_init(fdelay_device_t *dev)
...
@@ -913,7 +914,8 @@ int fdelay_init(fdelay_device_t *dev)
hw
->
calib
.
frr_poly
[
1
]
=
-
29825595LL
;
hw
->
calib
.
frr_poly
[
1
]
=
-
29825595LL
;
hw
->
calib
.
frr_poly
[
2
]
=
3801939743082LL
;
hw
->
calib
.
frr_poly
[
2
]
=
3801939743082LL
;
hw
->
calib
.
tdc_zero_offset
=
35600
;
hw
->
calib
.
tdc_zero_offset
=
35600
;
hw
->
calib
.
atmcr_val
=
2
|
(
1000
<<
4
);
hw
->
calib
.
atmcr_val
=
4
|
(
1500
<<
4
);
// hw->calib.atmcr_val = 2 | (1000 << 4);
hw
->
calib
.
adsfr_val
=
56648
;
hw
->
calib
.
adsfr_val
=
56648
;
hw
->
calib
.
acam_start_offset
=
10000
;
hw
->
calib
.
acam_start_offset
=
10000
;
for
(
i
=
0
;
i
<
4
;
i
++
)
for
(
i
=
0
;
i
<
4
;
i
++
)
...
@@ -1137,7 +1139,7 @@ int fdelay_configure_readout(fdelay_device_t *dev, int enable)
...
@@ -1137,7 +1139,7 @@ int fdelay_configure_readout(fdelay_device_t *dev, int enable)
if
(
enable
)
if
(
enable
)
{
{
fd_writel
(
FD_TSBCR_PURGE
|
FD_TSBCR_RST_SEQ
,
FD_REG_TSBCR
);
fd_writel
(
FD_TSBCR_PURGE
|
FD_TSBCR_RST_SEQ
,
FD_REG_TSBCR
);
fd_writel
(
FD_TSBCR_CHAN_MASK_W
(
1
)
|
FD_TSBCR_ENABLE
,
FD_REG_TSBCR
);
fd_writel
(
(
hw
->
raw_mode
?
FD_TSBCR_RAW
:
0
)
|
FD_TSBCR_CHAN_MASK_W
(
1
)
|
FD_TSBCR_ENABLE
,
FD_REG_TSBCR
);
}
else
}
else
fd_writel
(
FD_TSBCR_PURGE
|
FD_TSBCR_RST_SEQ
,
FD_REG_TSBCR
);
fd_writel
(
FD_TSBCR_PURGE
|
FD_TSBCR_RST_SEQ
,
FD_REG_TSBCR
);
...
@@ -1162,6 +1164,29 @@ fdelay_time_t ts_normalize(fdelay_time_t denorm)
...
@@ -1162,6 +1164,29 @@ fdelay_time_t ts_normalize(fdelay_time_t denorm)
return
denorm
;
return
denorm
;
}
}
/* as in VHDL */
void
ts_postprocess
(
fdelay_device_t
*
dev
,
fdelay_time_t
*
t
)
{
fd_decl_private
(
dev
)
int32_t
post_frac_start_adj
=
t
->
raw
.
frac
-
3
*
hw
->
calib
.
acam_start_offset
;
t
->
utc
=
t
->
raw
.
utc
;
if
(
t
->
raw
.
start_offset
<=
FD_ATMCR_C_THR_R
(
hw
->
calib
.
atmcr_val
)
&&
(
post_frac_start_adj
>
FD_ATMCR_F_THR_R
(
hw
->
calib
.
atmcr_val
)))
t
->
coarse
=
(
t
->
raw
.
coarse
-
1
)
*
16
;
else
t
->
coarse
=
(
t
->
raw
.
coarse
)
*
16
;
int64_t
post_frac_multiplied
=
post_frac_start_adj
*
(
int64_t
)
hw
->
calib
.
adsfr_val
;
t
->
coarse
+=
t
->
raw
.
subcycle_offset
+
(
post_frac_multiplied
>>
24
);
t
->
frac
=
(
post_frac_multiplied
>>
12
)
&
0xfff
;
}
/* Reads up to (how_many) timestamps from the FD ring buffer and stores them in (timestamps).
/* Reads up to (how_many) timestamps from the FD ring buffer and stores them in (timestamps).
Returns the number of read timestamps. */
Returns the number of read timestamps. */
int
fdelay_read
(
fdelay_device_t
*
dev
,
fdelay_time_t
*
timestamps
,
int
how_many
)
int
fdelay_read
(
fdelay_device_t
*
dev
,
fdelay_time_t
*
timestamps
,
int
how_many
)
...
@@ -1177,13 +1202,39 @@ int fdelay_read(fdelay_device_t *dev, fdelay_time_t *timestamps, int how_many)
...
@@ -1177,13 +1202,39 @@ int fdelay_read(fdelay_device_t *dev, fdelay_time_t *timestamps, int how_many)
uint32_t
seq_frac
;
uint32_t
seq_frac
;
if
(
!
how_many
)
break
;
if
(
!
how_many
)
break
;
if
(
hw
->
raw_mode
)
{
uint32_t
cyc
,
dbg
;
ts
.
raw
.
utc
=
((
int64_t
)
(
fd_readl
(
FD_REG_TSBR_SECH
)
&
0xff
)
<<
32
)
|
fd_readl
(
FD_REG_TSBR_SECL
);
cyc
=
fd_readl
(
FD_REG_TSBR_CYCLES
)
&
0xfffffff
;
ts
.
raw
.
coarse
=
cyc
>>
4
;
ts
.
raw
.
start_offset
=
cyc
&
0xf
;
dbg
=
fd_readl
(
FD_REG_TSBR_DEBUG
);
seq_frac
=
fd_readl
(
FD_REG_TSBR_FID
);
ts
.
raw
.
frac
=
FD_TSBR_FID_FINE_R
(
seq_frac
);
ts
.
raw
.
frac
|=
(
dbg
&
0x7ff
)
<<
12
;
ts
.
raw
.
subcycle_offset
=
(
dbg
>>
11
)
&
0x1f
;
// tag_dbg_raw_o(23 downto 16) <= raw_coarse_shifted_i(7 downto 0);
// tag_dbg_raw_o(31 downto 24) <= raw_utc_shifted_i(7 downto 0);
ts
.
seq_id
=
FD_TSBR_FID_SEQID_R
(
seq_frac
);
ts_postprocess
(
dev
,
&
ts
);
}
else
{
ts
.
utc
=
((
int64_t
)
(
fd_readl
(
FD_REG_TSBR_SECH
)
&
0xff
)
<<
32
)
|
fd_readl
(
FD_REG_TSBR_SECL
);
ts
.
utc
=
((
int64_t
)
(
fd_readl
(
FD_REG_TSBR_SECH
)
&
0xff
)
<<
32
)
|
fd_readl
(
FD_REG_TSBR_SECL
);
ts
.
coarse
=
fd_readl
(
FD_REG_TSBR_CYCLES
)
&
0xfffffff
;
ts
.
coarse
=
fd_readl
(
FD_REG_TSBR_CYCLES
)
&
0xfffffff
;
// dbg("Coarse %d\n", ts.coarse);
// dbg("Coarse %d\n", ts.coarse);
seq_frac
=
fd_readl
(
FD_REG_TSBR_FID
);
seq_frac
=
fd_readl
(
FD_REG_TSBR_FID
);
ts
.
frac
=
FD_TSBR_FID_FINE_R
(
seq_frac
);
ts
.
frac
=
FD_TSBR_FID_FINE_R
(
seq_frac
);
ts
.
seq_id
=
FD_TSBR_FID_SEQID_R
(
seq_frac
);
ts
.
seq_id
=
FD_TSBR_FID_SEQID_R
(
seq_frac
);
// ts.channel = FD_TSBR_FID_CHANNEL_R(seq_frac);
// ts.channel = FD_TSBR_FID_CHANNEL_R(seq_frac);
}
*
timestamps
++
=
ts_add_ps
(
ts_normalize
(
ts
),
hw
->
input_user_offset
);
*
timestamps
++
=
ts_add_ps
(
ts_normalize
(
ts
),
hw
->
input_user_offset
);
...
...
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