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
754b2473
Commit
754b2473
authored
May 16, 2012
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/lib: normalize negative timestamps, SPI idle fix
parent
605c84cc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletion
+23
-1
fdelay_private.h
software/include/fdelay_private.h
+1
-0
fdelay_lib.c
software/lib/fdelay_lib.c
+22
-1
No files found.
software/include/fdelay_private.h
View file @
754b2473
...
...
@@ -20,6 +20,7 @@
#define CS_DAC 0
/* AD9516 PLL */
#define CS_PLL 1
/* AD9516 PLL */
#define CS_GPIO 2
/* MCP23S17 GPIO */
#define CS_NONE 3
/* MCP23S17 GPIO expander pin locations: bit 8 = select bank 2, bits 7..0 = mask of the pin in the selected bank */
#define SGPIO_TERM_EN (1<<0)
/* Input termination enable (1 = on) */
...
...
software/lib/fdelay_lib.c
View file @
754b2473
...
...
@@ -273,6 +273,7 @@ MCP23S17 SPI I/O Port Driver
static
inline
void
mcp_write
(
fdelay_device_t
*
dev
,
uint8_t
reg
,
uint8_t
val
)
{
oc_spi_txrx
(
dev
,
CS_GPIO
,
24
,
0x4e0000
|
(((
uint32_t
)
reg
)
<<
8
)
|
(
uint32_t
)
val
,
NULL
);
oc_spi_txrx
(
dev
,
CS_NONE
,
24
,
0
,
NULL
);
}
/* Reads MCP23S17 register */
...
...
@@ -280,6 +281,8 @@ static uint8_t mcp_read(fdelay_device_t *dev, uint8_t reg)
{
uint32_t
rval
;
oc_spi_txrx
(
dev
,
CS_GPIO
,
24
,
0x4f0000
|
(((
uint32_t
)
reg
)
<<
8
),
&
rval
);
oc_spi_txrx
(
dev
,
CS_NONE
,
24
,
0
,
NULL
);
return
rval
&
0xff
;
}
...
...
@@ -1141,6 +1144,24 @@ int fdelay_configure_readout(fdelay_device_t *dev, int enable)
return
0
;
}
fdelay_time_t
ts_normalize
(
fdelay_time_t
denorm
)
{
if
(
denorm
.
coarse
&
(
1
<<
27
))
{
denorm
.
coarse
+=
125000000
;
denorm
.
coarse
&=
0xfffffff
;
denorm
.
utc
--
;
}
if
(
denorm
.
coarse
>=
125000000
)
{
denorm
.
coarse
-=
125000000
;
denorm
.
utc
++
;
}
return
denorm
;
}
/* Reads up to (how_many) timestamps from the FD ring buffer and stores them in (timestamps).
Returns the number of read timestamps. */
int
fdelay_read
(
fdelay_device_t
*
dev
,
fdelay_time_t
*
timestamps
,
int
how_many
)
...
...
@@ -1164,7 +1185,7 @@ int fdelay_read(fdelay_device_t *dev, fdelay_time_t *timestamps, int how_many)
ts
.
seq_id
=
FD_TSBR_FID_SEQID_R
(
seq_frac
);
// ts.channel = FD_TSBR_FID_CHANNEL_R(seq_frac);
*
timestamps
++
=
ts_add_ps
(
ts
,
hw
->
input_user_offset
);
*
timestamps
++
=
ts_add_ps
(
ts
_normalize
(
ts
)
,
hw
->
input_user_offset
);
how_many
--
;
n_read
++
;
...
...
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