driver: adjust res when oversampling
The SAM0 ADC has an internal register to divide the accumulated results of oversampling the ADC by the amount of samples collected. This value has to be set by the driver and was missing. Signed-off-by: Patrick Günzel <patrick.guenzel@kinexon.com>
This commit is contained in:
parent
ba5971e703
commit
66dceba537
1 changed files with 6 additions and 2 deletions
|
|
@ -177,7 +177,6 @@ static int adc_sam0_channel_setup(const struct device *dev,
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
uint32_t inputctrl = 0;
|
||||
|
||||
switch (channel_cfg->gain) {
|
||||
|
|
@ -255,7 +254,6 @@ static int adc_sam0_channel_setup(const struct device *dev,
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -325,6 +323,12 @@ static int start_read(const struct device *dev,
|
|||
}
|
||||
|
||||
adc->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM(sequence->oversampling);
|
||||
if (sequence->oversampling < 4) {
|
||||
adc->AVGCTRL.reg |= ADC_AVGCTRL_ADJRES(sequence->oversampling);
|
||||
} else {
|
||||
adc->AVGCTRL.reg |= ADC_AVGCTRL_ADJRES(4);
|
||||
}
|
||||
|
||||
/* AVGCTRL is not synchronized */
|
||||
|
||||
#ifdef CONFIG_SOC_SERIES_SAMD20
|
||||
|
|
|
|||
Loading…
Reference in a new issue