Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
adc-lib
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
adc-lib
Commits
8ba919e1
Commit
8ba919e1
authored
Oct 19, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: add sw trigger fire in adc_acq
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
a9628cd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
+61
-0
adc-acq.c
tools/adc-acq.c
+61
-0
No files found.
tools/adc-acq.c
View file @
8ba919e1
...
@@ -27,6 +27,8 @@ static int arg_show_config = 0;
...
@@ -27,6 +27,8 @@ static int arg_show_config = 0;
static
int
arg_no_read
=
0
;
static
int
arg_no_read
=
0
;
static
int
arg_plot
=
0
;
static
int
arg_plot
=
0
;
static
int
arg_x_display
=
0
;
static
int
arg_x_display
=
0
;
static
int
arg_trgsw_delay
=
0
;
static
int
arg_trgsw
=
0
;
static
char
git_version
[]
=
"version: "
GIT_VERSION
;
static
char
git_version
[]
=
"version: "
GIT_VERSION
;
...
@@ -47,6 +49,8 @@ static void fald_help()
...
@@ -47,6 +49,8 @@ static void fald_help()
printf
(
" <idx>,<enable>,<polarity>,<threshold>,<hysteresis>,<delay>
\n
"
);
printf
(
" <idx>,<enable>,<polarity>,<threshold>,<hysteresis>,<delay>
\n
"
);
printf
(
" --trg-tim <parameters> configure a timing trigger
\n
"
);
printf
(
" --trg-tim <parameters> configure a timing trigger
\n
"
);
printf
(
" <NOT IMPLEMENTED YET>
\n
"
);
printf
(
" <NOT IMPLEMENTED YET>
\n
"
);
printf
(
" --trg-sw <parameters> configure a software trigger
\n
"
);
printf
(
" <delay_seconds>
\n
"
);
printf
(
" --channel| -c <parameters> configure an acquisition channel
\n
"
);
printf
(
" --channel| -c <parameters> configure an acquisition channel
\n
"
);
printf
(
" <channel>,<termination>,<range>,<offset>,<saturation>
\n
"
);
printf
(
" <channel>,<termination>,<range>,<offset>,<saturation>
\n
"
);
printf
(
" --timeout|-T <millisec> timeout for acquisition
\n
"
);
printf
(
" --timeout|-T <millisec> timeout for acquisition
\n
"
);
...
@@ -69,6 +73,7 @@ enum fald_acq_options {
...
@@ -69,6 +73,7 @@ enum fald_acq_options {
FALD_ACQ_OPT_TRG_EXT
=
1024
,
FALD_ACQ_OPT_TRG_EXT
=
1024
,
FALD_ACQ_OPT_TRG_THR
,
FALD_ACQ_OPT_TRG_THR
,
FALD_ACQ_OPT_TRG_TIM
,
FALD_ACQ_OPT_TRG_TIM
,
FALD_ACQ_OPT_TRG_SW
,
};
};
static
struct
option
options
[]
=
{
static
struct
option
options
[]
=
{
...
@@ -77,9 +82,11 @@ static struct option options[] = {
...
@@ -77,9 +82,11 @@ static struct option options[] = {
{
"trg-ext"
,
required_argument
,
0
,
FALD_ACQ_OPT_TRG_EXT
},
{
"trg-ext"
,
required_argument
,
0
,
FALD_ACQ_OPT_TRG_EXT
},
{
"trg-thr"
,
required_argument
,
0
,
FALD_ACQ_OPT_TRG_THR
},
{
"trg-thr"
,
required_argument
,
0
,
FALD_ACQ_OPT_TRG_THR
},
{
"trg-tim"
,
required_argument
,
0
,
FALD_ACQ_OPT_TRG_TIM
},
{
"trg-tim"
,
required_argument
,
0
,
FALD_ACQ_OPT_TRG_TIM
},
{
"trg-sw"
,
required_argument
,
0
,
FALD_ACQ_OPT_TRG_SW
},
{
"channel"
,
required_argument
,
0
,
'c'
},
{
"channel"
,
required_argument
,
0
,
'c'
},
{
"timeout"
,
required_argument
,
0
,
'T'
},
{
"timeout"
,
required_argument
,
0
,
'T'
},
/* new options, to help stress-test */
/* new options, to help stress-test */
{
"binary"
,
required_argument
,
0
,
'B'
},
{
"binary"
,
required_argument
,
0
,
'B'
},
{
"multi-binary"
,
required_argument
,
0
,
'M'
},
{
"multi-binary"
,
required_argument
,
0
,
'M'
},
...
@@ -465,6 +472,46 @@ static int fald_acq_channel_configuration(struct adc_dev *adc, char *param)
...
@@ -465,6 +472,46 @@ static int fald_acq_channel_configuration(struct adc_dev *adc, char *param)
return
adc_apply_config
(
adc
,
0
,
&
cfg
);
return
adc_apply_config
(
adc
,
0
,
&
cfg
);
}
}
/**
* It configures a software trigger according to the parameters' string
* @param[in] adc The ADC device token
* @param[in] param a parameter string in the form
* "<delay>"
* @return 0 on success, otherwise -1 and errno is appropriately set
*
* The parameters are not mandatory. If not provided, the application will
* not try to set them (there is not a default value)
*/
static
int
fald_trg_software_configuration
(
struct
adc_dev
*
adc
,
char
*
param
)
{
uint32_t
delay
;
int
ret
;
ret
=
sscanf
(
param
,
"%"
SCNu32
,
&
delay
);
if
(
ret
<=
0
)
{
/* channel is mandatory */
errno
=
EINVAL
;
return
-
1
;
}
if
(
!
adc_has_trigger_fire
(
adc
))
{
fprintf
(
stderr
,
"Software trigger not supported
\n
"
);
errno
=
ADC_ENOP
;
return
-
1
;
}
arg_trgsw
=
1
;
switch
(
ret
)
{
case
1
:
arg_trgsw_delay
=
delay
;
break
;
default:
errno
=
EINVAL
;
return
-
1
;
}
return
0
;
}
/**
/**
* It configures a external trigger according to the parameters' string
* It configures a external trigger according to the parameters' string
...
@@ -635,6 +682,14 @@ static int fald_acq_parse_args_and_configure(struct adc_dev *adc, int argc, char
...
@@ -635,6 +682,14 @@ static int fald_acq_parse_args_and_configure(struct adc_dev *adc, int argc, char
return
-
1
;
return
-
1
;
}
}
break
;
break
;
case
FALD_ACQ_OPT_TRG_SW
:
err
=
fald_trg_software_configuration
(
adc
,
optarg
);
if
(
err
)
{
fprintf
(
stderr
,
"%s: Cannot configure software trigger: %s
\n
"
,
_argv
[
0
],
adc_strerror
(
errno
));
return
-
1
;
}
break
;
case
'T'
:
case
'T'
:
timeout
=
atoi
(
optarg
);
timeout
=
atoi
(
optarg
);
break
;
break
;
...
@@ -1007,6 +1062,12 @@ int main(int argc, char *argv[])
...
@@ -1007,6 +1062,12 @@ int main(int argc, char *argv[])
continue
;
continue
;
}
}
for
(
k
=
0
;
k
<
nshots
;
++
k
)
{
for
(
k
=
0
;
k
<
nshots
;
++
k
)
{
if
(
arg_trgsw
)
{
sleep
(
arg_trgsw_delay
);
err
=
adc_trigger_fire
(
adc
);
if
(
err
)
break
;
}
fprintf
(
stderr
,
fprintf
(
stderr
,
"iteration: %d, shot: %i/%i, nsamples: %d
\n
"
,
"iteration: %d, shot: %i/%i, nsamples: %d
\n
"
,
i
,
k
+
1
,
nshots
,
nsamples
);
i
,
k
+
1
,
nshots
,
nsamples
);
...
...
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