From 8cd0e6f140aedc99645f4d5494802680cc258e0a Mon Sep 17 00:00:00 2001 From: hugues Date: Sun, 6 Sep 2020 11:49:02 +0200 Subject: [PATCH] boards/nucleo-f334r8: add ADC feature --- boards/nucleo-f334r8/Kconfig | 1 + boards/nucleo-f334r8/Makefile.features | 1 + boards/nucleo-f334r8/include/periph_conf.h | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/boards/nucleo-f334r8/Kconfig b/boards/nucleo-f334r8/Kconfig index a3170c0157..01988728b9 100644 --- a/boards/nucleo-f334r8/Kconfig +++ b/boards/nucleo-f334r8/Kconfig @@ -15,6 +15,7 @@ config BOARD_NUCLEO_F334R8 select CPU_MODEL_STM32F334R8 # Put defined MCU peripherals here (in alphabetical order) + select HAS_PERIPH_ADC select HAS_PERIPH_DMA select HAS_PERIPH_PWM select HAS_PERIPH_RTC diff --git a/boards/nucleo-f334r8/Makefile.features b/boards/nucleo-f334r8/Makefile.features index 1526867a49..9169db12b8 100644 --- a/boards/nucleo-f334r8/Makefile.features +++ b/boards/nucleo-f334r8/Makefile.features @@ -2,6 +2,7 @@ CPU = stm32 CPU_MODEL = stm32f334r8 # Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_dma FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc diff --git a/boards/nucleo-f334r8/include/periph_conf.h b/boards/nucleo-f334r8/include/periph_conf.h index d5d5bc1914..c279fc6ce2 100644 --- a/boards/nucleo-f334r8/include/periph_conf.h +++ b/boards/nucleo-f334r8/include/periph_conf.h @@ -31,6 +31,28 @@ extern "C" { #endif +/** + * @name ADC configuration + * + * Note that we do not configure all ADC channels, + * and not in the STM32F334 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, 0), .dev = 0, .chan = 1 }, /* ADC1_IN1, fast */ + { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 2 }, /* ADC1_IN2, fast */ + { .pin = GPIO_PIN(PORT_A, 4), .dev = 1, .chan = 1 }, /* ADC2_IN1, fast */ + { .pin = GPIO_PIN(PORT_B, 0), .dev = 0, .chan = 11 }, /* ADC1_IN11, slow */ + { .pin = GPIO_PIN(PORT_C, 1), .dev = 1, .chan = 7 }, /* ADC12_IN7, slow */ + { .pin = GPIO_PIN(PORT_C, 0), .dev = 1, .chan = 6 }, /* ADC12_IN6, slow */ +}; + +#define ADC_NUMOF ARRAY_SIZE(adc_config) +/** @} */ + /** * @name DMA streams configuration * @{