Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/esp32: add support for ESP32-S2 #18506

Merged
merged 10 commits into from
Aug 30, 2022
1 change: 1 addition & 0 deletions .murdock
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ esp32c3-ci
esp32c3-devkit
esp32s3-ci
esp32s3-devkit
esp32s2-devkit
esp8266-ci
esp8266-esp-12x
hamilton
Expand Down
20 changes: 20 additions & 0 deletions boards/common/esp32s2/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2020 HAW Hamburg
# 2022 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.

config BOARD_COMMON_ESP32S2
bool
select HAS_PERIPH_UART
select HAVE_SAUL_GPIO

config MODULE_BOARDS_COMMON_ESP32S2
bool
depends on TEST_KCONFIG
depends on BOARD_COMMON_ESP32S2
depends on HAS_ARCH_ESP32
default y
help
Common ESP32-S2 boards code.
3 changes: 3 additions & 0 deletions boards/common/esp32s2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = boards_common_esp32s2

include $(RIOTBASE)/Makefile.base
5 changes: 5 additions & 0 deletions boards/common/esp32s2/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
USEMODULE += boards_common_esp32s2

ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
5 changes: 5 additions & 0 deletions boards/common/esp32s2/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CPU = esp32
CPU_FAM = esp32s2

# additional features provided by all boards is at least one UART
FEATURES_PROVIDED += periph_uart
5 changes: 5 additions & 0 deletions boards/common/esp32s2/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INCLUDES += -I$(RIOTBOARD)/common/esp32s2/include

# configure the serial interface
PORT_LINUX ?= /dev/ttyUSB0
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
99 changes: 99 additions & 0 deletions boards/common/esp32s2/board_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (C) 2021 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.
*/

/**
* @ingroup boards_common_esp32s2
* @{
*
* @file
* @brief Common declarations and functions for all ESP32-S2 boards.
*
* This file contains default declarations and functions that are valid
* for all ESP32-S2 boards.
*
* @author Gunar Schorcht <[email protected]>
*/

#include "board.h"
#include "esp_common.h"
#include "kernel_defines.h"
#include "log.h"
#include "periph/gpio.h"
#include "periph/spi.h"

#ifdef __cplusplus
extern "C" {
#endif

extern void adc_print_config(void);
extern void dac_print_config(void);
extern void pwm_print_config(void);
extern void i2c_print_config(void);
extern void spi_print_config(void);
extern void uart_print_config(void);
extern void can_print_config(void);

void print_board_config(void)
{
ets_printf("\nBoard configuration:\n");

#if IS_USED(MODULE_PERIPH_ADC)
adc_print_config();
#endif
#if IS_USED(MODULE_PERIPH_DAC)
dac_print_config();
#endif
#if IS_USED(MODULE_PERIPH_PWM)
pwm_print_config();
#endif
#if IS_USED(MODULE_PERIPH_I2C)
i2c_print_config();
#endif
#if IS_USED(MODULE_PERIPH_SPI)
spi_print_config();
#endif
#if IS_USED(MODULE_PERIPH_UART)
uart_print_config();
#endif

#if IS_USED(MODULE_PERIPH_CAN)
can_print_config();
#endif

ets_printf("\tLED\t\tpins=[ ");
#ifdef LED0_PIN
ets_printf("%d ", LED0_PIN);
#endif
#ifdef LED1_PIN
ets_printf("%d ", LED1_PIN);
#endif
#ifdef LED2_PIN
ets_printf("%d ", LED2_PIN);
#endif
ets_printf("]\n");

ets_printf("\tBUTTONS\t\tpins=[ ");
#ifdef BUTTON0_PIN
ets_printf("%d ", BUTTON0_PIN);
#endif
#ifdef BUTTON2_PIN
ets_printf("%d ", BUTTON1_PIN);
#endif
#ifdef BUTTON3_PIN
ets_printf("%d ", BUTTON2_PIN);
#endif
ets_printf("]\n");

ets_printf("\n");
}

#ifdef __cplusplus
} /* end extern "C" */
#endif

/** @} */
28 changes: 28 additions & 0 deletions boards/common/esp32s2/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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_esp32s2 ESP32-S2 Common
* @ingroup boards_common
* @ingroup boards_esp32s2
* @brief Definitions and configurations that are common for
* all ESP32-S2 boards.
*
* For detailed information about the ESP32-S2, configuring and compiling RIOT
* for ESP32-S2 boards, please refer \ref esp32_riot.
*/

/**
* @defgroup boards_esp32s2 ESP32-S2 Boards
* @ingroup boards
* @brief This group of boards contains the documentation of ESP32-S2 boards.
*
* @note For detailed information about the ESP32-S2 SoC, the tool chain
* as well as configuring and compiling RIOT for ESP32-S2 boards,
* see \ref esp32_riot.
*/
72 changes: 72 additions & 0 deletions boards/common/esp32s2/include/arduino_board_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2022 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.
*/

/**
* @ingroup boards_common_esp32s2
* @{
*
* @file
* @brief Common board definitions for the Arduino API
*
* @author Gunar Schorcht <[email protected]>
*/

