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
b0a46eac
Commit
b0a46eac
authored
Aug 06, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
drv: fix DAC gain by subtracting a linear error
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
59f4ed1e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
fa-calibration.c
kernel/fa-calibration.c
+24
-1
No files found.
kernel/fa-calibration.c
View file @
b0a46eac
...
...
@@ -23,6 +23,7 @@ static const struct fa_calib_stanza fa_identity_calib = {
.
gain
=
{
0x8000
,
0x8000
,
0x8000
,
0x8000
},
.
temperature
=
50
*
100
,
/* 50 celsius degrees */
};
/* Max difference from identity thing */
#define FA_CALIB_MAX_DELTA_OFFSET 0x1000
#define FA_CALIB_MAX_DELTA_GAIN 0x1000
...
...
@@ -94,6 +95,19 @@ static int fa_calib_adc_gain_fix(int range, int gain_c, int32_t delta_temp)
return
gain_c
-
error
;
}
/*
* Empirical values for the gain error slope
* 10V 0.0012500
* 1V -0.0000233
* 100mV -0.0000163
* To do integer math I store the value multiplied by 100000000
*/
static
const
int
gain_dac_error_slope_fix
[]
=
{
[
FA100M14B4C_RANGE_10V
]
=
17100
,
[
FA100M14B4C_RANGE_1V
]
=
-
349
,
[
FA100M14B4C_RANGE_100mV
]
=
1540
,
};
/**
* Compute the correct gain
* @range: voltage range
...
...
@@ -103,7 +117,14 @@ static int fa_calib_adc_gain_fix(int range, int gain_c, int32_t delta_temp)
*/
static
int
fa_calib_dac_gain_fix
(
int
range
,
int
gain_c
,
int32_t
delta_temp
)
{
return
gain_c
;
int
error
;
error
=
gain_adc_error_slope_fix
[
range
]
*
delta_temp
;
error
/=
100000000
;
/* the slope was multiplied by 100000000 */
error
/=
1000
;
/* the temperature is in milli-degree */
return
gain_c
-
error
;
}
static
void
fa_calib_adc_config_chan
(
struct
fa_dev
*
fa
,
unsigned
int
chan
,
...
...
@@ -194,6 +215,8 @@ static int fa_calib_dac_config_chan(struct fa_dev *fa, unsigned int chan,
int
gain
=
fa_calib_dac_gain_fix
(
range
,
cal
->
gain
[
chan
],
delta_temp
);
int
hwval
;
dev_dbg
(
&
fa
->
pdev
->
dev
,
"%s: {chan: %d, range: %d, gain: 0x%x, offset: 0x%x}
\n
"
,
__func__
,
chan
,
range
,
gain
,
offset
);
hwval
=
fa_dac_offset_raw_calibrate
(
off_uv_raw
,
gain
,
offset
);
return
fa_dac_offset_set
(
fa
,
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