Commit a7dd922d authored by Federico Vaga's avatar Federico Vaga

lib: VERY UGLY COMMIT - style'n'comments mix

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 8af8b9f4
......@@ -27,7 +27,13 @@
#include "fmctdc-lib.h"
#include "fmctdc-lib-private.h"
/**
* libfmctdc version string
*/
const char * const libfmctdc_version_s = "libfmctdc version: " GIT_VERSION;
/**
* zio version string used during compilation of libfmctdc
*/
const char * const libfmctdc_zio_version_s = "libfmctdc is using zio version: " ZIO_GIT_VERSION;
#define NSAMPLE 1 /* fake number of samples for the TDC */
......@@ -81,11 +87,12 @@ void fmctdc_exit(void)
/**
* It opens one specific device. -1 arguments mean "not installed"
* It opens one specific device.
* @param[in] dev_id FMC device id. -1 to ignore it and use only the offset
* @return an instance token, otherwise NULL and errno is appripriately set.
* ENODEV if the device was not found. EINVAL there is a mismatch with
* the arguments
*
* ENODEV if the device was not found.
* EINVAL there is a mismatch with the arguments
*/
#define __FMCTDC_OPEN_PATH_MAX 128
struct fmctdc_board *fmctdc_open(int dev_id)
......@@ -195,12 +202,13 @@ err_stat_s:
/**
* It opens one specific device by logical unit number (CERN/BE-CO-like).
* @param[in] lun Logical Unit Number
* @return an instance token, otherwise NULL and errno is appripriately set
*
* The function uses a symbolic link in /dev that points to the standard device.
* The link is created by the local installation procedure, and it allows to get
* the device id according to the LUN.
* Read also fmctdc_open() documentation.
* @param[in] lun Logical Unit Number
* @return an instance token, otherwise NULL and errno is appripriately set
*/
struct fmctdc_board *fmctdc_open_by_lun(int lun)
{
......@@ -680,19 +688,19 @@ int fmctdc_set_buffer_len(struct fmctdc_board *userb, unsigned int channel,
/**
* It get the file descriptor of a TDC channel. So, for example, you can
* poll(2) and select(2).
* Note that, the file descriptor is the file-descriptor of a
* ZIO control char-device.
* It get the file descriptor of a TDC channel.
* @param[in] userb TDC board instance token
* @param[in] channel channel to use
* @return a file descriptor, otherwise -1 and errno is set appropriately
*
* Note that, the file descriptor is the file-descriptor of a
* ZIO data char-device.
*/
int fmctdc_fileno_channel(struct fmctdc_board *userb, unsigned int channel)
{
__define_board(b, userb);
return b->fdc[channel];
return b->fdd[channel];
}
static void fmctdc_ts_convert(struct fmctdc_time *t, struct ft_hw_timestamp *o)
......@@ -942,12 +950,14 @@ extern int fmctdc_check_wr_mode(struct fmctdc_board *userb)
}
/**
* It removes all samples from the channel buffer. In order to doing this,
* the function temporary disable any active acquisition, only when the flush
* is completed the acquisition will be re-enabled
* It removes all samples from the channel buffer.
* @param[in] userb TDC board instance token
* @param[in] channel target channel [0, 4]
* @return 0 on success, otherwise -1 and errno is set appropriately
*
* In order to achieve this, this function temporary disables any active
* acquisition, only when the flush completes the acquisition will be
* re-enabled
*/
int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel)
{
......
......@@ -129,151 +129,95 @@ struct fmctdc_time {
};
/**
* @file fmctdc-lib.c
*/
/**
* @defgroup libutil Utilities
* Set of library utilities
* @{
*/
extern const char *fmctdc_strerror(int err);
/* Initialization */
extern int fmctdc_init(void);
extern void fmctdc_exit(void);
/**@}*/
/**
* @defgroup libboard Board Configuration
* Set of function to configure TDC board and retrieve information
* about the current status
* @{
*/
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_wr_mode(struct fmctdc_board *b, int on);
extern int fmctdc_check_wr_mode(struct fmctdc_board *b);
extern float fmctdc_read_temperature(struct fmctdc_board *b);
/**@}*/
/**
* @defgroup libchan Channel Configuration
* Set of function to configure TDC channels and retrieve information
* about the current status
* @{
*/
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);
extern int fmctdc_get_termination(struct fmctdc_board *b, unsigned int channel);
extern int fmctdc_get_buffer_type(struct fmctdc_board *userb);
extern int fmctdc_set_buffer_type(struct fmctdc_board *userb,
enum fmctdc_buffer_type type);
extern int fmctdc_get_buffer_mode(struct fmctdc_board *userb,
unsigned int channel);
extern int fmctdc_set_buffer_mode(struct fmctdc_board *userb,
unsigned int channel,
enum fmctdc_buffer_mode mode);
extern int fmctdc_get_buffer_len(struct fmctdc_board *userb,
unsigned int channel);
extern int fmctdc_set_buffer_len(struct fmctdc_board *userb,
unsigned int channel,
unsigned int length);
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);
extern int fmctdc_transfer_mode(struct fmctdc_board *userb,
enum ft_transfer_mode *mode);
/* Utilities */
extern const char *fmctdc_strerror(int err);
/* Open And Close Devices */
extern struct fmctdc_board *fmctdc_open(int dev_id);
extern struct fmctdc_board *fmctdc_open_by_lun(int lun);
extern int fmctdc_fileno_channel(struct fmctdc_board *b, unsigned int channel);
extern int fmctdc_close(struct fmctdc_board *);
/* Buffer Management */
extern int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel);
/* Configuration */
extern int fmctdc_coalescing_timeout_set(struct fmctdc_board *userb,
unsigned int channel,
unsigned int timeout_ms);
extern int fmctdc_coalescing_timeout_get(struct fmctdc_board *userb,
unsigned int channel,
unsigned int *timeout_ms);
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_ts_mode_set(struct fmctdc_board *userb,
unsigned int channel,
enum fmctdc_ts_mode mode);
extern int fmctdc_ts_mode_get(struct fmctdc_board *userb,
unsigned int channel,
enum fmctdc_ts_mode *mode);
/**@}*/
#include "fmctdc-lib-private.h"
/**
* @defgroup libacq Time-stamps Acquisition
* Set of functions to read time-stamps from the board
* @{
*/
extern struct fmctdc_board *fmctdc_open(int dev_id);
extern struct fmctdc_board *fmctdc_open_by_lun(int lun);
extern int fmctdc_close(struct fmctdc_board *);
/* Acquire Time-Stamps */
extern int fmctdc_fread(struct fmctdc_board *b, unsigned int channel,
struct fmctdc_time *t, int n);
extern int fmctdc_fileno_channel(struct fmctdc_board *b, unsigned int channel);
extern int fmctdc_read(struct fmctdc_board *b, unsigned int channel,
struct fmctdc_time *t, int n, int flags);
extern int fmctdc_readhw(struct fmctdc_board *b, unsigned int channel,
struct ft_hw_timestamp *t, int n, int flags);
extern int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel);
/**@}*/
/**
* @defgroup libstats Statistics
* Set of functions to get statistics
* @{
*/
/* Statistics */
extern int fmctdc_stats_recv_get(struct fmctdc_board *userb,
unsigned int channel,
uint32_t *val);
extern int fmctdc_stats_trans_get(struct fmctdc_board *userb,
unsigned int channel,
uint32_t *val);
/**@}*/
/**
*@file fmctdc-lib-math.c
*/
/**
* @defgroup libmath Time-Stamp Math
* Set of mathematical functions on time-stamps
* @{
*/
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);
/* Mathematical Operations */
extern int fmctdc_ts_sub(struct fmctdc_time *r,
const struct fmctdc_time *a,
const struct fmctdc_time *b);
extern void fmctdc_ts_add(struct fmctdc_time *r,
const struct fmctdc_time *a,
const struct fmctdc_time *b);
extern int _fmctdc_tscmp(struct fmctdc_time *a, struct fmctdc_time *b);
/**@}*/
extern void fmctdc_ts_norm(struct fmctdc_time *a);
/* Conversions */
extern uint64_t fmctdc_ts_approx_ns(struct fmctdc_time *a);
extern uint64_t fmctdc_ts_ps(struct fmctdc_time *a);
/* deprecated */
extern int fmctdc_channel_status_set(struct fmctdc_board *userb,
unsigned int channel,
enum fmctdc_channel_status status);
extern int fmctdc_channel_status_get(struct fmctdc_board *userb,
unsigned int channel);
/**
* libfmctdc version string
*/
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_type(struct fmctdc_board *userb);
extern int fmctdc_set_buffer_type(struct fmctdc_board *userb,
enum fmctdc_buffer_type type);
extern int fmctdc_get_buffer_mode(struct fmctdc_board *userb,
unsigned int channel);
extern int fmctdc_set_buffer_mode(struct fmctdc_board *userb,
unsigned int channel,
enum fmctdc_buffer_mode mode);
extern int fmctdc_get_buffer_len(struct fmctdc_board *userb,
unsigned int channel);
extern int fmctdc_set_buffer_len(struct fmctdc_board *userb,
unsigned int channel,
unsigned int length);
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);
extern int fmctdc_transfer_mode(struct fmctdc_board *userb,
enum ft_transfer_mode *mode);
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_wr_mode(struct fmctdc_board *b, int on);
extern int fmctdc_check_wr_mode(struct fmctdc_board *b);
extern float fmctdc_read_temperature(struct fmctdc_board *b);
/* other */
extern const char * const libfmctdc_version_s;
/**
* zio version string used during compilation of libfmctdc
*/
extern const char * const libfmctdc_zio_version_s;
#ifdef __cplusplus
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment