From 7f97c2143ead91076498a372f4d1d9ad6db6a392 Mon Sep 17 00:00:00 2001 From: krzysztof-cabaj Date: Fri, 16 Aug 2024 10:00:23 +0200 Subject: [PATCH 1/3] boards/nucleo-f439zi: add initial ADC support --- boards/nucleo-f439zi/Makefile.features | 1 + boards/nucleo-f439zi/include/periph_conf.h | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/boards/nucleo-f439zi/Makefile.features b/boards/nucleo-f439zi/Makefile.features index 8abb89362d..8411620c5b 100644 --- a/boards/nucleo-f439zi/Makefile.features +++ b/boards/nucleo-f439zi/Makefile.features @@ -2,6 +2,7 @@ CPU = stm32 CPU_MODEL = stm32f439zi # Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_dma FEATURES_PROVIDED += periph_eth FEATURES_PROVIDED += periph_i2c diff --git a/boards/nucleo-f439zi/include/periph_conf.h b/boards/nucleo-f439zi/include/periph_conf.h index aabd705105..febb5ac9e7 100644 --- a/boards/nucleo-f439zi/include/periph_conf.h +++ b/boards/nucleo-f439zi/include/periph_conf.h @@ -198,6 +198,10 @@ static const eth_conf_t eth_config = { #define ETH_DMA_ISR isr_dma2_stream0 /** @} */ +static const adc_conf_t adc_config[] = {{}}; + +#define ADC_NUMOF ARRAY_SIZE(adc_config) + #ifdef __cplusplus } #endif From 2d52ebd13617e61ac191ad5119664dab9b415faa Mon Sep 17 00:00:00 2001 From: krzysztof-cabaj Date: Fri, 16 Aug 2024 10:03:33 +0200 Subject: [PATCH 2/3] cpu/stm32/f4: add ADC support for f439zi --- cpu/stm32/include/periph/f4/periph_cpu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/stm32/include/periph/f4/periph_cpu.h b/cpu/stm32/include/periph/f4/periph_cpu.h index adba5e27be..231e246161 100644 --- a/cpu/stm32/include/periph/f4/periph_cpu.h +++ b/cpu/stm32/include/periph/f4/periph_cpu.h @@ -32,8 +32,8 @@ extern "C" { #define ADC_DEVS (1U) #elif defined(CPU_LINE_STM32F405xx) || defined(CPU_LINE_STM32F407xx) \ || defined(CPU_LINE_STM32F415xx) || defined(CPU_LINE_STM32F429xx) \ - || defined(CPU_LINE_STM32F437xx) || defined(CPU_LINE_STM32F446xx) \ - || defined(CPU_LINE_STM32F469xx) + || defined(CPU_LINE_STM32F439xx) || defined(CPU_LINE_STM32F437xx) \ + || defined(CPU_LINE_STM32F446xx) || defined(CPU_LINE_STM32F469xx) #define ADC_DEVS (3U) #endif From 03c700f1d67d5297acb67d88a971ee2f8fb67980 Mon Sep 17 00:00:00 2001 From: krzysztof-cabaj Date: Fri, 16 Aug 2024 13:04:15 +0200 Subject: [PATCH 3/3] boards/nucleo-f439zi: add full ADC config and doxygen doc --- boards/nucleo-f439zi/include/periph_conf.h | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/boards/nucleo-f439zi/include/periph_conf.h b/boards/nucleo-f439zi/include/periph_conf.h index febb5ac9e7..588d3aee9b 100644 --- a/boards/nucleo-f439zi/include/periph_conf.h +++ b/boards/nucleo-f439zi/include/periph_conf.h @@ -198,9 +198,43 @@ static const eth_conf_t eth_config = { #define ETH_DMA_ISR isr_dma2_stream0 /** @} */ -static const adc_conf_t adc_config[] = {{}}; +/** + * @name ADC configuration + * + * Note that we do not configure all ADC channels, + * and not in the STM32F439ZI order. Instead, we + * just define 6 ADC channels, for the Nucleo + * Arduino header pins A0-A5 and the internal VBAT channel. + * + * To find appropriate device and channel find in the + * board manual, table showing pin assignments and + * information about ADC - a text similar to ADC[X]_IN[Y], + * where: + * [X] - describes used device - indexed from 0, + * for example ADC12_IN10 is device 0 or device 1, + * [Y] - describes used channel - indexed from 1, + * for example ADC12_IN10 is channel 10 + * + * For STM32F439ZI this information is in MCU datasheet, + * Table 10, page 53 or in Nucleo-f439ZI board manual, + * Table 17, page 52. + + * @{ + */ +static const adc_conf_t adc_config[] = { + {GPIO_PIN(PORT_A, 3), .dev = 2, .chan = 3}, /* ADC123_IN3 */ + {GPIO_PIN(PORT_C, 0), .dev = 2, .chan = 10}, /* ADC123_IN10 */ + {GPIO_PIN(PORT_C, 3), .dev = 2, .chan = 13}, /* ADC123_IN13 */ + {GPIO_PIN(PORT_F, 3), .dev = 2, .chan = 9}, /* ADC3_IN9 */ + {GPIO_PIN(PORT_F, 5), .dev = 2, .chan = 15}, /* ADC3_IN15 */ + {GPIO_PIN(PORT_F, 10), .dev = 2, .chan = 8}, /* ADC3_IN8 */ + {GPIO_UNDEF, .dev = 0, .chan = 18}, /* VBAT */ +}; + +#define VBAT_ADC ADC_LINE(6) /**< VBAT ADC line */ #define ADC_NUMOF ARRAY_SIZE(adc_config) +/** @} */ #ifdef __cplusplus }