drivers: adc: sam0: Fix adc_reference implementation

The current sam0 adc driver not implement correctly the adc_reference
enum values. This try homonize adc input referece by tracking VDDANA
at ADC_REF_VDD_1. The ADC_REF_VDD_1_2 were fixed with correct INTVCCx
channel selection.

Fixes #45443

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
Gerson Fernando Budke 2022-05-16 20:27:58 +02:00 committed by Marti Bolivar
commit 5b7734c926
2 changed files with 23 additions and 11 deletions

View file

@ -133,7 +133,6 @@ static int adc_sam0_channel_setup(const struct device *dev,
adc->SAMPCTRL.reg = sampctrl;
wait_synchronization(adc);
uint8_t refctrl;
switch (channel_cfg->reference) {
@ -142,14 +141,14 @@ static int adc_sam0_channel_setup(const struct device *dev,
/* Enable the internal bandgap reference */
ADC_BGEN = 1;
break;
case ADC_REF_VDD_1_2:
refctrl = ADC_REFCTRL_REFSEL_VDD_1_2 | ADC_REFCTRL_REFCOMP;
break;
#ifdef ADC_REFCTRL_REFSEL_VDD_1
case ADC_REF_VDD_1:
refctrl = ADC_REFCTRL_REFSEL_VDD_1 | ADC_REFCTRL_REFCOMP;
break;
#endif
case ADC_REF_VDD_1_2:
refctrl = ADC_REFCTRL_REFSEL_VDD_1_2 | ADC_REFCTRL_REFCOMP;
break;
case ADC_REF_EXTERNAL0:
refctrl = ADC_REFCTRL_REFSEL_AREFA;
break;