#ifndef ARDUINO_BOARD_COMMON_H
#define ARDUINO_BOARD_COMMON_H

#include "arduino_pinmap.h"

#ifdef __cplusplus
extern "C"
{
#endif

/**
* @brief Look-up table for the Arduino's digital pins
*/
static const gpio_t arduino_pinmap[] = {
ARDUINO_PIN_0,
ARDUINO_PIN_1,
ARDUINO_PIN_2,
ARDUINO_PIN_3,
ARDUINO_PIN_4,
ARDUINO_PIN_5,
ARDUINO_PIN_6,
ARDUINO_PIN_7,
ARDUINO_PIN_8,
ARDUINO_PIN_9,
ARDUINO_PIN_10,
ARDUINO_PIN_11,
ARDUINO_PIN_12,
ARDUINO_PIN_13,
ARDUINO_PIN_A0,
ARDUINO_PIN_A1,
ARDUINO_PIN_A2,
ARDUINO_PIN_A3,
ARDUINO_PIN_A4,
ARDUINO_PIN_A5
};

/**
* @brief Look-up table for the Arduino's analog pins
*/
static const adc_t arduino_analog_map[] = {
ARDUINO_PIN_A0,
ARDUINO_PIN_A1,
ARDUINO_PIN_A2,
ARDUINO_PIN_A3,
ARDUINO_PIN_A4,
ARDUINO_PIN_A5
};

#ifdef __cplusplus
}
#endif

#endif /* ARDUINO_BOARD_COMMON_H */
/** @} */
126 changes: 126 additions & 0 deletions boards/common/esp32s2/include/board_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* Copyright (C) 2022 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.
*/

/**
* @ingroup boards_common_esp32s2
* @brief Common board definitions for ESP32-S2 boards.
*
* This file contains board configurations that are valid for all
* ESP32-S2 boards.
*
* For detailed information about the configuration of ESP32-S2 boards, see
* section \ref esp32_peripherals "Common Peripherals".
*
* @author Gunar Schorcht <[email protected]>
* @file
* @{
*/

#ifndef BOARD_COMMON_H
#define BOARD_COMMON_H

#include <stdint.h>

#include "cpu.h"
#include "periph_conf.h"
#if MODULE_ARDUINO
#include "arduino_pinmap.h"
#endif

#include "periph/gpio.h"
#include "sdkconfig.h"

#if MODULE_MTD
#include "mtd.h"
#endif

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name LED configuration (three predefined LEDs at maximum)
*
* @note LEDx_ACTIVE value must be declared in board configuration.
* @{
*/
#if defined(LED0_PIN) || DOXYGEN
#define LED0_MASK (BIT(LED0_PIN))
#define LED0_ON (gpio_write(LED0_PIN, LED0_ACTIVE))
#define LED0_OFF (gpio_write(LED0_PIN, !LED0_ACTIVE))
#define LED0_TOGGLE (gpio_toggle(LED0_PIN))
#endif

#if defined(LED1_PIN) || DOXYGEN
#define LED1_MASK (BIT(LED1_PIN))
#define LED1_ON (gpio_write(LED1_PIN, LED1_ACTIVE))
#define LED1_OFF (gpio_write(LED1_PIN, !LED1_ACTIVE))
#define LED1_TOGGLE (gpio_toggle(LED1_PIN))
#endif

#if defined(LED2_PIN) || DOXYGEN
#define LED2_MASK (BIT(LED2_PIN))
#define LED2_ON (gpio_write(LED2_PIN, LED2_ACTIVE))
#define LED2_OFF (gpio_write(LED2_PIN, !LED2_ACTIVE))
#define LED2_TOGGLE (gpio_toggle(LED2_PIN))
#endif
/** @} */

/**
* @name STDIO configuration
* @{
*/
/**< Default baudrate of UART for stdio */
#ifndef STDIO_UART_BAUDRATE
#define STDIO_UART_BAUDRATE (115200)
#endif
/** @} */

#if MODULE_MTD || DOXYGEN
/**
* @name MTD system drive configuration
*
* Built-in SPI flash memory is used as MTD system drive.
* @{
*/

/**
* @brief MTD drive start address in SPI flash memory
*
* Defines the start address of the MTD system device in the SPI
* flash memory. It can be overridden by \ref esp32_application_specific_configurations
* "application-specific board configuration"
*
* If the MTD start address is not defined or is 0, the first possible
* multiple of 0x100000 (1 MByte) is used in free SPI flash memory,
* which was determined from the partition table.
*/
#ifndef SPI_FLASH_DRIVE_START
#define SPI_FLASH_DRIVE_START 0
#endif

/** Default MTD drive definition */
#define MTD_0 mtd0

/** Pointer to the default MTD drive structure */
extern mtd_dev_t *mtd0;

/** @} */
#endif /* MODULE_MTD || DOXYGEN */

/**
* @brief Print the board configuration in a human readable format
*/
void print_board_config(void);

#ifdef __cplusplus
} /* end extern "C" */
#endif

#endif /* BOARD_COMMON_H */
/** @} */
Loading