Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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 TDC 1ns 5cha - Software
Commits
bae3761b
Commit
bae3761b
authored
Mar 16, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: getter and setter for user-offset
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
0a96741d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
+59
-0
fmctdc-lib.c
lib/fmctdc-lib.c
+55
-0
fmctdc-lib.h
lib/fmctdc-lib.h
+4
-0
No files found.
lib/fmctdc-lib.c
View file @
bae3761b
...
@@ -918,3 +918,58 @@ int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel)
...
@@ -918,3 +918,58 @@ int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel)
/* Re-enable if it was enable */
/* Re-enable if it was enable */
return
fmctdc_channel_status_set
(
userb
,
channel
,
en
);
return
fmctdc_channel_status_set
(
userb
,
channel
,
en
);
}
}
/**
* It sets the user offset to be applied on incoming timestamps. All the
* timestamps read from the driver (this means also from this library) will
* be already corrected using this offset.
* @param[in] userb TDC board instance token
* @param[in] channel target channel [0, 4]
* @param[in] offset the number of pico-seconds to be added
* @return 0 on success, otherwise -1 and errno is set appropriately
*/
int
fmctdc_set_offset_user
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
int32_t
offset
)
{
__define_board
(
b
,
userb
);
uint32_t
val
=
(
uint32_t
)
offset
;
char
attr
[
64
];
if
(
channel
>=
FMCTDC_NUM_CHANNELS
)
{
errno
=
EINVAL
;
return
-
1
;
}
snprintf
(
attr
,
sizeof
(
attr
),
"ft-ch%d/user-offset"
,
channel
+
1
);
return
fmctdc_sysfs_set
(
b
,
attr
,
&
val
);
}
/**
* It get the current user offset applied to the incoming timestamps
* @param[in] userb TDC board instance token
* @param[in] channel target channel [0, 4]
* @param[out] offset the number of pico-seconds to be added
* @return 0 on success, otherwise -1 and errno is set appropriately
*/
int
fmctdc_get_offset_user
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
int32_t
*
offset
)
{
struct
__fmctdc_board
*
b
=
(
void
*
)(
userb
);
uint32_t
val
;
char
path
[
64
];
int
err
;
if
(
channel
>=
FMCTDC_NUM_CHANNELS
)
{
errno
=
EINVAL
;
return
-
1
;
}
snprintf
(
path
,
sizeof
(
path
),
"ft-ch%d/user-offset"
,
channel
+
1
);
err
=
fmctdc_sysfs_get
(
b
,
path
,
&
val
);
if
(
err
)
return
-
1
;
*
offset
=
(
int32_t
)
val
;
return
0
;
}
lib/fmctdc-lib.h
View file @
bae3761b
...
@@ -136,6 +136,10 @@ extern int fmctdc_reference_set(struct fmctdc_board *userb,
...
@@ -136,6 +136,10 @@ extern int fmctdc_reference_set(struct fmctdc_board *userb,
extern
int
fmctdc_reference_get
(
struct
fmctdc_board
*
userb
,
extern
int
fmctdc_reference_get
(
struct
fmctdc_board
*
userb
,
unsigned
int
ch_target
);
unsigned
int
ch_target
);
extern
int
fmctdc_reference_clear
(
struct
fmctdc_board
*
userb
,
int
ch_target
);
extern
int
fmctdc_reference_clear
(
struct
fmctdc_board
*
userb
,
int
ch_target
);
extern
int
fmctdc_set_offset_user
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
int32_t
offset
);
extern
int
fmctdc_get_offset_user
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
int32_t
*
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