Skip to content

Commit a6500f1

Browse files
faxe1008cfriedt
authored andcommitted
drivers: sensor: voltage-divider: Add skip-calibration property
Adds a skip-calibration property to the voltage divider sensor, which can be enabled, in case the underlying ADC driver does not support calibration. Signed-off-by: Fabian Blatz <[email protected]>
1 parent 0025751 commit a6500f1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/sensor/voltage_divider/voltage.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct voltage_config {
2020
struct voltage_divider_dt_spec voltage;
2121
struct gpio_dt_spec gpio_power;
2222
uint32_t sample_delay_us;
23+
bool skip_calibration;
2324
};
2425

2526
struct voltage_data {
@@ -191,7 +192,7 @@ static int voltage_init(const struct device *dev)
191192

192193
data->sequence.buffer = &data->raw;
193194
data->sequence.buffer_size = sizeof(data->raw);
194-
data->sequence.calibrate = true;
195+
data->sequence.calibrate = !config->skip_calibration;
195196

196197
return pm_device_driver_init(dev, pm_action);
197198
}
@@ -203,6 +204,7 @@ static int voltage_init(const struct device *dev)
203204
.voltage = VOLTAGE_DIVIDER_DT_SPEC_GET(DT_DRV_INST(inst)), \
204205
.gpio_power = GPIO_DT_SPEC_INST_GET_OR(inst, power_gpios, {0}), \
205206
.sample_delay_us = DT_INST_PROP(inst, power_on_sample_delay_us), \
207+
.skip_calibration = DT_INST_PROP(inst, skip_calibration), \
206208
}; \
207209
\
208210
PM_DEVICE_DT_INST_DEFINE(inst, pm_action); \

dts/bindings/iio/afe/voltage-divider.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@ properties:
4545
`power-gpios`. In most cases the switched voltage rail will
4646
require some non-zero time to settle to its final value. The
4747
default value of 100us should be sufficient in most situations.
48+
49+
skip-calibration:
50+
type: boolean
51+
description: |
52+
Skip ADC calibration before taking a measurement.

0 commit comments

Comments
 (0)