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 <patrick.guenzel@kinexon.com>
This commit is contained in:
parent
c46247b550
commit
2a999e14e8
1 changed files with 8 additions and 0 deletions
|
|
@ -40,6 +40,14 @@ static int fetch(const struct device *dev, enum sensor_channel chan)
|
|||
/* Wait until sampling is valid */
|
||||
k_sleep(data->earliest_sample);
|
||||
|
||||
/* configure the active channel to be converted */
|
||||
ret = adc_channel_setup_dt(&config->voltage.port);
|
||||
if (ret != 0) {
|
||||
LOG_ERR("adc_setup failed: %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* start conversion */
|
||||
ret = adc_read(config->voltage.port.dev, &data->sequence);
|
||||
if (ret != 0) {
|
||||
LOG_ERR("adc_read: %d", ret);
|
||||
|
|
|
|||
Loading…
Reference in a new issue