From 356a1992053fbbbbf3e34d88ca9c3f919b16b44b Mon Sep 17 00:00:00 2001 From: hugues Date: Sun, 6 Sep 2020 19:31:37 +0200 Subject: [PATCH] boards/nucleo-f303ze: add ADC feature --- boards/nucleo-f303ze/Kconfig | 1 + boards/nucleo-f303ze/Makefile.features | 1 + boards/nucleo-f303ze/include/periph_conf.h | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/boards/nucleo-f303ze/Kconfig b/boards/nucleo-f303ze/Kconfig index 4f29eedc06..a8a6ff6b85 100644 --- a/boards/nucleo-f303ze/Kconfig +++ b/boards/nucleo-f303ze/Kconfig @@ -15,6 +15,7 @@ config BOARD_NUCLEO_F303ZE select CPU_MODEL_STM32F303ZE # Put defined MCU peripherals here (in alphabetical order) + select HAS_PERIPH_ADC select HAS_PERIPH_PWM select HAS_PERIPH_RTC select HAS_PERIPH_SPI diff --git a/boards/nucleo-f303ze/Makefile.features b/boards/nucleo-f303ze/Makefile.features index 698cb6adcd..87a9ea6c2b 100644 --- a/boards/nucleo-f303ze/Makefile.features +++ b/boards/nucleo-f303ze/Makefile.features @@ -2,6 +2,7 @@ CPU = stm32 CPU_MODEL = stm32f303ze # Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_spi diff --git a/boards/nucleo-f303ze/include/periph_conf.h b/boards/nucleo-f303ze/include/periph_conf.h index fe85132044..26a145a62a 100644 --- a/boards/nucleo-f303ze/include/periph_conf.h +++ b/boards/nucleo-f303ze/include/periph_conf.h @@ -37,6 +37,28 @@ extern "C" { #endif +/** + * @name ADC configuration + * + * Note that we do not configure all ADC channels, + * and not in the STM32F303 order. Instead, we + * just define 6 ADC channels, for the Nucleo + * Arduino header pins A0-A5 + * + * @{ + */ +static const adc_conf_t adc_config[] = { + { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 4 }, /* ADC1_IN4, fast */ + { .pin = GPIO_PIN(PORT_C, 0), .dev = 1, .chan = 6 }, /* ADC12_IN6, slow */ + { .pin = GPIO_PIN(PORT_C, 3), .dev = 1, .chan = 9 }, /* ADC12_IN9, slow */ + { .pin = GPIO_PIN(PORT_D, 11), .dev = 2, .chan = 8 }, /* ADC34_IN8, slow */ + { .pin = GPIO_PIN(PORT_D, 12), .dev = 3, .chan = 9 }, /* ADC34_IN9, slow */ + { .pin = GPIO_PIN(PORT_D, 13), .dev = 3, .chan = 10 }, /* ADC34_IN10, slo */ +}; + +#define ADC_NUMOF ARRAY_SIZE(adc_config) +/** @} */ + /** * @name UART configuration * @{