Skip to content

Commit a31d092

Browse files
ciocca-djic23
authored andcommitted
iio:magnetometer: bugfix magnetometers gain values
This patch fix gains values. The first driver was designed using engineering samples, in mass production the values are changed. Signed-off-by: Denis Ciocca <[email protected]> Cc: [email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent d4f5195 commit a31d092

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

drivers/iio/magnetometer/st_magn_core.c

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
#define ST_MAGN_FS_AVL_5600MG 5600
4343
#define ST_MAGN_FS_AVL_8000MG 8000
4444
#define ST_MAGN_FS_AVL_8100MG 8100
45-
#define ST_MAGN_FS_AVL_10000MG 10000
45+
#define ST_MAGN_FS_AVL_12000MG 12000
46+
#define ST_MAGN_FS_AVL_16000MG 16000
4647

4748
/* CUSTOM VALUES FOR SENSOR 1 */
4849
#define ST_MAGN_1_WAI_EXP 0x3c
@@ -69,20 +70,20 @@
6970
#define ST_MAGN_1_FS_AVL_4700_VAL 0x05
7071
#define ST_MAGN_1_FS_AVL_5600_VAL 0x06
7172
#define ST_MAGN_1_FS_AVL_8100_VAL 0x07
72-
#define ST_MAGN_1_FS_AVL_1300_GAIN_XY 1100
73-
#define ST_MAGN_1_FS_AVL_1900_GAIN_XY 855
74-
#define ST_MAGN_1_FS_AVL_2500_GAIN_XY 670
75-
#define ST_MAGN_1_FS_AVL_4000_GAIN_XY 450
76-
#define ST_MAGN_1_FS_AVL_4700_GAIN_XY 400
77-
#define ST_MAGN_1_FS_AVL_5600_GAIN_XY 330
78-
#define ST_MAGN_1_FS_AVL_8100_GAIN_XY 230
79-
#define ST_MAGN_1_FS_AVL_1300_GAIN_Z 980
80-
#define ST_MAGN_1_FS_AVL_1900_GAIN_Z 760
81-
#define ST_MAGN_1_FS_AVL_2500_GAIN_Z 600
82-
#define ST_MAGN_1_FS_AVL_4000_GAIN_Z 400
83-
#define ST_MAGN_1_FS_AVL_4700_GAIN_Z 355
84-
#define ST_MAGN_1_FS_AVL_5600_GAIN_Z 295
85-
#define ST_MAGN_1_FS_AVL_8100_GAIN_Z 205
73+
#define ST_MAGN_1_FS_AVL_1300_GAIN_XY 909
74+
#define ST_MAGN_1_FS_AVL_1900_GAIN_XY 1169
75+
#define ST_MAGN_1_FS_AVL_2500_GAIN_XY 1492
76+
#define ST_MAGN_1_FS_AVL_4000_GAIN_XY 2222
77+
#define ST_MAGN_1_FS_AVL_4700_GAIN_XY 2500
78+
#define ST_MAGN_1_FS_AVL_5600_GAIN_XY 3030
79+
#define ST_MAGN_1_FS_AVL_8100_GAIN_XY 4347
80+
#define ST_MAGN_1_FS_AVL_1300_GAIN_Z 1020
81+
#define ST_MAGN_1_FS_AVL_1900_GAIN_Z 1315
82+
#define ST_MAGN_1_FS_AVL_2500_GAIN_Z 1666
83+
#define ST_MAGN_1_FS_AVL_4000_GAIN_Z 2500
84+
#define ST_MAGN_1_FS_AVL_4700_GAIN_Z 2816
85+
#define ST_MAGN_1_FS_AVL_5600_GAIN_Z 3389
86+
#define ST_MAGN_1_FS_AVL_8100_GAIN_Z 4878
8687
#define ST_MAGN_1_MULTIREAD_BIT false
8788

8889
/* CUSTOM VALUES FOR SENSOR 2 */
@@ -105,10 +106,12 @@
105106
#define ST_MAGN_2_FS_MASK 0x60
106107
#define ST_MAGN_2_FS_AVL_4000_VAL 0x00
107108
#define ST_MAGN_2_FS_AVL_8000_VAL 0x01
108-
#define ST_MAGN_2_FS_AVL_10000_VAL 0x02
109-
#define ST_MAGN_2_FS_AVL_4000_GAIN 430
110-
#define ST_MAGN_2_FS_AVL_8000_GAIN 230
111-
#define ST_MAGN_2_FS_AVL_10000_GAIN 230
109+
#define ST_MAGN_2_FS_AVL_12000_VAL 0x02
110+
#define ST_MAGN_2_FS_AVL_16000_VAL 0x03
111+
#define ST_MAGN_2_FS_AVL_4000_GAIN 146
112+
#define ST_MAGN_2_FS_AVL_8000_GAIN 292
113+
#define ST_MAGN_2_FS_AVL_12000_GAIN 438
114+
#define ST_MAGN_2_FS_AVL_16000_GAIN 584
112115
#define ST_MAGN_2_MULTIREAD_BIT false
113116
#define ST_MAGN_2_OUT_X_L_ADDR 0x28
114117
#define ST_MAGN_2_OUT_Y_L_ADDR 0x2a
@@ -266,9 +269,14 @@ static const struct st_sensors st_magn_sensors[] = {
266269
.gain = ST_MAGN_2_FS_AVL_8000_GAIN,
267270
},
268271
[2] = {
269-
.num = ST_MAGN_FS_AVL_10000MG,
270-
.value = ST_MAGN_2_FS_AVL_10000_VAL,
271-
.gain = ST_MAGN_2_FS_AVL_10000_GAIN,
272+
.num = ST_MAGN_FS_AVL_12000MG,
273+
.value = ST_MAGN_2_FS_AVL_12000_VAL,
274+
.gain = ST_MAGN_2_FS_AVL_12000_GAIN,
275+
},
276+
[3] = {
277+
.num = ST_MAGN_FS_AVL_16000MG,
278+
.value = ST_MAGN_2_FS_AVL_16000_VAL,
279+
.gain = ST_MAGN_2_FS_AVL_16000_GAIN,
272280
},
273281
},
274282
},

0 commit comments

Comments
 (0)