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
aa3a6e15
Commit
aa3a6e15
authored
Apr 23, 2015
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: enable standard zio channel
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
037b748b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
25 deletions
+87
-25
fmctdc-lib.c
lib/fmctdc-lib.c
+54
-16
fmctdc-lib.h
lib/fmctdc-lib.h
+14
-2
Makefile
tools/Makefile
+0
-1
fmc-tdc-tstamp.c
tools/fmc-tdc-tstamp.c
+19
-6
No files found.
lib/fmctdc-lib.c
View file @
aa3a6e15
...
...
@@ -334,18 +334,27 @@ int fmctdc_get_termination(struct fmctdc_board *userb, unsigned int channel)
/**
* It gets the acquisition status of a TDC
device
* It gets the acquisition status of a TDC
channel
* @param[in] userb TDC board instance token
* @param[in] channel channel to which we want read the status
* @return the acquisition status (0 disabled, 1 enabled), otherwise -1 and
* errno is set appropriately
*/
int
fmctdc_
get_acquisition
(
struct
fmctdc_board
*
userb
)
int
fmctdc_
channel_status_get
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
)
{
__define_board
(
b
,
userb
);
uint32_t
val
;
char
attr
[
64
];
int
ret
;
ret
=
fmctdc_sysfs_get
(
b
,
"enable_inputs"
,
&
val
);
if
(
channel
>=
FMCTDC_NUM_CHANNELS
)
{
errno
=
EINVAL
;
return
-
1
;
}
snprintf
(
attr
,
sizeof
(
attr
),
"ft-ch%d/enable"
,
channel
+
1
);
ret
=
fmctdc_sysfs_get
(
b
,
attr
,
&
val
);
if
(
ret
)
return
ret
;
return
val
;
...
...
@@ -353,22 +362,51 @@ int fmctdc_get_acquisition(struct fmctdc_board *userb)
/**
* The function globally enables/disables timestamp acquisition for the given
* mezzanine. Due to limitations in the gateware, it is not possible to
* enable/disable channels individually. Certain operations such as setting
* board's time require acquisition to be disabled. Disabling acqusition also
* clears all timestamp buffers and resets sequence IDs of the timestamps.
* The function enables/disables timestamp acquisition for the given channel.
* @param[in] userb TDC board instance token
* @param[in] on acquisition status to set (0 disable, 1 enable)
* @param[in] channel channel to which we want change status
* @param[in] status enable status to set
* @return 0 on success, otherwise -1 and errno is set appropriately
*/
int
fmctdc_set_acquisition
(
struct
fmctdc_board
*
userb
,
int
on
)
int
fmctdc_channel_status_set
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
enum
fmctdc_channel_status
status
)
{
__define_board
(
b
,
userb
);
uint32_t
val
;
uint32_t
val
=
status
;
char
attr
[
64
];
val
=
on
?
1
:
0
;
return
fmctdc_sysfs_set
(
b
,
"enable_inputs"
,
&
val
);
if
(
channel
>=
FMCTDC_NUM_CHANNELS
)
{
errno
=
EINVAL
;
return
-
1
;
}
snprintf
(
attr
,
sizeof
(
attr
),
"ft-ch%d/enable"
,
channel
+
1
);
return
fmctdc_sysfs_set
(
b
,
attr
,
&
val
);
}
/**
* It enables a given channel.
* NOTE: it is just a wrapper of fmctdc_channel_status_set()
* @param[in] userb TDC board instance token
* @param[in] channel channel to which we want change status
* @return 0 on success, otherwise -1 and errno is set appropriately
*/
int
fmctdc_channel_enable
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
)
{
return
fmctdc_channel_status_set
(
userb
,
channel
,
FMCTDC_STATUS_ENABLE
);
}
/**
* It disable a given channel.
* NOTE: it is just a wrapper of fmctdc_channel_status_set()
* @param[in] userb TDC board instance token
* @param[in] channel channel to which we want change status
* @return 0 on success, otherwise -1 and errno is set appropriately
*/
int
fmctdc_channel_disable
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
)
{
return
fmctdc_channel_status_set
(
userb
,
channel
,
FMCTDC_STATUS_DISABLE
);
}
/**
...
...
@@ -813,12 +851,12 @@ int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel)
errno
=
EINVAL
;
return
-
1
;
}
en
=
fmctdc_
get_acquisition
(
userb
);
en
=
fmctdc_
channel_status_get
(
userb
,
channel
);
if
(
en
<
0
)
return
-
1
;
/* Disable acquisition, it will flush the hw buffer */
err
=
fmctdc_
set_acquisition
(
userb
,
0
);
err
=
fmctdc_
channel_status_set
(
userb
,
channel
,
FMCTDC_STATUS_DISABLE
);
if
(
err
)
return
err
;
...
...
@@ -830,5 +868,5 @@ int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel)
}
/* Re-enable if it was enable */
return
fmctdc_
set_acquisition
(
userb
,
en
);
return
fmctdc_
channel_status_set
(
userb
,
channel
,
en
);
}
lib/fmctdc-lib.h
View file @
aa3a6e15
...
...
@@ -30,6 +30,11 @@ enum fmctdc_buffer_mode {
FMCTDC_BUFFER_CIRC
,
};
enum
fmctdc_channel_status
{
FMCTDC_STATUS_DISABLE
=
0
,
FMCTDC_STATUS_ENABLE
,
};
/**
* Opaque data type used as token
*/
...
...
@@ -81,8 +86,15 @@ extern int fmctdc_set_time(struct fmctdc_board *b, struct fmctdc_time *t);
extern
int
fmctdc_get_time
(
struct
fmctdc_board
*
b
,
struct
fmctdc_time
*
t
);
extern
int
fmctdc_set_host_time
(
struct
fmctdc_board
*
b
);
extern
int
fmctdc_set_acquisition
(
struct
fmctdc_board
*
b
,
int
enable
);
extern
int
fmctdc_get_acquisition
(
struct
fmctdc_board
*
b
);
extern
int
fmctdc_channel_status_set
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
enum
fmctdc_channel_status
status
);
extern
int
fmctdc_channel_enable
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
);
extern
int
fmctdc_channel_disable
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
);
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
);
...
...
tools/Makefile
View file @
aa3a6e15
...
...
@@ -9,7 +9,6 @@ LIBTDC = ../lib/
TESTS
=
fmc-tdc-list
\
fmc-tdc-term
\
fmc-tdc-acquisition
\
fmc-tdc-temperature
\
fmc-tdc-time
\
fmc-tdc-tstamp
...
...
tools/fmc-tdc-tstamp.c
View file @
aa3a6e15
...
...
@@ -262,6 +262,12 @@ int main(int argc, char **argv)
"%s: chan %d: cannot set buffer lenght: %s. Use default
\n
"
,
argv
[
0
],
ch
,
fmctdc_strerror
(
errno
));
}
if
(
!
read
)
ret
=
fmctdc_channel_enable
(
brd
,
i
);
if
(
ret
)
fprintf
(
stderr
,
"%s: chan %d: cannot enable acquisition: %s.
\n
"
,
argv
[
0
],
i
,
fmctdc_strerror
(
errno
));
chan_count
++
;
optind
++
;
}
...
...
@@ -297,14 +303,18 @@ int main(int argc, char **argv)
"%s: chan %d: cannot set buffer lenght: %s. Use default
\n
"
,
argv
[
0
],
i
,
fmctdc_strerror
(
errno
));
}
if
(
!
read
)
ret
=
fmctdc_channel_enable
(
brd
,
i
);
if
(
ret
)
fprintf
(
stderr
,
"%s: chan %d: cannot enable acquisition: %s.
\n
"
,
argv
[
0
],
i
,
fmctdc_strerror
(
errno
));
}
chan_count
=
i
;
}
/* Enable acquisition */
if
(
!
read
)
fmctdc_set_acquisition
(
brd
,
1
);
/* Read Time-Stamps */
n
=
0
;
while
((
n
<
n_samples
||
n_samples
<=
0
)
&&
(
!
stop
))
{
...
...
@@ -359,10 +369,13 @@ int main(int argc, char **argv)
for
(
i
=
0
;
i
<=
FMCTDC_CH_LAST
;
i
++
)
{
if
(
channels
[
i
]
>
0
)
fmctdc_reference_clear
(
brd
,
-
1
);
if
(
!
read
)
ret
=
fmctdc_channel_disable
(
brd
,
i
);
if
(
ret
)
fprintf
(
stderr
,
"%s: chan %d: cannot disable acquisition: %s.
\n
"
,
argv
[
0
],
i
,
fmctdc_strerror
(
errno
));
}
/* Disable acquisition */
if
(
!
read
)
fmctdc_set_acquisition
(
brd
,
0
);
fmctdc_close
(
brd
);
exit
(
EXIT_SUCCESS
);
...
...
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