Skip to content

Commit 2a999e1

Browse files
guenzel-kinexonhenrikbrixandersen
authored andcommitted
sensors: reconfig adc for channel
Some ADCs (e.g. SAM0) can only convert one channel at a time and therefore need to be reconfigured for every voltage divider prior to startin the conversion Signed-off-by: Patrick Günzel <[email protected]>
1 parent c46247b commit 2a999e1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/sensor/voltage_divider/voltage.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ static int fetch(const struct device *dev, enum sensor_channel chan)
4040
/* Wait until sampling is valid */
4141
k_sleep(data->earliest_sample);
4242

43+
/* configure the active channel to be converted */
44+
ret = adc_channel_setup_dt(&config->voltage.port);
45+
if (ret != 0) {
46+
LOG_ERR("adc_setup failed: %d", ret);
47+
return ret;
48+
}
49+
50+
/* start conversion */
4351
ret = adc_read(config->voltage.port.dev, &data->sequence);
4452
if (ret != 0) {
4553
LOG_ERR("adc_read: %d", ret);

0 commit comments

Comments
 (0)