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
8d29bc85
Commit
8d29bc85
authored
Oct 18, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/buffer-fixup' into develop
parents
8099a4bb
5bcdb131
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
3 deletions
+52
-3
library-user.rst
doc/library-user.rst
+19
-0
adc-lib-int.h
lib/adc-lib-int.h
+1
-0
adc-lib.h
lib/adc-lib.h
+4
-0
fmc-adc-100m14b4cha.c
lib/fmc-adc-100m14b4cha.c
+1
-1
route.c
lib/route.c
+27
-2
No files found.
doc/library-user.rst
View file @
8d29bc85
...
...
@@ -433,6 +433,25 @@ for most of them the extraction is driver-specific.
The details about the actual content of ``zio_control`` is described
in the driver documentation.
Fixup
'''''
It may happen that low-level (HDL, hardware) bugs are found and they cannot
be fixed. This library offers the possibility to compensate for those errors.
For each type of board we can have, or not, a *fixup* algorithm that is able
to fix the data in the buffer and compensate the bugs.
There two possibilities to run the *fixup* algorithm over a given buffer.
The first one is to pass the flag :cpp:any:`ADC_F_FIXUP` to
:cpp:func:`adc_fill_buffer()`.::
err = adc_fill_buffer(adc, buff, ADC_F_FIXUP, &timeout);
The second one is to run it explicitly by invoking
:cpp:func:`adc_buffer_fixup()`.::
err = adc_buffer_fixup(buf);
Time Stamps
-------------
...
...
lib/adc-lib-int.h
View file @
8d29bc85
...
...
@@ -46,6 +46,7 @@ struct adc_operations {
typeof
(
adc_trigger_fire
)
*
trigger_fire
;
/**< @related adc_trigger_fire */
typeof
(
adc_buffer_get_sample
)
*
buffer_get_sample
;
/**< @related adc_buffer_get_sample */
typeof
(
adc_buffer_fixup
)
*
buffer_fixup
;
/**< @related adc_buffer_fixup*/
};
...
...
lib/adc-lib.h
View file @
8d29bc85
...
...
@@ -64,6 +64,7 @@ struct adc_buffer {
void
*
mapaddr
;
/**< mmap address */
unsigned
long
maplen
;
/**< mmap length */
unsigned
long
flags
;
/**< internal to the library */
void
*
priv
;
/**< library private date */
};
...
...
@@ -265,6 +266,8 @@ struct adc_conf {
(used by adc_open) */
#define ADC_F_VERBOSE 0x00020000
/**< Flag used to verbose on stdout/stderr
(usable by any function)*/
#define ADC_F_FIXUP 0x00400000
/**< Flag used to fixup a buffer when
filling it (usable by adc_fill_buffer) */
/**
* @defgroup dev Basic
...
...
@@ -400,6 +403,7 @@ extern int adc_buffer_get_sample(struct adc_buffer *buf,
unsigned
int
chan
,
unsigned
int
acq_sample
,
int32_t
*
value
);
extern
int
adc_buffer_fixup
(
struct
adc_buffer
*
buf
);
/**@}*/
/* libfmcadc version string */
...
...
lib/fmc-adc-100m14b4cha.c
View file @
8d29bc85
...
...
@@ -734,7 +734,6 @@ static int adc_100m14b4cha_buffer_get_sample(struct adc_buffer *buf,
return
0
;
}
#define ADC_100M_4CH_14BIT_ACQ_MASK (1LL << ADC_CONF_ACQ_N_SHOTS) | \
(1LL << ADC_CONF_ACQ_POST_SAMP) | \
(1LL << ADC_CONF_ACQ_PRE_SAMP) | \
...
...
@@ -785,6 +784,7 @@ static struct adc_operations fa_100ms_4ch_14bit_op = {
.
trigger_fire
=
adc_100m14b4cha_trigger_fire
,
.
buffer_get_sample
=
adc_100m14b4cha_buffer_get_sample
,
.
buffer_fixup
=
NULL
,
};
struct
adc_board_type
fmcadc_100ms_4ch_14bit
=
{
...
...
lib/route.c
View file @
8d29bc85
...
...
@@ -402,6 +402,7 @@ struct adc_buffer *adc_request_buffer(struct adc_dev *dev,
* @param[in] dev ADC device token
* @param[in] buf the buffer to fill
* @param[in] flags used to control how to fill the buffer
* (ADC_F_FIXUP)
* @param[in] timeout maximum time to fill the buffer. The behavior
* is similar to *select(1)*. If NULL, there is no timeout and
* the function will wait until the data is ready.
...
...
@@ -419,13 +420,21 @@ int adc_fill_buffer(struct adc_dev *dev,
{
struct
adc_gid
*
g
=
(
struct
adc_gid
*
)
dev
;
const
struct
adc_board_type
*
b
=
g
->
board
;
int
err
;
if
(
!
b
->
adc_op
->
fill_buffer
)
{
errno
=
ADC_ENOP
;
return
-
1
;
}
return
b
->
adc_op
->
fill_buffer
(
dev
,
buf
,
flags
,
timeout
);
err
=
b
->
adc_op
->
fill_buffer
(
dev
,
buf
,
flags
,
timeout
);
if
(
err
)
return
err
;
if
(
flags
&
ADC_F_FIXUP
)
return
adc_buffer_fixup
(
buf
);
return
0
;
}
...
...
@@ -540,6 +549,22 @@ int adc_buffer_get_sample(struct adc_buffer *buf,
return
-
1
;
}
return
b
->
adc_op
->
buffer_get_sample
(
buf
,
chan
,
acq_sample
,
value
);
}
/**
* It fixes the given buffer if there is any need
* @param[in, out] buf acquistion buffer (filled)
* @return 0 on success, -1 on error and errno is set appropriately
*
* This is used by board specifc code to compensate some known error
*/
int
adc_buffer_fixup
(
struct
adc_buffer
*
buf
)
{
struct
adc_gid
*
g
=
(
struct
adc_gid
*
)
buf
->
dev
;
const
struct
adc_board_type
*
b
=
g
->
board
;
if
(
b
->
adc_op
->
buffer_fixup
)
return
b
->
adc_op
->
buffer_fixup
(
buf
);
return
0
;
}
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