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
93f71397
Commit
93f71397
authored
Sep 14, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: add function to normalize timestamps
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
3c0d2649
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
fmctdc-lib-math.c
lib/fmctdc-lib-math.c
+24
-4
fmctdc-lib.h
lib/fmctdc-lib.h
+1
-0
No files found.
lib/fmctdc-lib-math.c
View file @
93f71397
...
...
@@ -44,11 +44,31 @@ uint64_t fmctdc_ts_ps(struct fmctdc_time *a)
return
ps
;
}
/**
* It normalizes the timestamp
* @param[in,out] a timestamp
*/
void
fmctdc_ts_norm
(
struct
fmctdc_time
*
a
)
{
uint64_t
tmp
;
if
(
a
->
frac
>=
4096
)
{
tmp
=
a
->
frac
/
4096UL
;
a
->
coarse
+=
tmp
;
a
->
frac
-=
tmp
*
4096UL
;
}
if
(
a
->
coarse
>=
125000000
)
{
tmp
=
a
->
coarse
/
125000000UL
;
a
->
seconds
+=
tmp
;
a
->
coarse
-=
tmp
*
125000000UL
;
}
}
/**
* It perform the subtraction: a = a - b
* @param[in] a timestamp
* @param[in] b timestamp
* @param[in] a
normalized
timestamp
* @param[in] b
normalized
timestamp
*/
void
fmctdc_ts_sub
(
struct
fmctdc_time
*
a
,
struct
fmctdc_time
*
b
)
{
...
...
@@ -76,8 +96,8 @@ void fmctdc_ts_sub(struct fmctdc_time *a, struct fmctdc_time *b)
/**
* It perform an addiction: a = a + b
* @param[in] a timestamp
* @param[in] b timestamp
* @param[in] a
normalized
timestamp
* @param[in] b
normalized
timestamp
*/
void
fmctdc_ts_add
(
struct
fmctdc_time
*
a
,
struct
fmctdc_time
*
b
)
{
...
...
lib/fmctdc-lib.h
View file @
93f71397
...
...
@@ -226,6 +226,7 @@ extern int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel);
extern
uint64_t
fmctdc_ts_approx_ns
(
struct
fmctdc_time
*
a
);
extern
uint64_t
fmctdc_ts_ps
(
struct
fmctdc_time
*
a
);
extern
void
fmctdc_ts_norm
(
struct
fmctdc_time
*
a
);
extern
void
fmctdc_ts_sub
(
struct
fmctdc_time
*
a
,
struct
fmctdc_time
*
b
);
extern
void
ft_ts_add
(
struct
fmctdc_time
*
a
,
struct
fmctdc_time
*
b
);
extern
int
_fmctdc_tscmp
(
struct
fmctdc_time
*
a
,
struct
fmctdc_time
*
b
);
...
...
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