From f278df5c960d3a8dfd3d360dea4e95e4ed669d63 Mon Sep 17 00:00:00 2001 From: Dave VanKampen Date: Fri, 24 Sep 2021 10:21:10 -0400 Subject: [PATCH] boards/nucleo-g070rb: Added ADCs 0-5 for g070 nucleo --- boards/nucleo-g070rb/Kconfig | 1 + boards/nucleo-g070rb/Makefile.features | 1 + boards/nucleo-g070rb/include/periph_conf.h | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/boards/nucleo-g070rb/Kconfig b/boards/nucleo-g070rb/Kconfig index 20f7ddcf64..78ceb7451a 100644 --- a/boards/nucleo-g070rb/Kconfig +++ b/boards/nucleo-g070rb/Kconfig @@ -15,6 +15,7 @@ config BOARD_NUCLEO_G070RB select CPU_MODEL_STM32G070RB # Put defined MCU peripherals here (in alphabetical order) + select HAS_PERIPH_ADC select HAS_PERIPH_I2C select HAS_PERIPH_SPI select HAS_PERIPH_TIMER diff --git a/boards/nucleo-g070rb/Makefile.features b/boards/nucleo-g070rb/Makefile.features index a1ece4c9c5..8f36cb4b3f 100644 --- a/boards/nucleo-g070rb/Makefile.features +++ b/boards/nucleo-g070rb/Makefile.features @@ -2,6 +2,7 @@ CPU = stm32 CPU_MODEL = stm32g070rb # Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer diff --git a/boards/nucleo-g070rb/include/periph_conf.h b/boards/nucleo-g070rb/include/periph_conf.h index a9227c1d3d..7e4fa79110 100644 --- a/boards/nucleo-g070rb/include/periph_conf.h +++ b/boards/nucleo-g070rb/include/periph_conf.h @@ -86,6 +86,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 STM32G070 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 * @{