From 76ca2f5a08c49e69ff2e50ba3b34e0cf417b369a Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Tue, 22 Oct 2019 11:19:26 +0200 Subject: [PATCH] boards/arduino-zero: configure ADC channels --- boards/arduino-zero/Makefile.features | 1 + boards/arduino-zero/include/periph_conf.h | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/boards/arduino-zero/Makefile.features b/boards/arduino-zero/Makefile.features index b6c34c06be..2933443774 100644 --- a/boards/arduino-zero/Makefile.features +++ b/boards/arduino-zero/Makefile.features @@ -2,6 +2,7 @@ CPU = samd21 CPU_MODEL = samd21g18a # Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc diff --git a/boards/arduino-zero/include/periph_conf.h b/boards/arduino-zero/include/periph_conf.h index b458f5fbbf..da138c9d44 100644 --- a/boards/arduino-zero/include/periph_conf.h +++ b/boards/arduino-zero/include/periph_conf.h @@ -194,7 +194,25 @@ static const pwm_conf_t pwm_config[] = { * @name ADC configuration * @{ */ -#define ADC_NUMOF (0) + +/* ADC Default values */ +#define ADC_PRESCALER ADC_CTRLB_PRESCALER_DIV512 + +#define ADC_NEG_INPUT ADC_INPUTCTRL_MUXNEG_GND +#define ADC_GAIN_FACTOR_DEFAULT ADC_INPUTCTRL_GAIN_1X +#define ADC_REF_DEFAULT ADC_REFCTRL_REFSEL_INT1V + +static const adc_conf_chan_t adc_channels[] = { + /* port, pin, muxpos */ + {GPIO_PIN(PA, 2), ADC_INPUTCTRL_MUXPOS_PIN0}, /* A0 */ + {GPIO_PIN(PB, 8), ADC_INPUTCTRL_MUXPOS_PIN2}, /* A1 */ + {GPIO_PIN(PB, 9), ADC_INPUTCTRL_MUXPOS_PIN3}, /* A2 */ + {GPIO_PIN(PA, 4), ADC_INPUTCTRL_MUXPOS_PIN4}, /* A3 */ + {GPIO_PIN(PA, 5), ADC_INPUTCTRL_MUXPOS_PIN5}, /* A4 */ + {GPIO_PIN(PB, 2), ADC_INPUTCTRL_MUXPOS_PIN10}, /* A5 */ +}; + +#define ADC_NUMOF ARRAY_SIZE(adc_channels) /** @} */ /**