Skip to content

Commit baeb208

Browse files
drivers: tmag5273: Add mag gain property
Signed-off-by: Marek Maškarinec <marek.maskarinec@hardwario.com>
1 parent 91b1b84 commit baeb208

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/sensor/ti/tmag5273/tmag5273.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct tmag5273_config {
5858
uint8_t temperature_coefficient;
5959
uint8_t angle_magnitude_axis;
6060
uint8_t ch_mag_gain_correction;
61+
uint8_t mag_gain_correction;
6162

6263
uint8_t operation_mode;
6364
uint8_t averaging;
@@ -1075,6 +1076,13 @@ static inline int tmag5273_init_sensor_settings(const struct tmag5273_config *dr
10751076
return -EIO;
10761077
}
10771078

1079+
retval = i2c_reg_write_byte_dt(&drv_cfg->i2c, TMAG5273_REG_MAG_GAIN_CONFIG,
1080+
drv_cfg->mag_gain_correction);
1081+
if (retval < 0) {
1082+
LOG_ERR("error setting MAG_GAIN_CONFIG %d", retval);
1083+
return -EIO;
1084+
}
1085+
10781086
return 0;
10791087
}
10801088

@@ -1258,6 +1266,7 @@ static DEVICE_API(sensor, tmag5273_driver_api) = {
12581266
DT_PROP(DT_INST(inst, compat), temperature_coefficient), \
12591267
.angle_magnitude_axis = DT_PROP(DT_INST(inst, compat), angle_magnitude_axis), \
12601268
.ch_mag_gain_correction = DT_PROP(DT_INST(inst, compat), ch_mag_gain_correction), \
1269+
.mag_gain_correction = DT_INST_PROP(inst, mag_gain_correction), \
12611270
.operation_mode = DT_PROP(DT_INST(inst, compat), operation_mode), \
12621271
.averaging = DT_PROP(DT_INST(inst, compat), average_mode), \
12631272
.trigger_conv_via_int = \

dts/bindings/sensor/ti,tmag5273.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ properties:
134134
135135
Only active if angle-magnitude-calculation is active.
136136
137+
mag-gain-correction:
138+
type: int
139+
default: 0
140+
description: |
141+
Gain value for axis determined by ch-mag-gain-correction.
142+
143+
The value is between 0 and 255, interpreted as a fractional
144+
value between 0 and 1 (mag-gain-correction/256). Gain value of 0
145+
is interpreted as 1.
146+
137147
average-mode:
138148
type: int
139149
default: 1

0 commit comments

Comments
 (0)