Commit 623771a2 authored by Federico Vaga's avatar Federico Vaga

tools: variable, function and libraries renaming

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent dcafd17c
This diff is collapsed.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <linux/zio-user.h> #include <linux/zio-user.h>
#include <fmcadc-lib.h> #include <adc-lib.h>
#include <fmc-adc-100m14b4cha.h> #include <fmc-adc-100m14b4cha.h>
/* Subtract the `struct timespec' values X and Y, /* Subtract the `struct timespec' values X and Y,
...@@ -56,8 +56,8 @@ static void fald_help() ...@@ -56,8 +56,8 @@ static void fald_help()
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
struct fmcadc_dev *adc; struct adc_dev *adc;
struct fmcadc_conf brd_cfg; struct adc_conf brd_cfg;
struct timespec sys_start, sys_cur, adc_cur, dlt_ts, dlt_dlt_ts = {0, 0}; struct timespec sys_start, sys_cur, adc_cur, dlt_ts, dlt_dlt_ts = {0, 0};
int err, devid, interval = 360; int err, devid, interval = 360;
uint32_t adc_sec, adc_ticks; uint32_t adc_sec, adc_ticks;
...@@ -65,7 +65,7 @@ int main (int argc, char *argv[]) ...@@ -65,7 +65,7 @@ int main (int argc, char *argv[])
/* Prepare the board timing base configuration */ /* Prepare the board timing base configuration */
memset(&brd_cfg, 0, sizeof(brd_cfg)); memset(&brd_cfg, 0, sizeof(brd_cfg));
brd_cfg.type = FMCADC_CONT_TYPE_BRD; brd_cfg.type = ADC_CONT_TYPE_BRD;
while ((c = getopt(argc, argv, "i:h")) >= 0) { while ((c = getopt(argc, argv, "i:h")) >= 0) {
switch (c) { switch (c) {
...@@ -83,10 +83,10 @@ int main (int argc, char *argv[]) ...@@ -83,10 +83,10 @@ int main (int argc, char *argv[])
sscanf(argv[argc-1], "%x", &devid); sscanf(argv[argc-1], "%x", &devid);
adc = fmcadc_open("fmc-adc-100m14b4cha", devid, 0, 0, FMCADC_F_FLUSH); adc = adc_open("fmc-adc-100m14b4cha", devid, 0, 0, ADC_F_FLUSH);
if (!adc) { if (!adc) {
fprintf(stderr, "%s: cannot open device: %s", fprintf(stderr, "%s: cannot open device: %s",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
...@@ -102,12 +102,12 @@ int main (int argc, char *argv[]) ...@@ -102,12 +102,12 @@ int main (int argc, char *argv[])
/* Configure ADC internal clock */ /* Configure ADC internal clock */
adc_sec = sys_start.tv_sec; adc_sec = sys_start.tv_sec;
adc_ticks = sys_start.tv_nsec / FA100M14B4C_UTC_CLOCK_NS; adc_ticks = sys_start.tv_nsec / FA100M14B4C_UTC_CLOCK_NS;
fmcadc_set_conf(&brd_cfg, FMCADC_CONF_UTC_TIMING_BASE_T, adc_ticks); adc_set_conf(&brd_cfg, ADC_CONF_UTC_TIMING_BASE_T, adc_ticks);
fmcadc_set_conf(&brd_cfg, FMCADC_CONF_UTC_TIMING_BASE_S, adc_sec); adc_set_conf(&brd_cfg, ADC_CONF_UTC_TIMING_BASE_S, adc_sec);
err = fmcadc_apply_config(adc, 0 , &brd_cfg); err = adc_apply_config(adc, 0 , &brd_cfg);
if (err && errno != FMCADC_ENOMASK) { if (err && errno != ADC_ENOMASK) {
fprintf(stderr, "%s: cannot configure board %s\n", fprintf(stderr, "%s: cannot configure board %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
fprintf(stdout, fprintf(stdout,
...@@ -127,15 +127,15 @@ int main (int argc, char *argv[]) ...@@ -127,15 +127,15 @@ int main (int argc, char *argv[])
} }
/* Get the ADC clock */ /* Get the ADC clock */
err = fmcadc_retrieve_config(adc, &brd_cfg); err = adc_retrieve_config(adc, &brd_cfg);
if (err) { if (err) {
fprintf(stderr, "%s: cannot get trigger config: %s\n", fprintf(stderr, "%s: cannot get trigger config: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
fmcadc_get_conf(&brd_cfg, FMCADC_CONF_UTC_TIMING_BASE_S, adc_get_conf(&brd_cfg, ADC_CONF_UTC_TIMING_BASE_S,
&adc_sec); &adc_sec);
fmcadc_get_conf(&brd_cfg, FMCADC_CONF_UTC_TIMING_BASE_T, adc_get_conf(&brd_cfg, ADC_CONF_UTC_TIMING_BASE_T,
&adc_ticks); &adc_ticks);
adc_cur.tv_sec = adc_sec; adc_cur.tv_sec = adc_sec;
adc_cur.tv_nsec = adc_ticks * FA100M14B4C_UTC_CLOCK_NS; adc_cur.tv_nsec = adc_ticks * FA100M14B4C_UTC_CLOCK_NS;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <limits.h> #include <limits.h>
#include <errno.h> #include <errno.h>
#include <linux/zio-user.h> #include <linux/zio-user.h>
#include <fmcadc-lib.h> #include <adc-lib.h>
static void fald_help() static void fald_help()
{ {
...@@ -39,7 +39,7 @@ static void fald_help() ...@@ -39,7 +39,7 @@ static void fald_help()
printf(" --help|-h show this help\n\n"); printf(" --help|-h show this help\n\n");
} }
static int trgval[__FMCADC_CONF_LEN]; /* FIXME: this is not used */ static int trgval[__ADC_CONF_LEN]; /* FIXME: this is not used */
static struct option options[] = { static struct option options[] = {
{"before", required_argument, 0, 'b'}, {"before", required_argument, 0, 'b'},
...@@ -50,7 +50,7 @@ static struct option options[] = { ...@@ -50,7 +50,7 @@ static struct option options[] = {
{"threshold", required_argument, 0, 't'}, {"threshold", required_argument, 0, 't'},
{"channel", required_argument, 0, 'c'}, {"channel", required_argument, 0, 'c'},
{"timeout", required_argument, 0, 'T'}, {"timeout", required_argument, 0, 'T'},
{"negative-edge", no_argument, &trgval[FMCADC_CONF_TRG_POLARITY], 1}, {"negative-edge", no_argument, &trgval[ADC_CONF_TRG_POLARITY], 1},
/* new options, to help stress-test */ /* new options, to help stress-test */
{"binary", required_argument, 0, 'B'}, {"binary", required_argument, 0, 'B'},
...@@ -70,9 +70,9 @@ static struct option options[] = { ...@@ -70,9 +70,9 @@ static struct option options[] = {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct fmcadc_buffer *buf; struct adc_buffer *buf;
struct fmcadc_dev *adc; struct adc_dev *adc;
struct fmcadc_conf trg, acq; struct adc_conf trg, acq;
int i, c, err, opt_index, binmode = 0; int i, c, err, opt_index, binmode = 0;
int nshots = 1, presamples = 0, postsamples = 16; int nshots = 1, presamples = 0, postsamples = 16;
int timeout = -1; int timeout = -1;
...@@ -88,13 +88,13 @@ int main(int argc, char *argv[]) ...@@ -88,13 +88,13 @@ int main(int argc, char *argv[])
/* reset attributes and provide defaults */ /* reset attributes and provide defaults */
memset(&trg, 0, sizeof(trg)); memset(&trg, 0, sizeof(trg));
trg.type = FMCADC_CONF_TYPE_TRG; trg.type = ADC_CONF_TYPE_TRG;
fmcadc_set_conf(&trg, FMCADC_CONF_TRG_SOURCE, 1); /* external */ adc_set_conf(&trg, ADC_CONF_TRG_SOURCE, 1); /* external */
memset(&acq, 0, sizeof(acq)); memset(&acq, 0, sizeof(acq));
acq.type = FMCADC_CONF_TYPE_ACQ; acq.type = ADC_CONF_TYPE_ACQ;
fmcadc_set_conf(&acq, FMCADC_CONF_ACQ_POST_SAMP, postsamples); adc_set_conf(&acq, ADC_CONF_ACQ_POST_SAMP, postsamples);
fmcadc_set_conf(&acq, FMCADC_CONF_ACQ_N_SHOTS, nshots); adc_set_conf(&acq, ADC_CONF_ACQ_N_SHOTS, nshots);
/* Parse options */ /* Parse options */
while ((c = getopt_long(argc, argv, GETOPT_STRING, while ((c = getopt_long(argc, argv, GETOPT_STRING,
...@@ -102,35 +102,35 @@ int main(int argc, char *argv[]) ...@@ -102,35 +102,35 @@ int main(int argc, char *argv[])
switch (c) { switch (c) {
case 'b': case 'p': /* before */ case 'b': case 'p': /* before */
presamples = atoi(optarg); presamples = atoi(optarg);
fmcadc_set_conf(&acq, FMCADC_CONF_ACQ_PRE_SAMP, adc_set_conf(&acq, ADC_CONF_ACQ_PRE_SAMP,
presamples); presamples);
break; break;
case 'a': case 'P': /* after */ case 'a': case 'P': /* after */
postsamples = atoi(optarg); postsamples = atoi(optarg);
fmcadc_set_conf(&acq, FMCADC_CONF_ACQ_POST_SAMP, adc_set_conf(&acq, ADC_CONF_ACQ_POST_SAMP,
postsamples); postsamples);
break; break;
case 'n': case 'n':
nshots = atoi(optarg); nshots = atoi(optarg);
fmcadc_set_conf(&acq, FMCADC_CONF_ACQ_N_SHOTS, adc_set_conf(&acq, ADC_CONF_ACQ_N_SHOTS,
nshots); nshots);
break; break;
case 'd': case 'd':
fmcadc_set_conf(&trg, FMCADC_CONF_TRG_DELAY, adc_set_conf(&trg, ADC_CONF_TRG_DELAY,
atoi(optarg)); atoi(optarg));
break; break;
case 'u': case 'D': case 'u': case 'D':
fmcadc_set_conf(&acq, FMCADC_CONF_ACQ_DECIMATION, adc_set_conf(&acq, ADC_CONF_ACQ_DECIMATION,
atoi(optarg)); atoi(optarg));
break; break;
case 't': case 't':
fmcadc_set_conf(&trg, FMCADC_CONF_TRG_THRESHOLD, adc_set_conf(&trg, ADC_CONF_TRG_THRESHOLD,
atoi(optarg)); atoi(optarg));
break; break;
case 'c': case 'c':
/* set internal, and then the channel */ /* set internal, and then the channel */
fmcadc_set_conf(&trg, FMCADC_CONF_TRG_SOURCE, 0); adc_set_conf(&trg, ADC_CONF_TRG_SOURCE, 0);
fmcadc_set_conf(&trg, FMCADC_CONF_TRG_SOURCE_CHAN, adc_set_conf(&trg, ADC_CONF_TRG_SOURCE_CHAN,
atoi(optarg)); atoi(optarg));
break; break;
case 'T': case 'T':
...@@ -165,17 +165,17 @@ int main(int argc, char *argv[]) ...@@ -165,17 +165,17 @@ int main(int argc, char *argv[])
} }
/* Open the ADC */ /* Open the ADC */
adc = fmcadc_open("fmc-adc-100m14b4cha", dev_id, adc = adc_open("fmc-adc-100m14b4cha", dev_id,
nshots * (presamples + postsamples), nshots * (presamples + postsamples),
nshots, nshots,
FMCADC_F_FLUSH); ADC_F_FLUSH);
if (!adc) { if (!adc) {
fprintf(stderr, "%s: cannot open device: %s", fprintf(stderr, "%s: cannot open device: %s",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
if (strcmp(fmcadc_get_driver_type(adc), "zio")) { if (strcmp(adc_get_driver_type(adc), "zio")) {
fprintf(stderr, "%s: not a zio driver, aborting\n", argv[0]); fprintf(stderr, "%s: not a zio driver, aborting\n", argv[0]);
exit(1); exit(1);
} }
...@@ -200,35 +200,35 @@ int main(int argc, char *argv[]) ...@@ -200,35 +200,35 @@ int main(int argc, char *argv[])
} }
/* Configure trigger (pick trigger polarity from external array) */ /* Configure trigger (pick trigger polarity from external array) */
fmcadc_set_conf(&trg, FMCADC_CONF_TRG_POLARITY, adc_set_conf(&trg, ADC_CONF_TRG_POLARITY,
trgval[FMCADC_CONF_TRG_POLARITY]); trgval[ADC_CONF_TRG_POLARITY]);
err = fmcadc_apply_config(adc, 0 , &trg); err = adc_apply_config(adc, 0 , &trg);
if (err && errno != FMCADC_ENOMASK) { if (err && errno != ADC_ENOMASK) {
fprintf(stderr, "%s: cannot configure trigger: %s\n", fprintf(stderr, "%s: cannot configure trigger: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
/* Configure acquisition parameter */ /* Configure acquisition parameter */
err = fmcadc_apply_config(adc, 0 , &acq); err = adc_apply_config(adc, 0 , &acq);
if (err && errno != FMCADC_ENOMASK) { if (err && errno != ADC_ENOMASK) {
fprintf(stderr, "%s: cannot configure acquisition: %s\n", fprintf(stderr, "%s: cannot configure acquisition: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
if (timeout < 0) { if (timeout < 0) {
/* Start acquisition and wait until it completes */ /* Start acquisition and wait until it completes */
err = fmcadc_acq_start(adc, 0 , NULL); err = adc_acq_start(adc, 0 , NULL);
} else { } else {
/* Start acquisition and don't wait. We use acq_poll() later */ /* Start acquisition and don't wait. We use acq_poll() later */
struct timeval tv = {0, 0}; struct timeval tv = {0, 0};
err = fmcadc_acq_start(adc, 0 , &tv); err = adc_acq_start(adc, 0 , &tv);
} }
if (err) { if (err) {
fprintf(stderr, "%s: cannot start acquisition: %s\n", fprintf(stderr, "%s: cannot start acquisition: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
...@@ -236,7 +236,7 @@ int main(int argc, char *argv[]) ...@@ -236,7 +236,7 @@ int main(int argc, char *argv[])
if (timeout >= 0) { if (timeout >= 0) {
struct timeval tv = {timeout / 1000, timeout % 1000}; struct timeval tv = {timeout / 1000, timeout % 1000};
err = fmcadc_acq_poll(adc, 0 , &tv); err = adc_acq_poll(adc, 0 , &tv);
} }
if (err) { if (err) {
fprintf(stderr, "%s: timeout after %i ms: %s\n", argv[0], fprintf(stderr, "%s: timeout after %i ms: %s\n", argv[0],
...@@ -245,16 +245,16 @@ int main(int argc, char *argv[]) ...@@ -245,16 +245,16 @@ int main(int argc, char *argv[])
} }
/* Allocate a buffer in the default way */ /* Allocate a buffer in the default way */
buf = fmcadc_request_buffer(adc, presamples + postsamples, buf = adc_request_buffer(adc, presamples + postsamples,
NULL /* alloc */, 0); NULL /* alloc */, 0);
if (!buf) { if (!buf) {
fprintf(stderr, "Cannot allocate buffer (%s)\n", fprintf(stderr, "Cannot allocate buffer (%s)\n",
fmcadc_strerror(errno)); adc_strerror(errno));
exit(1); exit(1);
} }
/* Fill the buffer once for each shot */ /* Fill the buffer once for each shot */
for (i = 0; i < acq.value[FMCADC_CONF_ACQ_N_SHOTS]; ++i) { for (i = 0; i < acq.value[ADC_CONF_ACQ_N_SHOTS]; ++i) {
struct zio_control *ctrl; struct zio_control *ctrl;
int j, ch; int j, ch;
int16_t *data; int16_t *data;
...@@ -262,19 +262,19 @@ int main(int argc, char *argv[]) ...@@ -262,19 +262,19 @@ int main(int argc, char *argv[])
if (binmode < 0) /* no data must be acquired */ if (binmode < 0) /* no data must be acquired */
break; break;
err = fmcadc_fill_buffer(adc, buf, 0, NULL); err = adc_fill_buffer(adc, buf, 0, NULL);
if (err) { if (err) {
fprintf(stderr, "%s: shot %i/%i: cannot fill buffer:" fprintf(stderr, "%s: shot %i/%i: cannot fill buffer:"
" %s\n", argv[0], i + i, " %s\n", argv[0], i + i,
acq.value[FMCADC_CONF_ACQ_N_SHOTS], acq.value[ADC_CONF_ACQ_N_SHOTS],
fmcadc_strerror(errno)); adc_strerror(errno));
exit(1); exit(1);
} }
ctrl = buf->metadata; ctrl = buf->metadata;
data = buf->data; data = buf->data;
fprintf(stderr, "Read %d samples from shot %i/%i\n", fprintf(stderr, "Read %d samples from shot %i/%i\n",
ctrl->nsamples, ctrl->nsamples,
i + 1, acq.value[FMCADC_CONF_ACQ_N_SHOTS]); i + 1, acq.value[ADC_CONF_ACQ_N_SHOTS]);
if (binmode == 1) { /* append everything to a single file */ if (binmode == 1) { /* append everything to a single file */
if (fwrite(ctrl, sizeof(*ctrl), 1, f) != 1) if (fwrite(ctrl, sizeof(*ctrl), 1, f) != 1)
...@@ -336,7 +336,7 @@ int main(int argc, char *argv[]) ...@@ -336,7 +336,7 @@ int main(int argc, char *argv[])
if (binmode == 1) if (binmode == 1)
fclose(f); fclose(f);
fmcadc_release_buffer(adc, buf, NULL); adc_release_buffer(adc, buf, NULL);
fmcadc_close(adc); adc_close(adc);
exit(0); exit(0);
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <linux/zio-user.h> #include <linux/zio-user.h>
#include <fmcadc-lib.h> #include <adc-lib.h>
static void fald_help() static void fald_help()
{ {
...@@ -27,8 +27,8 @@ static void fald_help() ...@@ -27,8 +27,8 @@ static void fald_help()
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct fmcadc_dev *adc; struct adc_dev *adc;
struct fmcadc_conf trg, acq, brd, chn; struct adc_conf trg, acq, brd, chn;
static struct option options[] = { static struct option options[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{0, 0, 0, 0} {0, 0, 0, 0}
...@@ -65,98 +65,98 @@ int main(int argc, char *argv[]) ...@@ -65,98 +65,98 @@ int main(int argc, char *argv[])
sscanf(argv[optind], "0x%x", &dev_id); sscanf(argv[optind], "0x%x", &dev_id);
} }
printf("Open ADC fmcadc_100MS_4ch_14bit dev_id 0x%04x ...\n", dev_id); printf("Open ADC dev_id 0x%04x ...\n", dev_id);
/* Open the ADC */ /* Open the ADC */
adc = fmcadc_open("fmcadc_100MS_4ch_14bit", dev_id, adc = adc_open("adc_100MS_4ch_14bit", dev_id,
/* no buffers expexted */ 0, 0, /* no buffers expexted */ 0, 0,
/* no flush either */ 0); /* no flush either */ 0);
if (!adc) { if (!adc) {
fprintf(stderr, "%s: cannot open device: %s", fprintf(stderr, "%s: cannot open device: %s",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
printf("Get Trigger Configuration ...\n"); printf("Get Trigger Configuration ...\n");
/* Configure Trigger parameter to retrieve */ /* Configure Trigger parameter to retrieve */
trg.type = FMCADC_CONF_TYPE_TRG; trg.type = ADC_CONF_TYPE_TRG;
fmcadc_set_conf_mask(&trg, FMCADC_CONF_TRG_SOURCE); adc_set_conf_mask(&trg, ADC_CONF_TRG_SOURCE);
fmcadc_set_conf_mask(&trg, FMCADC_CONF_TRG_SOURCE_CHAN); adc_set_conf_mask(&trg, ADC_CONF_TRG_SOURCE_CHAN);
fmcadc_set_conf_mask(&trg, FMCADC_CONF_TRG_THRESHOLD); adc_set_conf_mask(&trg, ADC_CONF_TRG_THRESHOLD);
fmcadc_set_conf_mask(&trg, FMCADC_CONF_TRG_POLARITY); adc_set_conf_mask(&trg, ADC_CONF_TRG_POLARITY);
fmcadc_set_conf_mask(&trg, FMCADC_CONF_TRG_DELAY); adc_set_conf_mask(&trg, ADC_CONF_TRG_DELAY);
err = fmcadc_retrieve_config(adc, &trg); err = adc_retrieve_config(adc, &trg);
if (err) { if (err) {
fprintf(stderr, "%s: cannot get trigger config: %s\n", fprintf(stderr, "%s: cannot get trigger config: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
printf(" source: %s\n", printf(" source: %s\n",
trg.value[FMCADC_CONF_TRG_SOURCE] ? "external" : "internal"); trg.value[ADC_CONF_TRG_SOURCE] ? "external" : "internal");
printf(" channel: %d\n", trg.value[FMCADC_CONF_TRG_SOURCE_CHAN]); printf(" channel: %d\n", trg.value[ADC_CONF_TRG_SOURCE_CHAN]);
printf(" threshold: %d\n", trg.value[FMCADC_CONF_TRG_THRESHOLD]); printf(" threshold: %d\n", trg.value[ADC_CONF_TRG_THRESHOLD]);
printf(" polarity: %d\n", trg.value[FMCADC_CONF_TRG_POLARITY]); printf(" polarity: %d\n", trg.value[ADC_CONF_TRG_POLARITY]);
printf(" delay: %d\n", trg.value[FMCADC_CONF_TRG_DELAY]); printf(" delay: %d\n", trg.value[ADC_CONF_TRG_DELAY]);
printf("Get Acquisition Configuration ...\n"); printf("Get Acquisition Configuration ...\n");
/* Configure acquisition parameter */ /* Configure acquisition parameter */
acq.type = FMCADC_CONF_TYPE_ACQ; acq.type = ADC_CONF_TYPE_ACQ;
fmcadc_set_conf_mask(&acq, FMCADC_CONF_ACQ_N_SHOTS); adc_set_conf_mask(&acq, ADC_CONF_ACQ_N_SHOTS);
fmcadc_set_conf_mask(&acq, FMCADC_CONF_ACQ_POST_SAMP); adc_set_conf_mask(&acq, ADC_CONF_ACQ_POST_SAMP);
fmcadc_set_conf_mask(&acq, FMCADC_CONF_ACQ_PRE_SAMP); adc_set_conf_mask(&acq, ADC_CONF_ACQ_PRE_SAMP);
fmcadc_set_conf_mask(&acq, FMCADC_CONF_ACQ_DECIMATION); adc_set_conf_mask(&acq, ADC_CONF_ACQ_DECIMATION);
fmcadc_set_conf_mask(&acq, FMCADC_CONF_ACQ_FREQ_HZ); adc_set_conf_mask(&acq, ADC_CONF_ACQ_FREQ_HZ);
fmcadc_set_conf_mask(&acq, FMCADC_CONF_ACQ_N_BITS); adc_set_conf_mask(&acq, ADC_CONF_ACQ_N_BITS);
err = fmcadc_retrieve_config(adc, &acq); err = adc_retrieve_config(adc, &acq);
if (err) { if (err) {
fprintf(stderr, "%s: cannot get acquisition config: %s\n", fprintf(stderr, "%s: cannot get acquisition config: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
printf(" n-shots: %d\n", acq.value[FMCADC_CONF_ACQ_N_SHOTS]); printf(" n-shots: %d\n", acq.value[ADC_CONF_ACQ_N_SHOTS]);
printf(" post-sample: %d\n", acq.value[FMCADC_CONF_ACQ_POST_SAMP]); printf(" post-sample: %d\n", acq.value[ADC_CONF_ACQ_POST_SAMP]);
printf(" pre-sample: %d\n", acq.value[FMCADC_CONF_ACQ_PRE_SAMP]); printf(" pre-sample: %d\n", acq.value[ADC_CONF_ACQ_PRE_SAMP]);
printf(" decimation: %d\n", acq.value[FMCADC_CONF_ACQ_DECIMATION]); printf(" decimation: %d\n", acq.value[ADC_CONF_ACQ_DECIMATION]);
printf(" frequency: %dHz\n", acq.value[FMCADC_CONF_ACQ_FREQ_HZ]); printf(" frequency: %dHz\n", acq.value[ADC_CONF_ACQ_FREQ_HZ]);
printf(" n-bits: %d\n", acq.value[FMCADC_CONF_ACQ_N_BITS]); printf(" n-bits: %d\n", acq.value[ADC_CONF_ACQ_N_BITS]);
printf("Get Board Configuration ...\n"); printf("Get Board Configuration ...\n");
/* Configure acquisition parameter */ /* Configure acquisition parameter */
brd.type = FMCADC_CONT_TYPE_BRD; brd.type = ADC_CONT_TYPE_BRD;
fmcadc_set_conf_mask(&brd, FMCADC_CONF_BRD_STATE_MACHINE_STATUS); adc_set_conf_mask(&brd, ADC_CONF_BRD_STATE_MACHINE_STATUS);
fmcadc_set_conf_mask(&brd, FMCADC_CONF_BRD_N_CHAN); adc_set_conf_mask(&brd, ADC_CONF_BRD_N_CHAN);
err = fmcadc_retrieve_config(adc, &brd); err = adc_retrieve_config(adc, &brd);
if (err) { if (err) {
fprintf(stderr, "%s: cannot get board config: %s\n", fprintf(stderr, "%s: cannot get board config: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
printf(" n-chan: %d\n", brd.value[FMCADC_CONF_BRD_N_CHAN]); printf(" n-chan: %d\n", brd.value[ADC_CONF_BRD_N_CHAN]);
printf(" State Machine: %d\n", printf(" State Machine: %d\n",
brd.value[FMCADC_CONF_BRD_STATE_MACHINE_STATUS]); brd.value[ADC_CONF_BRD_STATE_MACHINE_STATUS]);
for (i = 0; i < brd.value[FMCADC_CONF_BRD_N_CHAN]; ++i) { for (i = 0; i < brd.value[ADC_CONF_BRD_N_CHAN]; ++i) {
printf("Get Channel %d Configuration ...\n", i); printf("Get Channel %d Configuration ...\n", i);
/* Configure acquisition parameter */ /* Configure acquisition parameter */
chn.type = FMCADC_CONF_TYPE_CHN; chn.type = ADC_CONF_TYPE_CHN;
chn.route_to = i; chn.route_to = i;
fmcadc_set_conf_mask(&chn, FMCADC_CONF_CHN_RANGE); adc_set_conf_mask(&chn, ADC_CONF_CHN_RANGE);
fmcadc_set_conf_mask(&chn, FMCADC_CONF_CHN_TERMINATION); adc_set_conf_mask(&chn, ADC_CONF_CHN_TERMINATION);
fmcadc_set_conf_mask(&chn, FMCADC_CONF_CHN_OFFSET); adc_set_conf_mask(&chn, ADC_CONF_CHN_OFFSET);
err = fmcadc_retrieve_config(adc, &chn); err = adc_retrieve_config(adc, &chn);
if (err) { if (err) {
fprintf(stderr, "%s: cannot get channel config: %s\n", fprintf(stderr, "%s: cannot get channel config: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
printf(" range: %d\n", chn.value[FMCADC_CONF_CHN_RANGE]); printf(" range: %d\n", chn.value[ADC_CONF_CHN_RANGE]);
printf(" 50Ohm Termination: %s\n", printf(" 50Ohm Termination: %s\n",
chn.value[FMCADC_CONF_CHN_TERMINATION] ? "yes" : "no"); chn.value[ADC_CONF_CHN_TERMINATION] ? "yes" : "no");
printf(" offset: %d\n", chn.value[FMCADC_CONF_CHN_OFFSET]); printf(" offset: %d\n", chn.value[ADC_CONF_CHN_OFFSET]);
} }
fmcadc_close(adc); adc_close(adc);
exit(0); exit(0);
} }
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <limits.h> #include <limits.h>
#include <errno.h> #include <errno.h>
#include <linux/zio-user.h> #include <linux/zio-user.h>
#include <fmcadc-lib.h> #include <adc-lib.h>
/* Global configuration*/ /* Global configuration*/
#define N_CHAN 4 #define N_CHAN 4
...@@ -23,16 +23,16 @@ unsigned presamples = 10; ...@@ -23,16 +23,16 @@ unsigned presamples = 10;
unsigned postsamples = 10; unsigned postsamples = 10;
int print_data = 1; int print_data = 1;
void print_buffer_content(struct fmcadc_buffer *buf); void print_buffer_content(struct adc_buffer *buf);
int read_with_one_buffer(struct fmcadc_dev *dev); int read_with_one_buffer(struct adc_dev *dev);
int read_with_n_buffer(struct fmcadc_dev *dev); int read_with_n_buffer(struct adc_dev *dev);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
unsigned long totalsamples = nshots * (presamples + postsamples); unsigned long totalsamples = nshots * (presamples + postsamples);
unsigned int dev_id, n_buffers = nshots; unsigned int dev_id, n_buffers = nshots;
struct fmcadc_conf acq, trg; struct adc_conf acq, trg;
struct fmcadc_dev *dev; struct adc_dev *dev;
int test = 0, err; int test = 0, err;
if (argc != 3) { if (argc != 3) {
...@@ -53,25 +53,25 @@ int main(int argc, char *argv[]) ...@@ -53,25 +53,25 @@ int main(int argc, char *argv[])
if (getenv("FALD_TEST_NOPRINT")) if (getenv("FALD_TEST_NOPRINT"))
print_data = 0; print_data = 0;
fmcadc_init(); adc_init();
dev = fmcadc_open(CARD_NAME, dev_id, totalsamples, n_buffers, dev = adc_open(CARD_NAME, dev_id, totalsamples, n_buffers,
FMCADC_F_FLUSH); ADC_F_FLUSH);
if (!dev) { if (!dev) {
fprintf(stderr, "%s: fmcadc_open(%s, 0x%x): %s\n", argv[0], fprintf(stderr, "%s: adc_open(%s, 0x%x): %s\n", argv[0],
CARD_NAME, dev_id, strerror(errno)); CARD_NAME, dev_id, strerror(errno));
exit(1); exit(1);
} }
if (strcmp(fmcadc_get_driver_type(dev), "zio")) { if (strcmp(adc_get_driver_type(dev), "zio")) {
fprintf(stderr, "%s: not a zio driver, aborting\n", argv[0]); fprintf(stderr, "%s: not a zio driver, aborting\n", argv[0]);
exit(1); exit(1);
} }
if (0) { /* We can't change buffer, because chardevs are open */ if (0) { /* We can't change buffer, because chardevs are open */
err = fmcadc_set_param(dev, "cset0/current_buffer", argv[3], 0); err = adc_set_param(dev, "cset0/current_buffer", argv[3], 0);
if (err) { if (err) {
fprintf(stderr, "%s: cannot set '%s' as buffer: %s\n", fprintf(stderr, "%s: cannot set '%s' as buffer: %s\n",
argv[0], argv[3], fmcadc_strerror(errno)); argv[0], argv[3], adc_strerror(errno));
exit(1); exit(1);
} }
} }
...@@ -81,35 +81,35 @@ int main(int argc, char *argv[]) ...@@ -81,35 +81,35 @@ int main(int argc, char *argv[])
/* configure acquisition parameters */ /* configure acquisition parameters */
memset(&acq, 0, sizeof(acq)); memset(&acq, 0, sizeof(acq));
acq.type = FMCADC_CONF_TYPE_ACQ; acq.type = ADC_CONF_TYPE_ACQ;
fmcadc_set_conf(&acq, FMCADC_CONF_ACQ_N_SHOTS, nshots); adc_set_conf(&acq, ADC_CONF_ACQ_N_SHOTS, nshots);
fmcadc_set_conf(&acq, FMCADC_CONF_ACQ_PRE_SAMP, presamples); adc_set_conf(&acq, ADC_CONF_ACQ_PRE_SAMP, presamples);
fmcadc_set_conf(&acq, FMCADC_CONF_ACQ_POST_SAMP, postsamples); adc_set_conf(&acq, ADC_CONF_ACQ_POST_SAMP, postsamples);
err = fmcadc_apply_config(dev, 0, &acq); err = adc_apply_config(dev, 0, &acq);
if (err) { if (err) {
fprintf(stderr, "%s: apply_config(acq): %s\n", fprintf(stderr, "%s: apply_config(acq): %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
/* configure trigger parameters */ /* configure trigger parameters */
memset(&trg, 0, sizeof(trg)); memset(&trg, 0, sizeof(trg));
trg.type = FMCADC_CONF_TYPE_TRG; trg.type = ADC_CONF_TYPE_TRG;
fmcadc_set_conf(&trg, FMCADC_CONF_TRG_SOURCE, 1); /* external */ adc_set_conf(&trg, ADC_CONF_TRG_SOURCE, 1); /* external */
err = fmcadc_apply_config(dev, 0, &trg); err = adc_apply_config(dev, 0, &trg);
if (err) { if (err) {
fprintf(stderr, "%s: apply_config(trigger): %s\n", fprintf(stderr, "%s: apply_config(trigger): %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
/* Start the acquisition */ /* Start the acquisition */
err = fmcadc_acq_start(dev, 0 , NULL); err = adc_acq_start(dev, 0 , NULL);
if (err) { if (err) {
fprintf(stderr, "%s: cannot start acquisition: %s\n", fprintf(stderr, "%s: cannot start acquisition: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
...@@ -123,32 +123,32 @@ int main(int argc, char *argv[]) ...@@ -123,32 +123,32 @@ int main(int argc, char *argv[])
} }
if (err) { if (err) {
fprintf(stderr, "%s: problem with read buffer: %s\n", fprintf(stderr, "%s: problem with read buffer: %s\n",
argv[0], fmcadc_strerror(errno)); argv[0], adc_strerror(errno));
exit(1); exit(1);
} }
/* Stop acquisition, close device and exit from library */ /* Stop acquisition, close device and exit from library */
fmcadc_acq_stop(dev, 0); adc_acq_stop(dev, 0);
fmcadc_close(dev); adc_close(dev);
fmcadc_exit(); adc_exit();
exit(0); exit(0);
} }
/* Read all shots with a single buffer and then release it */ /* Read all shots with a single buffer and then release it */
int read_with_one_buffer(struct fmcadc_dev *dev) int read_with_one_buffer(struct adc_dev *dev)
{ {
struct fmcadc_buffer *buf; struct adc_buffer *buf;
int err = 0, i; int err = 0, i;
buf = fmcadc_request_buffer(dev, presamples + postsamples, NULL, 0); buf = adc_request_buffer(dev, presamples + postsamples, NULL, 0);
for (i = 0; i < nshots; ++i) { for (i = 0; i < nshots; ++i) {
err = fmcadc_fill_buffer(dev, buf, 0, NULL); err = adc_fill_buffer(dev, buf, 0, NULL);
if (err) if (err)
break; break;
print_buffer_content(buf); print_buffer_content(buf);
} }
fmcadc_release_buffer(dev, buf, NULL); adc_release_buffer(dev, buf, NULL);
return err; return err;
} }
...@@ -157,19 +157,19 @@ int read_with_one_buffer(struct fmcadc_dev *dev) ...@@ -157,19 +157,19 @@ int read_with_one_buffer(struct fmcadc_dev *dev)
* request, fill and release are separated in different loop to show that * request, fill and release are separated in different loop to show that
* are not strictly consecutive operations * are not strictly consecutive operations
*/ */
int read_with_n_buffer(struct fmcadc_dev *dev) int read_with_n_buffer(struct adc_dev *dev)
{ {
struct fmcadc_buffer *buf[nshots] ; struct adc_buffer *buf[nshots] ;
int err = 0, i; int err = 0, i;
/* Allocate all buffers before the use */ /* Allocate all buffers before the use */
for (i = 0; i < nshots; ++i) for (i = 0; i < nshots; ++i)
buf[i] = fmcadc_request_buffer(dev, buf[i] = adc_request_buffer(dev,
presamples + postsamples, NULL, 0); presamples + postsamples, NULL, 0);
/* Fill all buffers */ /* Fill all buffers */
for (i = 0; i < nshots; ++i) { for (i = 0; i < nshots; ++i) {
err = fmcadc_fill_buffer(dev, buf[i], 0, NULL); err = adc_fill_buffer(dev, buf[i], 0, NULL);
if (err) if (err)
break; break;
print_buffer_content(buf[i]); print_buffer_content(buf[i]);
...@@ -177,19 +177,19 @@ int read_with_n_buffer(struct fmcadc_dev *dev) ...@@ -177,19 +177,19 @@ int read_with_n_buffer(struct fmcadc_dev *dev)
/* Release all buffers */ /* Release all buffers */
for (i = 0; i < nshots; ++i) for (i = 0; i < nshots; ++i)
fmcadc_release_buffer(dev, buf[i], NULL); adc_release_buffer(dev, buf[i], NULL);
return err; return err;
} }
void print_buffer_content(struct fmcadc_buffer *buf) void print_buffer_content(struct adc_buffer *buf)
{ {
int16_t *data = buf->data; /* get data */ int16_t *data = buf->data; /* get data */
struct fmcadc_timestamp *ts; struct adc_timestamp *ts;
int i, ch; int i, ch;
ts = fmcadc_tstamp_buffer(buf, NULL); ts = adc_tstamp_buffer(buf, NULL);
printf("timestamp %lli:%lli:%lli\n", printf("timestamp %lli:%lli:%lli\n",
(long long)ts->secs, (long long)ts->secs,
(long long)ts->ticks, (long long)ts->ticks,
......
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