File tree Expand file tree Collapse file tree 2 files changed +23
-11
lines changed
soc/arm/atmel_sam0/common Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,6 @@ static int adc_sam0_channel_setup(const struct device *dev,
133133 adc -> SAMPCTRL .reg = sampctrl ;
134134 wait_synchronization (adc );
135135
136-
137136 uint8_t refctrl ;
138137
139138 switch (channel_cfg -> reference ) {
@@ -142,14 +141,14 @@ static int adc_sam0_channel_setup(const struct device *dev,
142141 /* Enable the internal bandgap reference */
143142 ADC_BGEN = 1 ;
144143 break ;
145- case ADC_REF_VDD_1_2 :
146- refctrl = ADC_REFCTRL_REFSEL_VDD_1_2 | ADC_REFCTRL_REFCOMP ;
147- break ;
148144#ifdef ADC_REFCTRL_REFSEL_VDD_1
149145 case ADC_REF_VDD_1 :
150146 refctrl = ADC_REFCTRL_REFSEL_VDD_1 | ADC_REFCTRL_REFCOMP ;
151147 break ;
152148#endif
149+ case ADC_REF_VDD_1_2 :
150+ refctrl = ADC_REFCTRL_REFSEL_VDD_1_2 | ADC_REFCTRL_REFCOMP ;
151+ break ;
153152 case ADC_REF_EXTERNAL0 :
154153 refctrl = ADC_REFCTRL_REFSEL_AREFA ;
155154 break ;
Original file line number Diff line number Diff line change 106106#endif
107107#endif /* MCLK */
108108
109+ /*
110+ * All SAM0 define the internal voltage reference as 1.0V by default.
111+ */
109112#ifndef ADC_REFCTRL_REFSEL_INTERNAL
110113# ifdef ADC_REFCTRL_REFSEL_INTREF
111114# define ADC_REFCTRL_REFSEL_INTERNAL ADC_REFCTRL_REFSEL_INTREF
114117# endif
115118#endif
116119
120+ /*
121+ * Some SAM0 devices can use VDDANA as a direct reference. For the devices
122+ * that not offer this option, the internal 1.0V reference will be used.
123+ */
124+ #ifndef ADC_REFCTRL_REFSEL_VDD_1
125+ # if defined(ADC0_BANDGAP )
126+ # define ADC_REFCTRL_REFSEL_VDD_1 ADC_REFCTRL_REFSEL_INTVCC1
127+ # elif defined(ADC_REFCTRL_REFSEL_INTVCC2 )
128+ # define ADC_REFCTRL_REFSEL_VDD_1 ADC_REFCTRL_REFSEL_INTVCC2
129+ # endif
130+ #endif
131+
132+ /*
133+ * SAMD/E5x define ADC[0-1]_BANDGAP symbol. Only those devices use INTVCC0 to
134+ * implement VDDANA / 2.
135+ */
117136#ifndef ADC_REFCTRL_REFSEL_VDD_1_2
118- # ifdef ADC_REFCTRL_REFSEL_INTVCC0
137+ # ifdef ADC0_BANDGAP
119138# define ADC_REFCTRL_REFSEL_VDD_1_2 ADC_REFCTRL_REFSEL_INTVCC0
120139# else
121140# define ADC_REFCTRL_REFSEL_VDD_1_2 ADC_REFCTRL_REFSEL_INTVCC1
122141# endif
123142#endif
124143
125- #ifndef ADC_REFCTRL_REFSEL_VDD_1
126- # ifdef ADC_REFCTRL_REFSEL_INTVCC1
127- # define ADC_REFCTRL_REFSEL_VDD_1 ADC_REFCTRL_REFSEL_INTVCC1
128- # endif
129- #endif
130-
131144#endif /* _ATMEL_SAM0_ADC_FIXUP_H_ */
You can’t perform that action at this time.
0 commit comments