From ef6fc615ab704be785819040910bf2db5c6c5c8e Mon Sep 17 00:00:00 2001 From: Dave VanKampen Date: Fri, 24 Sep 2021 10:21:17 -0400 Subject: [PATCH] boards/nucleo-g071rb: Added ADCs 0-5 for g071 nucleo --- boards/nucleo-g071rb/Kconfig | 1 + boards/nucleo-g071rb/Makefile.features | 1 + boards/nucleo-g071rb/include/periph_conf.h | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/boards/nucleo-g071rb/Kconfig b/boards/nucleo-g071rb/Kconfig index 376b6621db..e03e2a87a8 100644 --- a/boards/nucleo-g071rb/Kconfig +++ b/boards/nucleo-g071rb/Kconfig @@ -15,6 +15,7 @@ config BOARD_NUCLEO_G071RB select CPU_MODEL_STM32G071RB # Put defined MCU peripherals here (in alphabetical order) + select HAS_PERIPH_ADC select HAS_PERIPH_I2C select HAS_PERIPH_RTT select HAS_PERIPH_SPI diff --git a/boards/nucleo-g071rb/Makefile.features b/boards/nucleo-g071rb/Makefile.features index ffa484623e..d7038a4afe 100644 --- a/boards/nucleo-g071rb/Makefile.features +++ b/boards/nucleo-g071rb/Makefile.features @@ -2,6 +2,7 @@ CPU = stm32 CPU_MODEL = stm32g071rb # Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_spi diff --git a/boards/nucleo-g071rb/include/periph_conf.h b/boards/nucleo-g071rb/include/periph_conf.h index 2ed0679676..f7ca766479 100644 --- a/boards/nucleo-g071rb/include/periph_conf.h +++ b/boards/nucleo-g071rb/include/periph_conf.h @@ -84,6 +84,27 @@ static const uart_conf_t uart_config[] = { #define UART_NUMOF ARRAY_SIZE(uart_config) /** @} */ +/** + * @name ADC configuration + * + * Note that we do not configure all ADC channels, + * and not in the STM32G071 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 = 0 }, + { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 1 }, + { .pin = GPIO_PIN(PORT_A, 4), .dev = 0, .chan = 4 }, + { .pin = GPIO_PIN(PORT_B, 1), .dev = 0, .chan = 9 }, + { .pin = GPIO_PIN(PORT_B, 11), .dev = 0, .chan = 15 }, + { .pin = GPIO_PIN(PORT_B, 12), .dev = 0, .chan = 16 }, +}; + +#define ADC_NUMOF ARRAY_SIZE(adc_config) + /** * @name SPI configuration * @{