Skip to content

Commit bbaaac9

Browse files
DavidCerronedkalowsk
authored andcommitted
drivers: sensor: current_amp: add calibration option
Allow the option to enable or disable calibration of the ADC. Signed-off-by: David Cerrone <davidcerrone@gmail.com>
1 parent d3584b4 commit bbaaac9

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

drivers/sensor/current_amp/current_amp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static int current_init(const struct device *dev)
152152

153153
data->sequence.buffer = &data->raw;
154154
data->sequence.buffer_size = sizeof(data->raw);
155-
data->sequence.calibrate = true;
155+
data->sequence.calibrate = config->enable_calibration;
156156

157157
return 0;
158158
}

dts/bindings/iio/afe/current-sense-amplifier.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ properties:
4545
4646
If present the corresponding GPIO must be set to an active level
4747
to enable the current amplifier.
48+
49+
enable-calibration:
50+
type: boolean
51+
description: |
52+
Enable calibration of the current sense amplifier.
53+
This is used to calibrate the ADC prior to taking measurements.

include/zephyr/drivers/adc/current_sense_amplifier.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct current_sense_amplifier_dt_spec {
1616
uint16_t sense_gain_mult;
1717
uint16_t sense_gain_div;
1818
struct gpio_dt_spec power_gpio;
19+
bool enable_calibration;
1920
};
2021

2122
/**
@@ -35,6 +36,7 @@ struct current_sense_amplifier_dt_spec {
3536
.sense_gain_mult = DT_PROP(node_id, sense_gain_mult), \
3637
.sense_gain_div = DT_PROP(node_id, sense_gain_div), \
3738
.power_gpio = GPIO_DT_SPEC_GET_OR(node_id, power_gpios, {0}), \
39+
.enable_calibration = DT_PROP_OR(node_id, enable_calibration, false), \
3840
}
3941

4042
/**

0 commit comments

Comments
 (0)