diff --git a/boards/seeedstudio-gd32/Kconfig b/boards/seeedstudio-gd32/Kconfig index 46c9ea8230..24879583ac 100644 --- a/boards/seeedstudio-gd32/Kconfig +++ b/boards/seeedstudio-gd32/Kconfig @@ -14,6 +14,7 @@ config BOARD_SEEEDSTUDIO_GD32 select CPU_MODEL_GD32VF103VBT6 select BOARD_HAS_HXTAL select BOARD_HAS_LXTAL + select HAS_PERIPH_ADC select HAS_PERIPH_I2C select HAS_PERIPH_PWM select HAS_PERIPH_SPI diff --git a/boards/seeedstudio-gd32/Makefile.features b/boards/seeedstudio-gd32/Makefile.features index f1a4d92d35..4972cfd7da 100644 --- a/boards/seeedstudio-gd32/Makefile.features +++ b/boards/seeedstudio-gd32/Makefile.features @@ -1,6 +1,7 @@ CPU_MODEL = gd32vf103vbt6 # Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi diff --git a/boards/seeedstudio-gd32/doc.txt b/boards/seeedstudio-gd32/doc.txt index 2419086fa0..4fa5666de9 100644 --- a/boards/seeedstudio-gd32/doc.txt +++ b/boards/seeedstudio-gd32/doc.txt @@ -37,7 +37,7 @@ on-board components: | Timers | 5 x 16-bit timer | yes | | RTC | 1 x 32-bit counter, 20-bit prescaler | yes | | WDT | 2 x 12-bit counter, 3-bit prescaler | yes | -| ADC | 2 x 12-bit units, 16 channels, 1 Msps | no | +| ADC | 2 x 12-bit units, 16 channels @ 1 Msps | yes | | DAC | 2 x 12-bit channel | no | | UART | 2 | yes | | USART | 3 | yes | @@ -65,6 +65,9 @@ MCU pins and their configuration in RIOT. | MCU Pin | MCU Peripheral | RIOT Peripheral | Board Function | Remark | |:--------|:---------------|:-----------------|:---------------|:-----------------------------| | PA0 | BOOT0 | BTN0 | KEY1 | | +| PA1 | ADC01_IN1 | ADC_LINE(0) | | | +| PA2 | ADC01_IN2 | ADC_LINE(1) | | | +| PA3 | ADC01_IN3 | ADC_LINE(2) | | | | PA9 | USART0 TX | UART_DEV(0) TX | UART TX | | | PA10 | USART0 RX | UART_DEV(0) RX | UART RX | | | PA4 | SPI1 CS | SPI_DEV(1) CS | | | @@ -84,7 +87,15 @@ MCU pins and their configuration in RIOT. | PB13 | SPI0 SCLK | SPI_DEV(0) SCLK | | | | PB14 | SPI0 MISO | SPI_DEV(0) MISO | | | | PB15 | SPI0 MOSI | SPI_DEV(0) MOSI | | | +| PC0 | ADC01_IN10 | ADC_LINE(3) | | | +| PC1 | ADC01_IN11 | ADC_LINE(4) | | | +| PC2 | ADC01_IN12 | ADC_LINE(5) | | | +| PC3 | ADC01_IN13 | ADC_LINE(6) | | | +| PC4 | ADC01_IN14 | ADC_LINE(7) | | | +| PC5 | ADC01_IN15 | ADC_LINE(8) | | | | PC13 | | BTN1 | KEY2 | | +| - | ADC01_IN16 | ADC_LINE(9) | | internal Temperature channel | +| - | ADC01_IN17 | ADC_LINE(10) | | internal VFEF channel | ## Flashing the Device diff --git a/boards/seeedstudio-gd32/include/periph_conf.h b/boards/seeedstudio-gd32/include/periph_conf.h index 9a807a2434..e93dfcd163 100644 --- a/boards/seeedstudio-gd32/include/periph_conf.h +++ b/boards/seeedstudio-gd32/include/periph_conf.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2020 Koen Zandberg + * 2023 Gunar Schorcht * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -14,6 +15,7 @@ * @brief Board specific definitions for the SeeedStudio GD32 RISC-V board * * @author Koen Zandberg + * @author Gunar Schorcht */ #ifndef PERIPH_CONF_H @@ -45,6 +47,29 @@ extern "C" { #endif +/** + * @name ADC configuration + * @{ + */ +static const adc_conf_t adc_config[] = { + { .pin = GPIO_PIN(PORT_A, 1), .dev = 0, .chan = 1 }, + { .pin = GPIO_PIN(PORT_A, 2), .dev = 0, .chan = 2 }, + { .pin = GPIO_PIN(PORT_A, 3), .dev = 0, .chan = 3 }, + { .pin = GPIO_PIN(PORT_C, 0), .dev = 0, .chan = 10 }, + { .pin = GPIO_PIN(PORT_C, 1), .dev = 0, .chan = 11 }, + { .pin = GPIO_PIN(PORT_C, 2), .dev = 0, .chan = 12 }, + { .pin = GPIO_PIN(PORT_C, 3), .dev = 0, .chan = 13 }, + { .pin = GPIO_PIN(PORT_C, 4), .dev = 0, .chan = 14 }, + { .pin = GPIO_PIN(PORT_C, 5), .dev = 0, .chan = 15 }, + /* ADC Temperature channel */ + { .pin = GPIO_UNDEF, .dev = 0, .chan = 16 }, + /* ADC VREF channel */ + { .pin = GPIO_UNDEF, .dev = 0, .chan = 17 }, +}; + +#define ADC_NUMOF ARRAY_SIZE(adc_config) +/** @} */ + /** * @name PWM configuration * @{