diff --git a/boards/common/esp32x/Kconfig b/boards/common/esp32x/Kconfig new file mode 100644 index 0000000000..703ab39ac0 --- /dev/null +++ b/boards/common/esp32x/Kconfig @@ -0,0 +1,20 @@ +# Copyright (c) 2020 HAW Hamburg +# +# 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 +# directory for more details. + +config BOARD_COMMON_ESP32X + bool + select HAS_PERIPH_UART + + select HAVE_SAUL_GPIO + +config MODULE_BOARDS_COMMON_ESP32X + bool + depends on TEST_KCONFIG + depends on BOARD_COMMON_ESP32X + depends on HAS_ARCH_ESP32 + default y + help + Common ESP32x boards code. diff --git a/boards/common/esp32x/Makefile b/boards/common/esp32x/Makefile new file mode 100644 index 0000000000..4bede69663 --- /dev/null +++ b/boards/common/esp32x/Makefile @@ -0,0 +1,3 @@ +MODULE = boards_common_esp32x + +include $(RIOTBASE)/Makefile.base diff --git a/boards/common/esp32x/Makefile.dep b/boards/common/esp32x/Makefile.dep new file mode 100644 index 0000000000..d406950ee5 --- /dev/null +++ b/boards/common/esp32x/Makefile.dep @@ -0,0 +1,5 @@ +USEMODULE += boards_common_esp32x + +ifneq (,$(filter saul_default,$(USEMODULE))) + USEMODULE += saul_gpio +endif diff --git a/boards/common/esp32x/Makefile.features b/boards/common/esp32x/Makefile.features new file mode 100644 index 0000000000..3d3348ae93 --- /dev/null +++ b/boards/common/esp32x/Makefile.features @@ -0,0 +1,4 @@ +CPU = esp32 + +# additional features provided by all boards is at least one UART +FEATURES_PROVIDED += periph_uart diff --git a/boards/common/esp32x/Makefile.include b/boards/common/esp32x/Makefile.include new file mode 100644 index 0000000000..51a5b7e629 --- /dev/null +++ b/boards/common/esp32x/Makefile.include @@ -0,0 +1,5 @@ +INCLUDES += -I$(RIOTBOARD)/common/esp32x/include + +# configure the serial interface +PORT_LINUX ?= /dev/ttyUSB0 +PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) diff --git a/boards/common/esp32s3/board_common.c b/boards/common/esp32x/board_common.c similarity index 93% rename from boards/common/esp32s3/board_common.c rename to boards/common/esp32x/board_common.c index b3c372fa17..ea30032e76 100644 --- a/boards/common/esp32s3/board_common.c +++ b/boards/common/esp32x/board_common.c @@ -7,14 +7,14 @@ */ /** - * @ingroup boards_common_esp32s3 + * @ingroup boards_common_esp32x * @{ * * @file - * @brief Common declarations and functions for all ESP32-S3 boards. + * @brief Common declarations and functions for all ESP32x boards. * * This file contains default declarations and functions that are valid - * for all ESP32-S3 boards. + * for all ESP32x boards. * * @author Gunar Schorcht */ diff --git a/boards/common/esp32x/doc.txt b/boards/common/esp32x/doc.txt new file mode 100644 index 0000000000..66c6d33599 --- /dev/null +++ b/boards/common/esp32x/doc.txt @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 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 + * directory for more details. + */ + +/** + * @defgroup boards_common_esp32x ESP32x Common + * @brief Definitions and configurations that are common for + * all ESP32 boards. + * + * For detailed information about the ESP32, configuring and compiling RIOT + * for ESP32 boards, please refer \ref esp32_riot. + */ diff --git a/boards/common/esp32s3/include/arduino_board_common.h b/boards/common/esp32x/include/arduino_board_common.h similarity index 88% rename from boards/common/esp32s3/include/arduino_board_common.h rename to boards/common/esp32x/include/arduino_board_common.h index f86cc059ba..0166c19d4b 100644 --- a/boards/common/esp32s3/include/arduino_board_common.h +++ b/boards/common/esp32x/include/arduino_board_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Gunar Schorcht + * Copyright (C) 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 @@ -7,11 +7,11 @@ */ /** - * @ingroup boards_common_esp32s3 + * @ingroup boards_common_esp32x * @{ * * @file - * @brief Common board definitions for the Arduino API + * @brief Definitions for the Arduino API that are common for all ESP32x boards * * @author Gunar Schorcht */ diff --git a/boards/common/esp32s3/include/board_common.h b/boards/common/esp32x/include/board_common.h similarity index 92% rename from boards/common/esp32s3/include/board_common.h rename to boards/common/esp32x/include/board_common.h index 92ccbd1c43..ca5a074d1e 100644 --- a/boards/common/esp32s3/include/board_common.h +++ b/boards/common/esp32x/include/board_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Gunar Schorcht + * Copyright (C) 2018 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 @@ -7,13 +7,12 @@ */ /** - * @ingroup boards_common_esp32s3 - * @brief Common board definitions for ESP32-S3 boards. + * @ingroup boards_common + * @brief Board definitions that are common for all ESP32x boards. * - * This file contains board configurations that are valid for all - * ESP32-S3 boards. + * This file contains board configurations that are valid for all ESP32. * - * For detailed information about the configuration of ESP32-S3 boards, see + * For detailed information about the configuration of ESP32 boards, see * section \ref esp32_peripherals "Common Peripherals". * * @author Gunar Schorcht diff --git a/boards/common/esp32s3/include/periph_conf_common.h b/boards/common/esp32x/include/periph_conf_common.h similarity index 89% rename from boards/common/esp32s3/include/periph_conf_common.h rename to boards/common/esp32x/include/periph_conf_common.h index 120fdd526a..2f7bfe6bfa 100644 --- a/boards/common/esp32s3/include/periph_conf_common.h +++ b/boards/common/esp32x/include/periph_conf_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Gunar Schorcht + * Copyright (C) 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 @@ -7,13 +7,13 @@ */ /** - * @ingroup boards_common_esp32s3 - * @brief Common peripheral configurations for ESP32-S3 boards + * @ingroup boards_common_esp32x + * @brief Peripheral configurations that are common for all ESP32x boards * * This file contains the peripheral configurations that are valid for all - * ESP32-S3 boards. + * ESP32x boards. * - * For detailed information about the peripheral configuration for ESP32-S3 + * For detailed information about the peripheral configuration for ESP32x * boards, see section \ref esp32_peripherals "Common Peripherals". * * @author Gunar Schorcht @@ -24,6 +24,18 @@ #ifndef PERIPH_CONF_COMMON_H #define PERIPH_CONF_COMMON_H +#if defined(CPU_FAM_ESP32) +#include "periph_conf_common_esp32.h" +#elif defined(CPU_FAM_ESP32C3) +#include "periph_conf_common_esp32c3.h" +#elif defined(CPU_FAM_ESP32S2) +#include "periph_conf_common_esp32s2.h" +#elif defined(CPU_FAM_ESP32S3) +#include "periph_conf_common_esp32s3.h" +#else +#error "ESP32x SoC family not supported" +#endif + /* include periph_cpu.h to make it visible in any case */ #include "periph_cpu.h" #include "kernel_defines.h" @@ -105,16 +117,18 @@ static const gpio_t dac_channels[] = DAC_GPIOS; /** Define SCL pullup enabled by default */ #define I2C0_SCL_PULLUP true #endif + #if defined(I2C0_SDA) && !defined(I2C0_SDA_PULLUP) /** Define SDA pullup enabled by default */ #define I2C0_SDA_PULLUP true #endif -#if defined(I2C1_SCL) && !defined(I2C1_SCL_PULLUP) +#if (SOC_I2C_NUM > 1) && defined(I2C1_SCL) && !defined(I2C1_SCL_PULLUP) /** Define SCL pullup enabled by default */ #define I2C1_SCL_PULLUP true #endif -#if defined(I2C1_SDA) && !defined(I2C1_SDA_PULLUP) + +#if (SOC_I2C_NUM > 1) && defined(I2C1_SDA) && !defined(I2C1_SDA_PULLUP) /** Define SDA pullup enabled by default */ #define I2C1_SDA_PULLUP true #endif @@ -133,7 +147,7 @@ static const i2c_conf_t i2c_config[] = { .sda_pullup = I2C0_SCL_PULLUP, }, #endif -#if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED) +#if (SOC_I2C_NUM > 1) && defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED) { .module = PERIPH_I2C1_MODULE, .speed = I2C1_SPEED, @@ -295,7 +309,7 @@ static const rmt_channel_config_t rmt_channel_config[] = { * @brief Static array with configuration for declared SPI devices */ static const spi_conf_t spi_config[] = { -#ifdef SPI0_CTRL +#if defined(SPI0_CTRL) { .ctrl = SPI0_CTRL, .sck = SPI0_SCK, @@ -304,7 +318,7 @@ static const spi_conf_t spi_config[] = { .cs = SPI0_CS0, }, #endif -#ifdef SPI1_CTRL +#if defined(SPI1_CTRL) && (SOC_SPI_PERIPH_NUM > 2) { .ctrl = SPI1_CTRL, .sck = SPI1_SCK, @@ -331,13 +345,6 @@ static const spi_conf_t spi_config[] = { * @{ */ -#ifndef UART0_TXD -#define UART0_TXD (GPIO43) /**< TxD of UART_DEV(0) used on all ESP32-S3 boards */ -#endif -#ifndef UART0_RXD -#define UART0_RXD (GPIO44) /**< RxD of UART_DEV(0) used on all ESP32-S3 boards */ -#endif - /** * @brief Static array with configuration for declared UART devices */ @@ -346,13 +353,13 @@ static const uart_conf_t uart_config[] = { .txd = UART0_TXD, .rxd = UART0_RXD, }, -#if defined(UART1_TXD) && defined(UART1_RXD) +#if (SOC_UART_NUM > 1) && defined(UART1_TXD) && defined(UART1_RXD) { .txd = UART1_TXD, .rxd = UART1_RXD, }, #endif -#if defined(UART2_TXD) && defined(UART2_RXD) +#if (SOC_UART_NUM > 2) && defined(UART2_TXD) && defined(UART2_RXD) { .txd = UART2_TXD, .rxd = UART2_RXD, @@ -371,9 +378,9 @@ static const uart_conf_t uart_config[] = { #define UART_NUMOF ARRAY_SIZE(uart_config) /** @} */ +#ifdef SOC_USB_OTG_SUPPORTED /** * @name USB device configuration - * * @{ */ @@ -396,6 +403,7 @@ static const dwc2_usb_otg_fshs_config_t dwc2_usb_otg_fshs_config[] = { #define USBDEV_NUMOF ARRAY_SIZE(dwc2_usb_otg_fshs_config) /** @} */ +#endif /* SOC_USB_OTG_SUPPORTED */ #ifdef __cplusplus } /* end extern "C" */