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
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
misc
adc-lib
Commits
4b79f254
Commit
4b79f254
authored
Oct 22, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib: add function to set/get more configurations in one call
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
372263f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
library-user.rst
doc/library-user.rst
+5
-0
adc-lib.h
lib/adc-lib.h
+5
-0
route.c
lib/route.c
+54
-0
No files found.
doc/library-user.rst
View file @
4b79f254
...
...
@@ -185,6 +185,11 @@ Following an example from the ``example.c`` code available under ``tools``
:language: c
:lines: 186-203
There are also the correspondent functions to set/get more than one
configuration at time:
:cpp:func:`adc_apply_config_n()`, :cpp:func:`adc_retrieve_config_n()`.
To handle the exceptional cases where parameters are actually *strings*
(``char *``) or the library does not support them (e.g. board-specific
parameter), the library added the support to single access parameters.
...
...
lib/adc-lib.h
View file @
4b79f254
...
...
@@ -394,8 +394,13 @@ extern int adc_reset_conf(struct adc_dev *dev, unsigned int flags,
struct
adc_conf
*
conf
);
extern
int
adc_apply_config
(
struct
adc_dev
*
dev
,
unsigned
int
flags
,
struct
adc_conf
*
conf
);
extern
int
adc_apply_config_n
(
struct
adc_dev
*
dev
,
unsigned
int
flags
,
struct
adc_conf
*
conf
,
unsigned
int
n
);
extern
int
adc_retrieve_config
(
struct
adc_dev
*
dev
,
struct
adc_conf
*
conf
);
extern
int
adc_retrieve_config_n
(
struct
adc_dev
*
dev
,
struct
adc_conf
*
conf
,
unsigned
int
n
);
extern
uint64_t
adc_get_capabilities
(
struct
adc_dev
*
dev
,
enum
adc_configuration_type
type
);
extern
int
adc_get_param
(
struct
adc_dev
*
dev
,
char
*
name
,
...
...
lib/route.c
View file @
4b79f254
...
...
@@ -295,6 +295,33 @@ int adc_apply_config(struct adc_dev *dev, unsigned int flags,
}
/**
* It applies the given configuration to the device
* @param[in] dev ADC device token
* @param[in] flags
* @param[in] conf list of configurations to apply
* @param[in] n number of valid configurations in conf
* @return 0 on success, -1 on error and errno is set appropriately
*
* If a configuration cannot be applied entirely, then this function
* will set ADC_CONF_F_ERROR in conf[i].flags
*/
int
adc_apply_config_n
(
struct
adc_dev
*
dev
,
unsigned
int
flags
,
struct
adc_conf
*
conf
,
unsigned
int
n
)
{
unsigned
int
i
;
int
err_last
=
0
;
for
(
i
=
0
;
i
<
n
;
++
i
)
{
int
err
=
adc_apply_config
(
dev
,
flags
,
&
conf
[
i
]);
if
(
err
)
{
err_last
=
err
;
continue
;
}
}
return
err_last
;
}
/**
* It retrieve the current device configuration
...
...
@@ -341,6 +368,33 @@ int adc_retrieve_config(struct adc_dev *dev, struct adc_conf *conf)
return
err
;
}
/**
* It retrieve the current device configuration
* @param[in] dev ADC device token
* @param[in,out] conf configuration descriptor to fill with configuration
* values.
* @param[in] n number of valid configurations in conf
* @return 0 on success, -1 on error and errno is set appropriately
*
* If a configuration cannot be retrieved entirely, then this function
* will set ADC_CONF_F_ERROR in conf[i].flags
*/
int
adc_retrieve_config_n
(
struct
adc_dev
*
dev
,
struct
adc_conf
*
conf
,
unsigned
int
n
)
{
unsigned
int
i
;
int
err_last
=
0
;
for
(
i
=
0
;
i
<
n
;
++
i
)
{
int
err
=
adc_retrieve_config
(
dev
,
&
conf
[
i
]);
if
(
err
)
{
err_last
=
err
;
continue
;
}
}
return
err_last
;
}
/**
* It get a single parameter from the device
...
...
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