Commit 1e40c00a authored by Tristan Gingold's avatar Tristan Gingold Committed by Federico Vaga

tools/adc-acq.c: allow floating point values to sw trigger delay

parent e06d2fc3
......@@ -555,11 +555,11 @@ static int fald_acq_channel_configuration(struct adc_dev *adc, char *param)
*/
static int fald_trg_software_configuration(struct adc_dev *adc, char *param)
{
uint32_t delay;
double delay;
int ret;
ret = sscanf(param, "%u", &delay);
if (ret <= 0) { /* channel is mandatory */
ret = sscanf(param, "%lf", &delay);
if (ret != 1) { /* delay is mandatory */
errno = EINVAL;
return -1;
}
......@@ -569,16 +569,8 @@ static int fald_trg_software_configuration(struct adc_dev *adc, char *param)
errno = ADC_ENOP;
return -1;
}
arg_trgsw = 1;
switch (ret) {
case 1:
arg_trgsw_delay = delay;
break;
default:
errno = EINVAL;
return -1;
}
arg_trgsw = 1;
arg_trgsw_delay = delay * 1000000;
return 0;
}
......@@ -1220,18 +1212,24 @@ static int adc_acq_acquisition(struct adc_dev *adc,
adc_get_conf(cfg_acq, ADC_CONF_ACQ_PRE_SAMP, &pre);
adc_get_conf(cfg_acq, ADC_CONF_ACQ_POST_SAMP, &post);
adc_get_conf(cfg_acq, ADC_CONF_ACQ_N_SHOTS, &nshots);
if (arg_trgsw_delay) {
for (k = 0; k < nshots; ++k) {
usleep(arg_trgsw_delay);
err = adc_trigger_fire(adc);
if (err) {
fprintf(stderr, "Cannot fire sw trigger: (%d) %s\n",
errno, adc_strerror(errno));
goto err;
}
}
}
for (k = 0; k < nshots; ++k) {
fprintf(stderr,
"shot: %i/%u, nsamples: %u\n",
k + 1, nshots, pre + post);
if (arg_trgsw) {
sleep(arg_trgsw_delay);
err = adc_trigger_fire(adc);
if (err)
goto err;
}
tv.tv_sec = 60;
err = adc_fill_buffer(adc, buf,
fixup ? ADC_F_FIXUP: 0,
......
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