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
31c00d49
Commit
31c00d49
authored
Sep 12, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: deprecate set|get_termination
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
ebc3e68c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
24 deletions
+75
-24
fmctdc-lib.c
lib/fmctdc-lib.c
+33
-9
fmctdc-lib.h
lib/fmctdc-lib.h
+11
-3
fmc-tdc-term.c
tools/fmc-tdc-term.c
+20
-5
fmctdc-ut.c
unittest/fmctdc-ut.c
+11
-7
No files found.
lib/fmctdc-lib.c
View file @
31c00d49
...
...
@@ -311,11 +311,10 @@ int fmctdc_temperature_get(struct fmctdc_board *userb, float *temperature)
* @param[in] userb TDC board instance token
* @param[in] channel to use
* @param[in] on status of the termination to set
* @return 0 on success, otherwise a negative errno code is set
* appropriately
* @return 0 on success, otherwise -1 and errno is set appropriately
*/
int
fmctdc_
set_termination
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
int
on
)
int
fmctdc_
termination_set
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
unsigned
int
enable
)
{
__define_board
(
b
,
userb
);
uint32_t
val
;
...
...
@@ -328,7 +327,7 @@ int fmctdc_set_termination(struct fmctdc_board *userb, unsigned int channel,
snprintf
(
attr
,
sizeof
(
attr
),
"ft-ch%d/termination"
,
channel
+
1
);
val
=
on
?
1
:
0
;
val
=
enable
?
1
:
0
;
return
fmctdc_sysfs_set
(
b
,
attr
,
&
val
);
}
...
...
@@ -338,10 +337,11 @@ int fmctdc_set_termination(struct fmctdc_board *userb, unsigned int channel,
* is high-impedance and positive if it is 50 Ohm-terminated.
* @param[in] userb TDC board instance token
* @param[in] channel to use
* @
return termination status, otherwise a negative errno code is set
*
appropriately
* @
param[out] enable termination status
*
@return 0 on success, otherwise -1 and errno is appropriately set
*/
int
fmctdc_get_termination
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
)
int
fmctdc_termination_get
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
unsigned
int
*
enable
)
{
__define_board
(
b
,
userb
);
uint32_t
val
;
...
...
@@ -358,7 +358,8 @@ int fmctdc_get_termination(struct fmctdc_board *userb, unsigned int channel)
ret
=
fmctdc_sysfs_get
(
b
,
attr
,
&
val
);
if
(
ret
)
return
ret
;
return
val
;
*
enable
=
val
;
return
0
;
}
...
...
@@ -1222,3 +1223,26 @@ int fmctdc_set_offset_user(struct fmctdc_board *userb,
int
fmctdc_get_offset_user
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
int32_t
*
offset
)
__attribute__
((
alias
(
"fmctdc_offset_get"
)));
int
fmctdc_set_termination
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
,
int
enable
)
__attribute__
((
alias
(
"fmctdc_termination_set"
)));
/**
* The function returns current temrmination status: 0 if the given channel
* is high-impedance and positive if it is 50 Ohm-terminated.
* @param[in] userb TDC board instance token
* @param[in] channel to use
* @return termination status, otherwise a negative errno code is set
* appropriately
*/
int
fmctdc_get_termination
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
)
{
int
ret
;
unsigned
int
enable
;
ret
=
fmctdc_termination_get
(
b
,
channel
,
&
enable
);
if
(
ret
<
0
)
return
ret
;
return
enable
;
}
lib/fmctdc-lib.h
View file @
31c00d49
...
...
@@ -142,6 +142,12 @@ extern int fmctdc_time_set_host(struct fmctdc_board *userb);
extern
int
fmctdc_wr_status_set
(
struct
fmctdc_board
*
userb
,
int
on
);
extern
int
fmctdc_wr_status_get
(
struct
fmctdc_board
*
userb
,
enum
fmctdc_wr_status
*
status
);
extern
int
fmctdc_termination_set
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
,
unsigned
int
enable
);
extern
int
fmctdc_termination_get
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
,
unsigned
int
*
enable
);
/* Acquire Time-Stamps */
extern
int
fmctdc_fread
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
,
struct
fmctdc_time
*
t
,
int
n
);
...
...
@@ -161,9 +167,6 @@ extern int fmctdc_channel_status_set(struct fmctdc_board *userb,
extern
int
fmctdc_channel_status_get
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
);
extern
int
fmctdc_set_termination
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
,
int
enable
);
extern
int
fmctdc_get_termination
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
);
extern
int
fmctdc_get_buffer_mode
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
);
extern
int
fmctdc_set_buffer_mode
(
struct
fmctdc_board
*
userb
,
...
...
@@ -200,6 +203,11 @@ extern int fmctdc_set_offset_user(struct fmctdc_board *userb,
extern
int
fmctdc_get_offset_user
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
int32_t
*
offset
)
__attribute__
((
deprecated
));
extern
int
fmctdc_set_termination
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
,
int
enable
)
__attribute__
((
deprecated
));
extern
int
fmctdc_get_termination
(
struct
fmctdc_board
*
b
,
unsigned
int
channel
)
__attribute__
((
deprecated
));
/* other */
extern
const
char
*
const
libfmctdc_version_s
;
...
...
tools/fmc-tdc-term.c
View file @
31c00d49
...
...
@@ -11,6 +11,23 @@
char
git_version
[]
=
"git version: "
GIT_VERSION
;
void
fmctdc_term_print
(
struct
fmctdc_board
*
brd
,
unsigned
int
channel
)
{
int
err
;
unsigned
int
enable
;
err
=
fmctdc_termination_get
(
brd
,
channel
,
&
enable
);
if
(
err
<
0
)
{
fprintf
(
stderr
,
"channel %d: cannot read termination status
\n
"
,
channel
);
return
;
}
printf
(
"channel %d: 50 Ohm termination is %s
\n
"
,
channel
,
enable
?
"on"
:
"off"
);
}
int
main
(
int
argc
,
char
**
argv
)
{
init
(
argc
,
argv
);
...
...
@@ -26,8 +43,7 @@ int main(int argc, char **argv)
if
(
argc
==
2
)
{
int
i
;
for
(
i
=
FMCTDC_CH_1
;
i
<=
FMCTDC_CH_LAST
;
i
++
)
printf
(
"channel %d: 50 Ohm termination is %s
\n
"
,
i
,
fmctdc_get_termination
(
brd
,
i
)
?
"on"
:
"off"
);
fmctdc_term_print
(
brd
,
i
);
return
0
;
}
...
...
@@ -49,15 +65,14 @@ int main(int argc, char **argv)
return
-
1
;
}
if
(
fmctdc_
set_termination
(
brd
,
channel
,
term_on
)
<
0
)
{
if
(
fmctdc_
termination_set
(
brd
,
channel
,
term_on
)
<
0
)
{
fprintf
(
stderr
,
"%s: error setting termination: %s
\n
"
,
argv
[
0
],
strerror
(
errno
));
return
-
1
;
}
}
printf
(
"channel %d: 50 Ohm termination is %s
\n
"
,
channel
,
fmctdc_get_termination
(
brd
,
channel
)
?
"on"
:
"off"
);
fmctdc_term_print
(
brd
,
channel
);
return
0
;
}
unittest/fmctdc-ut.c
View file @
31c00d49
...
...
@@ -118,23 +118,27 @@ static void fmctdc_param_test3(struct m_test *m_test)
{
struct
fmctdc_test_desc
*
d
=
m_test
->
suite
->
private
;
struct
fmctdc_board
*
tdc
=
d
->
tdc
;
int
i
,
err
,
ret
;
int
i
,
err
;
unsigned
int
ret
;
for
(
i
=
0
;
i
<
FMCTDC_NUM_CHANNELS
;
++
i
)
{
/* disable */
err
=
fmctdc_set_termination
(
tdc
,
i
,
0
);
err
=
fmctdc_termination_set
(
tdc
,
i
,
0
);
m_assert_int_eq
(
0
,
err
);
err
=
fmctdc_termination_get
(
tdc
,
i
,
&
ret
);
m_assert_int_eq
(
0
,
err
);
ret
=
fmctdc_get_termination
(
tdc
,
i
);
m_assert_int_eq
(
0
,
ret
);
/* enable */
err
=
fmctdc_set_termination
(
tdc
,
i
,
1
);
err
=
fmctdc_termination_set
(
tdc
,
i
,
1
);
m_assert_int_eq
(
0
,
err
);
err
=
fmctdc_termination_get
(
tdc
,
i
,
&
ret
);
m_assert_int_eq
(
0
,
err
);
ret
=
fmctdc_get_termination
(
tdc
,
i
);
m_assert_int_eq
(
1
,
ret
);
/* disable */
err
=
fmctdc_set_termination
(
tdc
,
i
,
0
);
err
=
fmctdc_termination_set
(
tdc
,
i
,
0
);
m_assert_int_eq
(
0
,
err
);
err
=
fmctdc_termination_get
(
tdc
,
i
,
&
ret
);
m_assert_int_eq
(
0
,
err
);
ret
=
fmctdc_get_termination
(
tdc
,
i
);
m_assert_int_eq
(
0
,
ret
);
}
}
...
...
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