1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 22:13:52 +01:00

cpu/sam0_common: adc: Automatically configure extref pin

This commit is contained in:
Benjamin Valentin 2022-05-02 16:23:49 +02:00
parent 164220fb7f
commit 35588d46bd
2 changed files with 32 additions and 0 deletions

View File

@ -779,6 +779,23 @@ typedef struct {
#endif
} adc_conf_chan_t;
/**
* @brief Pin that can be used for external voltage reference A
*/
#define ADC_REFSEL_AREFA_PIN GPIO_PIN(PA, 3)
/**
* @brief Pin that can be used for external voltage reference B
*/
#define ADC_REFSEL_AREFB_PIN GPIO_PIN(PA, 4)
#if defined(ADC_REFCTRL_REFSEL_AREFC) || DOXYGEN
/**
* @brief Pin that can be used for external voltage reference C
*/
#define ADC_REFSEL_AREFC_PIN GPIO_PIN(PA, 6)
#endif
/**
* @name Ethernet peripheral parameters
* @{

View File

@ -223,6 +223,21 @@ static int _adc_configure(Adc *dev, adc_res_t res)
SUPC->VREF.reg |= SUPC_VREF_VREFOE;
}
#endif
#ifdef ADC_REFCTRL_REFSEL_AREFA
if (ADC_REF_DEFAULT == ADC_REFCTRL_REFSEL_AREFA) {
gpio_init_mux(ADC_REFSEL_AREFA_PIN, GPIO_MUX_B);
}
#endif
#ifdef ADC_REFCTRL_REFSEL_AREFB
if (ADC_REF_DEFAULT == ADC_REFCTRL_REFSEL_AREFB) {
gpio_init_mux(ADC_REFSEL_AREFB_PIN, GPIO_MUX_B);
}
#endif
#ifdef ADC_REFCTRL_REFSEL_AREFC
if (ADC_REF_DEFAULT == ADC_REFCTRL_REFSEL_AREFC) {
gpio_init_mux(ADC_REFSEL_AREFC_PIN, GPIO_MUX_B);
}
#endif
/* Enable ADC Module */
dev->CTRLA.reg |= ADC_CTRLA_ENABLE;