Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC ADC 100M 14b 4cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
FMC ADC 100M 14b 4cha - Software
Commits
17e68283
Commit
17e68283
authored
Aug 06, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drv: split DAC offset computation in smaller functions
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
faeef496
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
fa-core.c
kernel/fa-core.c
+17
-11
No files found.
kernel/fa-core.c
View file @
17e68283
...
...
@@ -158,23 +158,23 @@ static int zfad_dac_set(struct zio_channel *chan, uint32_t val)
return
fa_spi_xfer
(
fa
,
FA_SPI_SS_DAC
(
chan
->
index
),
16
,
val
,
NULL
);
}
static
int
zfad_offset_to_dac
(
struct
zio_channel
*
chan
,
int32_t
uval
,
enum
fa100m14b4c_input_range
range
)
static
int64_t
fa_dac_offset_raw_get
(
int32_t
offset
)
{
struct
fa_dev
*
fa
=
get_zfadc
(
&
chan
->
cset
->
zdev
->
head
.
dev
);
int
offset
,
gain
;
int64_t
hwval
;
hwval
=
uval
*
0x8000LL
/
5000000
;
hwval
=
offset
*
0x8000LL
/
5000000
;
if
(
hwval
==
0x8000
)
hwval
=
0x7fff
;
/* -32768 .. 32767 */
return
hwval
;
}
offset
=
fa
->
calib
.
dac
[
range
].
offset
[
chan
->
index
];
gain
=
fa
->
calib
.
dac
[
range
].
gain
[
chan
->
index
];
static
int64_t
fa_dac_offset_raw_calibrate
(
int32_t
raw_offset
,
int
gain
,
int
offset
)
{
int64_t
hwval
;
hwval
=
((
hwval
+
offset
)
*
gain
)
>>
15
;
/* signed */
hwval
+=
0x8000
;
/* offset binary */
hwval
=
((
raw_offset
+
offset
)
*
gain
)
>>
15
;
/* signed */
hwval
+=
0x8000
;
/* offset binary */
if
(
hwval
<
0
)
hwval
=
0
;
if
(
hwval
>
0xffff
)
...
...
@@ -216,6 +216,8 @@ int zfad_apply_offset(struct zio_channel *chan)
{
struct
fa_dev
*
fa
=
get_zfadc
(
&
chan
->
cset
->
zdev
->
head
.
dev
);
int32_t
off_uv
=
fa_dac_offset_get
(
fa
,
chan
->
index
);
int32_t
off_uv_raw
=
fa_dac_offset_raw_get
(
off_uv
);
struct
fa_calib_stanza
*
cal
;
int
hwval
;
int
range
;
...
...
@@ -223,7 +225,11 @@ int zfad_apply_offset(struct zio_channel *chan)
range
=
fa
->
range
[
chan
->
index
];
spin_unlock
(
&
fa
->
zdev
->
cset
->
lock
);
hwval
=
zfad_offset_to_dac
(
chan
,
off_uv
,
range
);
cal
=
&
fa
->
calib
.
dac
[
range
];
hwval
=
fa_dac_offset_raw_calibrate
(
off_uv_raw
,
cal
->
gain
[
chan
->
index
],
cal
->
offset
[
chan
->
index
]);
return
zfad_dac_set
(
chan
,
hwval
);
}
...
...
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