mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
19432: boards/esp32: deduplication in common ESP32x board definitions r=benpicco a=gschorcht ### Contribution description The PR reduced code duplication in `boards/common/esp32*`. The PR moves the header files from `boards/common/esp32s3/include` that can be used for all types of ESP32x SoCs to a new common ESP32x board definition which is then included by all common ESP32x board definitions. ### Testing procedure Green CI. ### Issues/PRs references 19461: drivers/enc28j60: fix ISR routine and bth r=benpicco a=peteut Co-authored-by: Gunar Schorcht <gunar@schorcht.net> Co-authored-by: Alain Péteut <alain.peteut@yahoo.com>
This commit is contained in:
commit
99b13cbb1b
@ -6,9 +6,7 @@
|
||||
|
||||
config BOARD_COMMON_ESP32
|
||||
bool
|
||||
select HAS_PERIPH_UART
|
||||
|
||||
select HAVE_SAUL_GPIO
|
||||
select BOARD_COMMON_ESP32X
|
||||
|
||||
config MODULE_BOARDS_COMMON_ESP32
|
||||
bool
|
||||
@ -18,3 +16,5 @@ config MODULE_BOARDS_COMMON_ESP32
|
||||
default y
|
||||
help
|
||||
Common ESP32 boards code.
|
||||
|
||||
source "$(RIOTBOARD)/common/esp32x/Kconfig"
|
||||
|
@ -1,3 +1,5 @@
|
||||
MODULE = boards_common_esp32
|
||||
|
||||
DIRS = $(RIOTBOARD)/common/esp32x
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -1,5 +1,3 @@
|
||||
USEMODULE += boards_common_esp32
|
||||
|
||||
ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||
USEMODULE += saul_gpio
|
||||
endif
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.dep
|
||||
|
@ -1,5 +1,3 @@
|
||||
CPU = esp32
|
||||
CPU_FAM = esp32
|
||||
|
||||
# additional features provided by all boards is at least one UART
|
||||
FEATURES_PROVIDED += periph_uart
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.features
|
||||
|
@ -1,3 +1,3 @@
|
||||
# configure the serial interface
|
||||
PORT_LINUX ?= /dev/ttyUSB0
|
||||
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
|
||||
INCLUDES += -I$(RIOTBOARD)/common/esp32/include
|
||||
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.include
|
||||
|
@ -20,8 +20,7 @@
|
||||
/**
|
||||
* @defgroup boards_esp32 ESP32 Boards
|
||||
* @ingroup boards
|
||||
* @brief This group of boards contains the documentation
|
||||
* defined ESP32 boards.
|
||||
* @brief This group of boards contains the documentation of ESP32 boards.
|
||||
*
|
||||
* @note For detailed information about the ESP32 SoC, the tool chain
|
||||
* as well as configuring and compiling RIOT for ESP32 boards,
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_esp32
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Common board for the Arduino API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
*/
|
||||
|
||||
#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 */
|
||||
/** @} */
|
@ -1,168 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_esp32
|
||||
* @brief Board definitions that are common for all ESP32 boards.
|
||||
*
|
||||
* This file contains board configurations that are valid for all ESP32.
|
||||
*
|
||||
* For detailed information about the configuration of ESP32 boards, see
|
||||
* section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef BOARD_COMMON_H
|
||||
#define BOARD_COMMON_H
|
||||
|
||||
/* not required when compiling ESP32 vendor code parts */
|
||||
#ifndef ESP32_IDF_CODE
|
||||
|
||||
#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 External clock crystal frequency (MHz)
|
||||
*
|
||||
* Most boards use a 40MHz crystal, including all those based on Espressif's
|
||||
* WROOM-32 and WROVER-32 modules. Those that don't, like the SparkFun ESP32
|
||||
* Thing (26MHz), must define ESP32_XTAL_FREQ appropriately in their board
|
||||
* configuration.
|
||||
*
|
||||
* An obvious side effect of a mismatch is that the UART won't sync and the
|
||||
* development terminal will show garbage instead of log output.
|
||||
* @{
|
||||
*/
|
||||
#ifndef ESP32_XTAL_FREQ
|
||||
#define ESP32_XTAL_FREQ (40)
|
||||
#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;
|
||||
|
||||
/**
|
||||
* @brief MTD offset for SD Card interfaces
|
||||
*
|
||||
* MTD_1 is used for SD Card.
|
||||
*/
|
||||
#ifndef CONFIG_SDCARD_GENERIC_MTD_OFFSET
|
||||
#define CONFIG_SDCARD_GENERIC_MTD_OFFSET 1
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#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
|
||||
|
||||
#else /* ESP32_IDF_CODE */
|
||||
|
||||
#ifndef DOXYGEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* DOXYGEN */
|
||||
#endif /* ESP32_IDF_CODE */
|
||||
#endif /* BOARD_COMMON_H */
|
||||
/** @} */
|
52
boards/common/esp32/include/board_common_esp32.h
Normal file
52
boards/common/esp32/include/board_common_esp32.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_esp32
|
||||
* @brief Board definitions that are common for all ESP32 boards.
|
||||
*
|
||||
* This file contains board configurations that are valid for all ESP32.
|
||||
*
|
||||
* For detailed information about the configuration of ESP32 boards, see
|
||||
* section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef BOARD_COMMON_ESP32_H
|
||||
#define BOARD_COMMON_ESP32_H
|
||||
|
||||
#include "board_common.h"
|
||||
|
||||
/**
|
||||
* @brief External clock crystal frequency (MHz)
|
||||
*
|
||||
* Most boards use a 40MHz crystal, including all those based on Espressif's
|
||||
* WROOM-32 and WROVER-32 modules. Those that don't, like the SparkFun ESP32
|
||||
* Thing (26MHz), must define ESP32_XTAL_FREQ appropriately in their board
|
||||
* configuration.
|
||||
*
|
||||
* An obvious side effect of a mismatch is that the UART won't sync and the
|
||||
* development terminal will show garbage instead of log output.
|
||||
*/
|
||||
#ifndef ESP32_XTAL_FREQ
|
||||
#define ESP32_XTAL_FREQ (40)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* BOARD_COMMON_ESP32_H */
|
||||
/** @} */
|
@ -1,378 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_esp32
|
||||
* @brief Common declarations of ESP32 periphery for all ESP32 boards
|
||||
*
|
||||
* This file contains peripheral configurations that are valid for all ESP32.
|
||||
*
|
||||
* For detailed information about the configuration of ESP32 boards, see
|
||||
* section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef PERIPH_CONF_COMMON_H
|
||||
#define PERIPH_CONF_COMMON_H
|
||||
|
||||
/* include periph_cpu.h to make it visible in any case */
|
||||
#include "periph_cpu.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name ADC configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Declaration of GPIOs that can be used as ADC channels
|
||||
*
|
||||
* ADC_GPIOS is defined in board-specific peripheral configuration. Since
|
||||
* ADC_GPIOS must be defined even if there are no ADC channels, an empty
|
||||
* list definition is done here as fallback configuration.
|
||||
*/
|
||||
#ifndef ADC_GPIOS
|
||||
#define ADC_GPIOS { }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with declared ADC channels
|
||||
*/
|
||||
static const gpio_t adc_channels[] = ADC_GPIOS;
|
||||
|
||||
/**
|
||||
* @brief Number of GPIOs declared as ADC channels
|
||||
*
|
||||
* The number of GPIOs that are declared as ADC channels is determined from
|
||||
* the ADC_GPIOS definition.
|
||||
*
|
||||
* @note ADC_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define ADC_NUMOF ARRAY_SIZE(adc_channels)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name DAC configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Declaration of GPIOs that can be used as DAC channels
|
||||
*
|
||||
* DAC_GPIOS is defined in board-specific peripheral configuration. Since
|
||||
* DAC_GPIOS must be defined even if there are no DAC channels, an empty
|
||||
* list definition is done here as fallback configuration.
|
||||
*/
|
||||
#ifndef DAC_GPIOS
|
||||
#define DAC_GPIOS { }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with declared DAC channels
|
||||
*/
|
||||
static const gpio_t dac_channels[] = DAC_GPIOS;
|
||||
|
||||
/**
|
||||
* @brief Number of GPIOs declared as DAC channels
|
||||
*
|
||||
* The number of GPIOs that are declared as DAC channels is determined from
|
||||
* the DAC_GPIOS definition.
|
||||
*
|
||||
* @note DAC_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define DAC_NUMOF ARRAY_SIZE(dac_channels)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name I2C configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(I2C0_SCL) && !defined(I2C0_SCL_PULLUP)
|
||||
/** 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)
|
||||
/** Define SCL pullup enabled by default */
|
||||
#define I2C1_SCL_PULLUP true
|
||||
#endif
|
||||
#if defined(I2C1_SDA) && !defined(I2C1_SDA_PULLUP)
|
||||
/** Define SDA pullup enabled by default */
|
||||
#define I2C1_SDA_PULLUP true
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with configuration for declared I2C devices
|
||||
*/
|
||||
static const i2c_conf_t i2c_config[] = {
|
||||
#if defined(I2C0_SCL) && defined(I2C0_SDA) && defined(I2C0_SPEED)
|
||||
{
|
||||
.module = PERIPH_I2C0_MODULE,
|
||||
.speed = I2C0_SPEED,
|
||||
.scl = I2C0_SCL,
|
||||
.sda = I2C0_SDA,
|
||||
.scl_pullup = I2C0_SCL_PULLUP,
|
||||
.sda_pullup = I2C0_SCL_PULLUP,
|
||||
},
|
||||
#endif
|
||||
#if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED)
|
||||
{
|
||||
.module = PERIPH_I2C1_MODULE,
|
||||
.speed = I2C1_SPEED,
|
||||
.scl = I2C1_SCL,
|
||||
.sda = I2C1_SDA,
|
||||
.scl_pullup = I2C1_SCL_PULLUP,
|
||||
.sda_pullup = I2C1_SCL_PULLUP,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of I2C interfaces
|
||||
*
|
||||
* The number of I2C interfaces is determined from board-specific peripheral
|
||||
* definitions of I2Cn_SPEED, I2Cn_SCK, and I2Cn_SDA.
|
||||
*
|
||||
* @note I2C_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name PWM configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM0_GPIOS
|
||||
static const gpio_t pwm0_gpios[] = PWM0_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM1_GPIOS
|
||||
static const gpio_t pwm1_gpios[] = PWM1_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM2_GPIOS
|
||||
static const gpio_t pwm2_gpios[] = PWM2_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM3_GPIOS
|
||||
static const gpio_t pwm3_gpios[] = PWM3_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PWM device configuration based on defined PWM channel GPIOs
|
||||
*/
|
||||
static const pwm_config_t pwm_config[] =
|
||||
{
|
||||
#ifdef PWM0_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
.timer = LEDC_TIMER_0,
|
||||
.ch_numof = ARRAY_SIZE(pwm0_gpios),
|
||||
.gpios = pwm0_gpios,
|
||||
},
|
||||
#endif
|
||||
#ifdef PWM1_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
||||
.group = LEDC_HIGH_SPEED_MODE,
|
||||
#else
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
#endif
|
||||
.timer = LEDC_TIMER_1,
|
||||
.ch_numof = ARRAY_SIZE(pwm1_gpios),
|
||||
.gpios = pwm1_gpios,
|
||||
},
|
||||
#endif
|
||||
#ifdef PWM2_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
.timer = LEDC_TIMER_2,
|
||||
.ch_numof = ARRAY_SIZE(pwm2_gpios),
|
||||
.gpios = pwm2_gpios,
|
||||
},
|
||||
#endif
|
||||
#ifdef PWM3_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
||||
.group = LEDC_HIGH_SPEED_MODE,
|
||||
#else
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
#endif
|
||||
.timer = LEDC_TIMER_3,
|
||||
.ch_numof = ARRAY_SIZE(pwm3_gpios),
|
||||
.gpios = pwm3_gpios,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of PWM devices
|
||||
*
|
||||
* The number of PWM devices is determined from the PWM device configuration.
|
||||
*
|
||||
* @note PWM_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define PWM_NUMOF ARRAY_SIZE(pwm_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name RMT configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief RMT channel configuration
|
||||
*
|
||||
* For the moment, the only RMT channel configuration used is for the WS2812
|
||||
* driver. To override this default configuration by a board definition, add
|
||||
* ```
|
||||
* #define HAVE_RMT_CHANNEL_CONFIG
|
||||
* ```
|
||||
* before including this file and define an according `rmt_channel_config`
|
||||
* after including this file.
|
||||
*/
|
||||
#ifndef HAVE_RMT_CHANNEL_CONFIG
|
||||
static const rmt_channel_config_t rmt_channel_config[] = {
|
||||
#ifdef WS281X_PARAM_PIN
|
||||
{ 0, WS281X_PARAM_PIN },
|
||||
#else
|
||||
/* default for boards that don't define WS281X_PARAM_PIN */
|
||||
{ 0, GPIO0 },
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of RMT channels
|
||||
*/
|
||||
#define RMT_CH_NUMOF ARRAY_SIZE(rmt_channel_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name SPI configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Static array with configuration for declared SPI devices
|
||||
*/
|
||||
static const spi_conf_t spi_config[] = {
|
||||
#ifdef SPI0_CTRL
|
||||
{
|
||||
.ctrl = SPI0_CTRL,
|
||||
.sck = SPI0_SCK,
|
||||
.mosi = SPI0_MOSI,
|
||||
.miso = SPI0_MISO,
|
||||
.cs = SPI0_CS0,
|
||||
},
|
||||
#endif
|
||||
#ifdef SPI1_CTRL
|
||||
{
|
||||
.ctrl = SPI1_CTRL,
|
||||
.sck = SPI1_SCK,
|
||||
.mosi = SPI1_MOSI,
|
||||
.miso = SPI1_MISO,
|
||||
.cs = SPI1_CS0,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of SPI interfaces
|
||||
*
|
||||
* The number of SPI interfaces is determined from board-specific peripheral
|
||||
* definitions of SPIn_*.
|
||||
*
|
||||
* @note SPI_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define SPI_NUMOF ARRAY_SIZE(spi_config)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name UART configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef UART0_TXD
|
||||
#define UART0_TXD (GPIO1) /**< TxD of UART_DEV(0) used on all ESP32 boards */
|
||||
#endif
|
||||
#ifndef UART0_RXD
|
||||
#define UART0_RXD (GPIO3) /**< RxD of UART_DEV(0) used on all ESP32 boards */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with configuration for declared UART devices
|
||||
*/
|
||||
static const uart_conf_t uart_config[] = {
|
||||
{
|
||||
.txd = UART0_TXD,
|
||||
.rxd = UART0_RXD,
|
||||
},
|
||||
#if defined(UART1_TXD) && defined(UART1_RXD)
|
||||
{
|
||||
.txd = UART1_TXD,
|
||||
.rxd = UART1_RXD,
|
||||
},
|
||||
#endif
|
||||
#if defined(UART2_TXD) && defined(UART2_RXD)
|
||||
{
|
||||
.txd = UART2_TXD,
|
||||
.rxd = UART2_RXD,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of UART interfaces
|
||||
*
|
||||
* The number of UART interfaces is determined from board-specific peripheral
|
||||
* definitions of UARTn_*.
|
||||
*
|
||||
* @note UART_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define UART_NUMOF ARRAY_SIZE(uart_config)
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* PERIPH_CONF_COMMON_H */
|
||||
/** @} */
|
48
boards/common/esp32/include/periph_conf_common_esp32.h
Normal file
48
boards/common/esp32/include/periph_conf_common_esp32.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_esp32
|
||||
* @brief Common declarations of ESP32 periphery for all ESP32 boards
|
||||
*
|
||||
* This file contains peripheral configurations that are valid for all ESP32.
|
||||
*
|
||||
* For detailed information about the configuration of ESP32 boards, see
|
||||
* section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef PERIPH_CONF_COMMON_ESP32_H
|
||||
#define PERIPH_CONF_COMMON_ESP32_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name UART configuration
|
||||
* @{
|
||||
*/
|
||||
#ifndef UART0_TXD
|
||||
#define UART0_TXD (GPIO1) /**< TxD of UART_DEV(0) used on all ESP32 boards */
|
||||
#endif
|
||||
|
||||
#ifndef UART0_RXD
|
||||
#define UART0_RXD (GPIO3) /**< RxD of UART_DEV(0) used on all ESP32 boards */
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* PERIPH_CONF_COMMON_ESP32_H */
|
||||
/** @} */
|
@ -7,8 +7,7 @@
|
||||
|
||||
config BOARD_COMMON_ESP32C3
|
||||
bool
|
||||
select HAS_PERIPH_UART
|
||||
select HAVE_SAUL_GPIO
|
||||
select BOARD_COMMON_ESP32X
|
||||
|
||||
config MODULE_BOARDS_COMMON_ESP32C3
|
||||
bool
|
||||
@ -18,3 +17,5 @@ config MODULE_BOARDS_COMMON_ESP32C3
|
||||
default y
|
||||
help
|
||||
Common ESP32-C3 boards code.
|
||||
|
||||
source "$(RIOTBOARD)/common/esp32x/Kconfig"
|
||||
|
@ -1,3 +1,5 @@
|
||||
MODULE = boards_common_esp32c3
|
||||
|
||||
DIRS = $(RIOTBOARD)/common/esp32x
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -1,5 +1,3 @@
|
||||
USEMODULE += boards_common_esp32c3
|
||||
|
||||
ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||
USEMODULE += saul_gpio
|
||||
endif
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.dep
|
||||
|
@ -1,5 +1,3 @@
|
||||
CPU = esp32
|
||||
CPU_FAM = esp32c3
|
||||
|
||||
# additional features provided by all boards is at least one UART
|
||||
FEATURES_PROVIDED += periph_uart
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.features
|
||||
|
@ -1,5 +1,3 @@
|
||||
INCLUDES += -I$(RIOTBOARD)/common/esp32c3/include
|
||||
|
||||
# configure the serial interface
|
||||
PORT_LINUX ?= /dev/ttyUSB0
|
||||
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.include
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* 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_esp32c3
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Common declarations and functions for all ESP32-C3 boards.
|
||||
*
|
||||
* This file contains default declarations and functions that are valid
|
||||
* for all ESP32-C3 boards.
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
/** @} */
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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_esp32c3
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Common board definitions for the Arduino API
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
*/
|
||||
|
||||
#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 */
|
||||
/** @} */
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* 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_esp32c3
|
||||
* @brief Common board definitions for ESP32-C3 boards.
|
||||
*
|
||||
* This file contains board configurations that are valid for all
|
||||
* ESP32-C3 boards.
|
||||
*
|
||||
* For detailed information about the configuration of ESP32-C3 boards, see
|
||||
* section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @brief MTD offset for SD Card interfaces
|
||||
*
|
||||
* MTD_1 is used for SD Card.
|
||||
*/
|
||||
#ifndef CONFIG_SDCARD_GENERIC_MTD_OFFSET
|
||||
#define CONFIG_SDCARD_GENERIC_MTD_OFFSET 1
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#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 */
|
||||
/** @} */
|
@ -1,354 +0,0 @@
|
||||
/*
|
||||
* 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_esp32c3
|
||||
* @brief Common peripheral configurations for ESP32-C3 boards
|
||||
*
|
||||
* This file contains the peripheral configurations that are valid for all
|
||||
* ESP32-C3 boards.
|
||||
*
|
||||
* For detailed information about the peripheral configuration for ESP32-C3
|
||||
* boards, see section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef PERIPH_CONF_COMMON_H
|
||||
#define PERIPH_CONF_COMMON_H
|
||||
|
||||
/* include periph_cpu.h to make it visible in any case */
|
||||
#include "periph_cpu.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name ADC configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Declaration of GPIOs that can be used as ADC channels
|
||||
*
|
||||
* ADC_GPIOS is defined in board-specific peripheral configuration. Since
|
||||
* ADC_GPIOS must be defined even if there are no ADC channels, an empty
|
||||
* list definition is done here as fallback configuration.
|
||||
*/
|
||||
#ifndef ADC_GPIOS
|
||||
#define ADC_GPIOS { }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with declared ADC channels
|
||||
*/
|
||||
static const gpio_t adc_channels[] = ADC_GPIOS;
|
||||
|
||||
/**
|
||||
* @brief Number of GPIOs declared as ADC channels
|
||||
*
|
||||
* The number of GPIOs that are declared as ADC channels is determined from
|
||||
* the ADC_GPIOS definition.
|
||||
*
|
||||
* @note ADC_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define ADC_NUMOF ARRAY_SIZE(adc_channels)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name DAC configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Declaration of GPIOs that can be used as DAC channels
|
||||
*
|
||||
* DAC_GPIOS is defined in board-specific peripheral configuration. Since
|
||||
* DAC_GPIOS must be defined even if there are no DAC channels, an empty
|
||||
* list definition is done here as fallback configuration.
|
||||
*/
|
||||
#ifndef DAC_GPIOS
|
||||
#define DAC_GPIOS { }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with declared DAC channels
|
||||
*/
|
||||
static const gpio_t dac_channels[] = DAC_GPIOS;
|
||||
|
||||
/**
|
||||
* @brief Number of GPIOs declared as DAC channels
|
||||
*
|
||||
* The number of GPIOs that are declared as DAC channels is determined from
|
||||
* the DAC_GPIOS definition.
|
||||
*
|
||||
* @note DAC_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define DAC_NUMOF ARRAY_SIZE(dac_channels)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name I2C configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(I2C0_SCL) && !defined(I2C0_SCL_PULLUP)
|
||||
/** 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
|
||||
|
||||
/**
|
||||
* @brief Static array with configuration for declared I2C devices
|
||||
*/
|
||||
static const i2c_conf_t i2c_config[] = {
|
||||
#if defined(I2C0_SCL) && defined(I2C0_SDA) && defined(I2C0_SPEED)
|
||||
{
|
||||
.module = PERIPH_I2C0_MODULE,
|
||||
.speed = I2C0_SPEED,
|
||||
.scl = I2C0_SCL,
|
||||
.sda = I2C0_SDA,
|
||||
.scl_pullup = I2C0_SCL_PULLUP,
|
||||
.sda_pullup = I2C0_SCL_PULLUP,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of I2C interfaces
|
||||
*
|
||||
* The number of I2C interfaces is determined from board-specific peripheral
|
||||
* definitions of I2Cn_SPEED, I2Cn_SCK, and I2Cn_SDA.
|
||||
*
|
||||
* @note I2C_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name PWM configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM0_GPIOS
|
||||
static const gpio_t pwm0_gpios[] = PWM0_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM1_GPIOS
|
||||
static const gpio_t pwm1_gpios[] = PWM1_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM2_GPIOS
|
||||
static const gpio_t pwm2_gpios[] = PWM2_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM3_GPIOS
|
||||
static const gpio_t pwm3_gpios[] = PWM3_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PWM device configuration based on defined PWM channel GPIOs
|
||||
*/
|
||||
static const pwm_config_t pwm_config[] =
|
||||
{
|
||||
#ifdef PWM0_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
.timer = LEDC_TIMER_0,
|
||||
.ch_numof = ARRAY_SIZE(pwm0_gpios),
|
||||
.gpios = pwm0_gpios,
|
||||
},
|
||||
#endif
|
||||
#ifdef PWM1_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
||||
.group = LEDC_HIGH_SPEED_MODE,
|
||||
#else
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
#endif
|
||||
.timer = LEDC_TIMER_1,
|
||||
.ch_numof = ARRAY_SIZE(pwm1_gpios),
|
||||
.gpios = pwm1_gpios,
|
||||
},
|
||||
#endif
|
||||
#ifdef PWM2_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
.timer = LEDC_TIMER_2,
|
||||
.ch_numof = ARRAY_SIZE(pwm2_gpios),
|
||||
.gpios = pwm2_gpios,
|
||||
},
|
||||
#endif
|
||||
#ifdef PWM3_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
||||
.group = LEDC_HIGH_SPEED_MODE,
|
||||
#else
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
#endif
|
||||
.timer = LEDC_TIMER_3,
|
||||
.ch_numof = ARRAY_SIZE(pwm3_gpios),
|
||||
.gpios = pwm3_gpios,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of PWM devices
|
||||
*
|
||||
* The number of PWM devices is determined from the PWM device configuration.
|
||||
*
|
||||
* @note PWM_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define PWM_NUMOF ARRAY_SIZE(pwm_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name RMT configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief RMT channel configuration
|
||||
*
|
||||
* For the moment, the only RMT channel configuration used is for the WS2812
|
||||
* driver. To override this default configuration by a board definition, add
|
||||
* ```
|
||||
* #define HAVE_RMT_CHANNEL_CONFIG
|
||||
* ```
|
||||
* before including this file and define an according `rmt_channel_config`
|
||||
* after including this file.
|
||||
*/
|
||||
#ifndef HAVE_RMT_CHANNEL_CONFIG
|
||||
static const rmt_channel_config_t rmt_channel_config[] = {
|
||||
#ifdef WS281X_PARAM_PIN
|
||||
{ 0, WS281X_PARAM_PIN },
|
||||
#else
|
||||
/* default for boards that don't define WS281X_PARAM_PIN */
|
||||
{ 0, GPIO0 },
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of RMT channels
|
||||
*/
|
||||
#define RMT_CH_NUMOF ARRAY_SIZE(rmt_channel_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name SPI configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Static array with configuration for declared SPI devices
|
||||
*/
|
||||
static const spi_conf_t spi_config[] = {
|
||||
#ifdef SPI0_CTRL
|
||||
{
|
||||
.ctrl = SPI0_CTRL,
|
||||
.sck = SPI0_SCK,
|
||||
.mosi = SPI0_MOSI,
|
||||
.miso = SPI0_MISO,
|
||||
.cs = SPI0_CS0,
|
||||
},
|
||||
#endif
|
||||
#ifdef SPI1_CTRL
|
||||
{
|
||||
.ctrl = SPI1_CTRL,
|
||||
.sck = SPI1_SCK,
|
||||
.mosi = SPI1_MOSI,
|
||||
.miso = SPI1_MISO,
|
||||
.cs = SPI1_CS0,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of SPI interfaces
|
||||
*
|
||||
* The number of SPI interfaces is determined from board-specific peripheral
|
||||
* definitions of SPIn_*.
|
||||
*
|
||||
* @note SPI_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define SPI_NUMOF ARRAY_SIZE(spi_config)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name UART configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef UART0_TXD
|
||||
#define UART0_TXD (GPIO21) /**< TxD of UART_DEV(0) used on all ESP32-C3 boards */
|
||||
#endif
|
||||
#ifndef UART0_RXD
|
||||
#define UART0_RXD (GPIO20) /**< RxD of UART_DEV(0) used on all ESP32-C3 boards */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with configuration for declared UART devices
|
||||
*/
|
||||
static const uart_conf_t uart_config[] = {
|
||||
{
|
||||
.txd = UART0_TXD,
|
||||
.rxd = UART0_RXD,
|
||||
},
|
||||
#if defined(UART1_TXD) && defined(UART1_RXD)
|
||||
{
|
||||
.txd = UART1_TXD,
|
||||
.rxd = UART1_RXD,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of UART interfaces
|
||||
*
|
||||
* The number of UART interfaces is determined from board-specific peripheral
|
||||
* definitions of UARTn_*.
|
||||
*
|
||||
* @note UART_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define UART_NUMOF ARRAY_SIZE(uart_config)
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* PERIPH_CONF_COMMON_H */
|
||||
/** @} */
|
49
boards/common/esp32c3/include/periph_conf_common_esp32c3.h
Normal file
49
boards/common/esp32c3/include/periph_conf_common_esp32c3.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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_esp32c3
|
||||
* @brief Common peripheral configurations for ESP32-C3 boards
|
||||
*
|
||||
* This file contains the peripheral configurations that are valid for all
|
||||
* ESP32-C3 boards.
|
||||
*
|
||||
* For detailed information about the peripheral configuration for ESP32-C3
|
||||
* boards, see section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef PERIPH_CONF_COMMON_ESP32C3_H
|
||||
#define PERIPH_CONF_COMMON_ESP32C3_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name UART configuration
|
||||
* @{
|
||||
*/
|
||||
#ifndef UART0_TXD
|
||||
#define UART0_TXD (GPIO21) /**< TxD of UART_DEV(0) used on all ESP32-C3 boards */
|
||||
#endif
|
||||
|
||||
#ifndef UART0_RXD
|
||||
#define UART0_RXD (GPIO20) /**< RxD of UART_DEV(0) used on all ESP32-C3 boards */
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* PERIPH_CONF_COMMON_ESP32C3_H */
|
||||
/** @} */
|
@ -7,8 +7,7 @@
|
||||
|
||||
config BOARD_COMMON_ESP32S2
|
||||
bool
|
||||
select HAS_PERIPH_UART
|
||||
select HAVE_SAUL_GPIO
|
||||
select BOARD_COMMON_ESP32X
|
||||
|
||||
config MODULE_BOARDS_COMMON_ESP32S2
|
||||
bool
|
||||
@ -18,3 +17,5 @@ config MODULE_BOARDS_COMMON_ESP32S2
|
||||
default y
|
||||
help
|
||||
Common ESP32-S2 boards code.
|
||||
|
||||
source "$(RIOTBOARD)/common/esp32x/Kconfig"
|
||||
|
@ -1,3 +1,5 @@
|
||||
MODULE = boards_common_esp32s2
|
||||
|
||||
DIRS = $(RIOTBOARD)/common/esp32x
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -1,5 +1,3 @@
|
||||
USEMODULE += boards_common_esp32s2
|
||||
|
||||
ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||
USEMODULE += saul_gpio
|
||||
endif
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.dep
|
||||
|
@ -1,5 +1,3 @@
|
||||
CPU = esp32
|
||||
CPU_FAM = esp32s2
|
||||
|
||||
# additional features provided by all boards is at least one UART
|
||||
FEATURES_PROVIDED += periph_uart
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.features
|
||||
|
@ -1,5 +1,3 @@
|
||||
INCLUDES += -I$(RIOTBOARD)/common/esp32s2/include
|
||||
|
||||
# configure the serial interface
|
||||
PORT_LINUX ?= /dev/ttyUSB0
|
||||
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.include
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* 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 <gunar@schorcht.net>
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
/** @} */
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* 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 <gunar@schorcht.net>
|
||||
*/
|
||||
|
||||
#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 */
|
||||
/** @} */
|
49
boards/common/esp32s2/include/periph_conf_common_esp32s2.h
Normal file
49
boards/common/esp32s2/include/periph_conf_common_esp32s2.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 peripheral configurations for ESP32-S2 boards
|
||||
*
|
||||
* This file contains the peripheral configurations that are valid for all
|
||||
* ESP32-S2 boards.
|
||||
*
|
||||
* For detailed information about the peripheral configuration for ESP32-S2
|
||||
* boards, see section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef PERIPH_CONF_COMMON_ESP32S2_H
|
||||
#define PERIPH_CONF_COMMON_ESP32S2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name UART configuration
|
||||
* @{
|
||||
*/
|
||||
#ifndef UART0_TXD
|
||||
#define UART0_TXD (GPIO43) /**< TxD of UART_DEV(0) used on all ESP32-S2 boards */
|
||||
#endif
|
||||
|
||||
#ifndef UART0_RXD
|
||||
#define UART0_RXD (GPIO44) /**< RxD of UART_DEV(0) used on all ESP32-S2 boards */
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* PERIPH_CONF_COMMON_ESP32S2_H */
|
||||
/** @} */
|
@ -7,8 +7,7 @@
|
||||
|
||||
config BOARD_COMMON_ESP32S3
|
||||
bool
|
||||
select HAS_PERIPH_UART
|
||||
select HAVE_SAUL_GPIO
|
||||
select BOARD_COMMON_ESP32X
|
||||
|
||||
config MODULE_BOARDS_COMMON_ESP32S3
|
||||
bool
|
||||
@ -18,3 +17,5 @@ config MODULE_BOARDS_COMMON_ESP32S3
|
||||
default y
|
||||
help
|
||||
Common ESP32-S3 boards code.
|
||||
|
||||
source "$(RIOTBOARD)/common/esp32x/Kconfig"
|
||||
|
@ -1,3 +1,5 @@
|
||||
MODULE = boards_common_esp32s3
|
||||
|
||||
DIRS = $(RIOTBOARD)/common/esp32x
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -1,5 +1,3 @@
|
||||
USEMODULE += boards_common_esp32s3
|
||||
|
||||
ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||
USEMODULE += saul_gpio
|
||||
endif
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.dep
|
||||
|
@ -1,5 +1,3 @@
|
||||
CPU = esp32
|
||||
CPU_FAM = esp32s3
|
||||
|
||||
# additional features provided by all boards is at least one UART
|
||||
FEATURES_PROVIDED += periph_uart
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.features
|
||||
|
@ -1,5 +1,3 @@
|
||||
INCLUDES += -I$(RIOTBOARD)/common/esp32s3/include
|
||||
|
||||
# configure the serial interface
|
||||
PORT_LINUX ?= /dev/ttyUSB0
|
||||
PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*)))
|
||||
include $(RIOTBOARD)/common/esp32x/Makefile.include
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* 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_esp32s3
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Common declarations and functions for all ESP32-S3 boards.
|
||||
*
|
||||
* This file contains default declarations and functions that are valid
|
||||
* for all ESP32-S3 boards.
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
/** @} */
|
@ -1,135 +0,0 @@
|
||||
/*
|
||||
* 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_esp32s3
|
||||
* @brief Common board definitions for ESP32-S3 boards.
|
||||
*
|
||||
* This file contains board configurations that are valid for all
|
||||
* ESP32-S3 boards.
|
||||
*
|
||||
* For detailed information about the configuration of ESP32-S3 boards, see
|
||||
* section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @brief MTD offset for SD Card interfaces
|
||||
*
|
||||
* MTD_1 is used for SD Card.
|
||||
*/
|
||||
#ifndef CONFIG_SDCARD_GENERIC_MTD_OFFSET
|
||||
#define CONFIG_SDCARD_GENERIC_MTD_OFFSET 1
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#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 */
|
||||
/** @} */
|
@ -1,405 +0,0 @@
|
||||
/*
|
||||
* 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_esp32s3
|
||||
* @brief Common peripheral configurations for ESP32-S3 boards
|
||||
*
|
||||
* This file contains the peripheral configurations that are valid for all
|
||||
* ESP32-S3 boards.
|
||||
*
|
||||
* For detailed information about the peripheral configuration for ESP32-S3
|
||||
* boards, see section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef PERIPH_CONF_COMMON_H
|
||||
#define PERIPH_CONF_COMMON_H
|
||||
|
||||
/* include periph_cpu.h to make it visible in any case */
|
||||
#include "periph_cpu.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name ADC configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Declaration of GPIOs that can be used as ADC channels
|
||||
*
|
||||
* ADC_GPIOS is defined in board-specific peripheral configuration. Since
|
||||
* ADC_GPIOS must be defined even if there are no ADC channels, an empty
|
||||
* list definition is done here as fallback configuration.
|
||||
*/
|
||||
#ifndef ADC_GPIOS
|
||||
#define ADC_GPIOS { }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with declared ADC channels
|
||||
*/
|
||||
static const gpio_t adc_channels[] = ADC_GPIOS;
|
||||
|
||||
/**
|
||||
* @brief Number of GPIOs declared as ADC channels
|
||||
*
|
||||
* The number of GPIOs that are declared as ADC channels is determined from
|
||||
* the ADC_GPIOS definition.
|
||||
*
|
||||
* @note ADC_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define ADC_NUMOF ARRAY_SIZE(adc_channels)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name DAC configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Declaration of GPIOs that can be used as DAC channels
|
||||
*
|
||||
* DAC_GPIOS is defined in board-specific peripheral configuration. Since
|
||||
* DAC_GPIOS must be defined even if there are no DAC channels, an empty
|
||||
* list definition is done here as fallback configuration.
|
||||
*/
|
||||
#ifndef DAC_GPIOS
|
||||
#define DAC_GPIOS { }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with declared DAC channels
|
||||
*/
|
||||
static const gpio_t dac_channels[] = DAC_GPIOS;
|
||||
|
||||
/**
|
||||
* @brief Number of GPIOs declared as DAC channels
|
||||
*
|
||||
* The number of GPIOs that are declared as DAC channels is determined from
|
||||
* the DAC_GPIOS definition.
|
||||
*
|
||||
* @note DAC_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define DAC_NUMOF ARRAY_SIZE(dac_channels)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name I2C configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(I2C0_SCL) && !defined(I2C0_SCL_PULLUP)
|
||||
/** 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)
|
||||
/** Define SCL pullup enabled by default */
|
||||
#define I2C1_SCL_PULLUP true
|
||||
#endif
|
||||
#if defined(I2C1_SDA) && !defined(I2C1_SDA_PULLUP)
|
||||
/** Define SDA pullup enabled by default */
|
||||
#define I2C1_SDA_PULLUP true
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Static array with configuration for declared I2C devices
|
||||
*/
|
||||
static const i2c_conf_t i2c_config[] = {
|
||||
#if defined(I2C0_SCL) && defined(I2C0_SDA) && defined(I2C0_SPEED)
|
||||
{
|
||||
.module = PERIPH_I2C0_MODULE,
|
||||
.speed = I2C0_SPEED,
|
||||
.scl = I2C0_SCL,
|
||||
.sda = I2C0_SDA,
|
||||
.scl_pullup = I2C0_SCL_PULLUP,
|
||||
.sda_pullup = I2C0_SCL_PULLUP,
|
||||
},
|
||||
#endif
|
||||
#if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED)
|
||||
{
|
||||
.module = PERIPH_I2C1_MODULE,
|
||||
.speed = I2C1_SPEED,
|
||||
.scl = I2C1_SCL,
|
||||
.sda = I2C1_SDA,
|
||||
.scl_pullup = I2C1_SCL_PULLUP,
|
||||
.sda_pullup = I2C1_SCL_PULLUP,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of I2C interfaces
|
||||
*
|
||||
* The number of I2C interfaces is determined from board-specific peripheral
|
||||
* definitions of I2Cn_SPEED, I2Cn_SCK, and I2Cn_SDA.
|
||||
*
|
||||
* @note I2C_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name PWM configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM0_GPIOS
|
||||
static const gpio_t pwm0_gpios[] = PWM0_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM1_GPIOS
|
||||
static const gpio_t pwm1_gpios[] = PWM1_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM2_GPIOS
|
||||
static const gpio_t pwm2_gpios[] = PWM2_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief GPIOs used as channels for the according PWM device
|
||||
*/
|
||||
#ifdef PWM3_GPIOS
|
||||
static const gpio_t pwm3_gpios[] = PWM3_GPIOS;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief PWM device configuration based on defined PWM channel GPIOs
|
||||
*/
|
||||
static const pwm_config_t pwm_config[] =
|
||||
{
|
||||
#ifdef PWM0_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
.timer = LEDC_TIMER_0,
|
||||
.ch_numof = ARRAY_SIZE(pwm0_gpios),
|
||||
.gpios = pwm0_gpios,
|
||||
},
|
||||
#endif
|
||||
#ifdef PWM1_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
||||
.group = LEDC_HIGH_SPEED_MODE,
|
||||
#else
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
#endif
|
||||
.timer = LEDC_TIMER_1,
|
||||
.ch_numof = ARRAY_SIZE(pwm1_gpios),
|
||||
.gpios = pwm1_gpios,
|
||||
},
|
||||
#endif
|
||||
#ifdef PWM2_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
.timer = LEDC_TIMER_2,
|
||||
.ch_numof = ARRAY_SIZE(pwm2_gpios),
|
||||
.gpios = pwm2_gpios,
|
||||
},
|
||||
#endif
|
||||
#ifdef PWM3_GPIOS
|
||||
{
|
||||
.module = PERIPH_LEDC_MODULE,
|
||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
||||
.group = LEDC_HIGH_SPEED_MODE,
|
||||
#else
|
||||
.group = LEDC_LOW_SPEED_MODE,
|
||||
#endif
|
||||
.timer = LEDC_TIMER_3,
|
||||
.ch_numof = ARRAY_SIZE(pwm3_gpios),
|
||||
.gpios = pwm3_gpios,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of PWM devices
|
||||
*
|
||||
* The number of PWM devices is determined from the PWM device configuration.
|
||||
*
|
||||
* @note PWM_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define PWM_NUMOF ARRAY_SIZE(pwm_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name RMT configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief RMT channel configuration
|
||||
*
|
||||
* For the moment, the only RMT channel configuration used is for the WS2812
|
||||
* driver. To override this default configuration by a board definition, add
|
||||
* ```
|
||||
* #define HAVE_RMT_CHANNEL_CONFIG
|
||||
* ```
|
||||
* before including this file and define an according `rmt_channel_config`
|
||||
* after including this file.
|
||||
*/
|
||||
#ifndef HAVE_RMT_CHANNEL_CONFIG
|
||||
static const rmt_channel_config_t rmt_channel_config[] = {
|
||||
#ifdef WS281X_PARAM_PIN
|
||||
{ 0, WS281X_PARAM_PIN },
|
||||
#else
|
||||
/* default for boards that don't define WS281X_PARAM_PIN */
|
||||
{ 0, GPIO0 },
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Number of RMT channels
|
||||
*/
|
||||
#define RMT_CH_NUMOF ARRAY_SIZE(rmt_channel_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name SPI configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Static array with configuration for declared SPI devices
|
||||
*/
|
||||
static const spi_conf_t spi_config[] = {
|
||||
#ifdef SPI0_CTRL
|
||||
{
|
||||
.ctrl = SPI0_CTRL,
|
||||
.sck = SPI0_SCK,
|
||||
.mosi = SPI0_MOSI,
|
||||
.miso = SPI0_MISO,
|
||||
.cs = SPI0_CS0,
|
||||
},
|
||||
#endif
|
||||
#ifdef SPI1_CTRL
|
||||
{
|
||||
.ctrl = SPI1_CTRL,
|
||||
.sck = SPI1_SCK,
|
||||
.mosi = SPI1_MOSI,
|
||||
.miso = SPI1_MISO,
|
||||
.cs = SPI1_CS0,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of SPI interfaces
|
||||
*
|
||||
* The number of SPI interfaces is determined from board-specific peripheral
|
||||
* definitions of SPIn_*.
|
||||
*
|
||||
* @note SPI_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define SPI_NUMOF ARRAY_SIZE(spi_config)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name UART configuration
|
||||
* @{
|
||||
*/
|
||||
|
||||
#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
|
||||
*/
|
||||
static const uart_conf_t uart_config[] = {
|
||||
{
|
||||
.txd = UART0_TXD,
|
||||
.rxd = UART0_RXD,
|
||||
},
|
||||
#if defined(UART1_TXD) && defined(UART1_RXD)
|
||||
{
|
||||
.txd = UART1_TXD,
|
||||
.rxd = UART1_RXD,
|
||||
},
|
||||
#endif
|
||||
#if defined(UART2_TXD) && defined(UART2_RXD)
|
||||
{
|
||||
.txd = UART2_TXD,
|
||||
.rxd = UART2_RXD,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of UART interfaces
|
||||
*
|
||||
* The number of UART interfaces is determined from board-specific peripheral
|
||||
* definitions of UARTn_*.
|
||||
*
|
||||
* @note UART_NUMOF definition must not be changed.
|
||||
*/
|
||||
#define UART_NUMOF ARRAY_SIZE(uart_config)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name USB device configuration
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "usbdev_esp32.h"
|
||||
|
||||
/**
|
||||
* @brief Static array with USB OTG FS configuration
|
||||
*/
|
||||
static const dwc2_usb_otg_fshs_config_t dwc2_usb_otg_fshs_config[] = {
|
||||
{
|
||||
.periph = USB_OTG_FS_PERIPH_BASE,
|
||||
.type = DWC2_USB_OTG_FS,
|
||||
.phy = DWC2_USB_OTG_PHY_BUILTIN,
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Number of USB OTG FS interfaces
|
||||
*/
|
||||
#define USBDEV_NUMOF ARRAY_SIZE(dwc2_usb_otg_fshs_config)
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* PERIPH_CONF_COMMON_H */
|
||||
/** @} */
|
49
boards/common/esp32s3/include/periph_conf_common_esp32s3.h
Normal file
49
boards/common/esp32s3/include/periph_conf_common_esp32s3.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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_esp32s3
|
||||
* @brief Common peripheral configurations for ESP32-S3 boards
|
||||
*
|
||||
* This file contains the peripheral configurations that are valid for all
|
||||
* ESP32-S3 boards.
|
||||
*
|
||||
* For detailed information about the peripheral configuration for ESP32-S3
|
||||
* boards, see section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
* @file
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef PERIPH_CONF_COMMON_ESP32S3_H
|
||||
#define PERIPH_CONF_COMMON_ESP32S3_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name UART configuration
|
||||
* @{
|
||||
*/
|
||||
#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
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* PERIPH_CONF_COMMON_ESP32S3_H */
|
||||
/** @} */
|
20
boards/common/esp32x/Kconfig
Normal file
20
boards/common/esp32x/Kconfig
Normal file
@ -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.
|
3
boards/common/esp32x/Makefile
Normal file
3
boards/common/esp32x/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = boards_common_esp32x
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
5
boards/common/esp32x/Makefile.dep
Normal file
5
boards/common/esp32x/Makefile.dep
Normal file
@ -0,0 +1,5 @@
|
||||
USEMODULE += boards_common_esp32x
|
||||
|
||||
ifneq (,$(filter saul_default,$(USEMODULE)))
|
||||
USEMODULE += saul_gpio
|
||||
endif
|
4
boards/common/esp32x/Makefile.features
Normal file
4
boards/common/esp32x/Makefile.features
Normal file
@ -0,0 +1,4 @@
|
||||
CPU = esp32
|
||||
|
||||
# additional features provided by all boards is at least one UART
|
||||
FEATURES_PROVIDED += periph_uart
|
5
boards/common/esp32x/Makefile.include
Normal file
5
boards/common/esp32x/Makefile.include
Normal file
@ -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*)))
|
@ -7,14 +7,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup boards_common_esp32
|
||||
* @ingroup boards_common_esp32x
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Common declarations and functions for all ESP32 boards.
|
||||
* @brief Common declarations and functions for all ESP32x boards.
|
||||
*
|
||||
* This file contains default declarations and functions that are valid
|
||||
* for all ESP32 boards.
|
||||
* for all ESP32x boards.
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
*/
|
16
boards/common/esp32x/doc.txt
Normal file
16
boards/common/esp32x/doc.txt
Normal file
@ -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.
|
||||
*/
|
@ -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 <gunar@schorcht.net>
|
||||
*/
|
@ -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_esp32s2
|
||||
* @brief Common board definitions for ESP32-S2 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-S2 boards.
|
||||
* This file contains board configurations that are valid for all ESP32.
|
||||
*
|
||||
* For detailed information about the configuration of ESP32-S2 boards, see
|
||||
* For detailed information about the configuration of ESP32 boards, see
|
||||
* section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
@ -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_esp32s2
|
||||
* @brief Common peripheral configurations for ESP32-S2 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-S2 boards.
|
||||
* ESP32x boards.
|
||||
*
|
||||
* For detailed information about the peripheral configuration for ESP32-S2
|
||||
* For detailed information about the peripheral configuration for ESP32x
|
||||
* boards, see section \ref esp32_peripherals "Common Peripherals".
|
||||
*
|
||||
* @author Gunar Schorcht <gunar@schorcht.net>
|
||||
@ -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-S2 boards */
|
||||
#endif
|
||||
#ifndef UART0_RXD
|
||||
#define UART0_RXD (GPIO44) /**< RxD of UART_DEV(0) used on all ESP32-S2 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" */
|
@ -249,9 +249,6 @@ static void mac_set(enc28j60_t *dev, uint8_t *mac)
|
||||
|
||||
static void on_int(void *arg)
|
||||
{
|
||||
/* disable global interrupt enable bit to avoid losing interrupts */
|
||||
cmd_bfc((enc28j60_t *)arg, REG_EIE, -1, EIE_INTIE);
|
||||
|
||||
netdev_trigger_event_isr(arg);
|
||||
}
|
||||
|
||||
@ -450,13 +447,38 @@ static int nd_init(netdev_t *netdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* PKTIF does not reliably report the status of pending packets.
|
||||
* Checking EPKTCNT is the suggested workaround.
|
||||
* Returns the number of pending packets.
|
||||
*/
|
||||
static int rx_interrupt(netdev_t *netdev)
|
||||
{
|
||||
enc28j60_t *dev = (enc28j60_t *)netdev;
|
||||
int pkg_cnt = cmd_rcr(dev, REG_B1_EPKTCNT, 1);
|
||||
int ret = pkg_cnt;
|
||||
while (pkg_cnt-- > 0) {
|
||||
DEBUG("[enc28j60] isr: packet received\n");
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_RX_COMPLETE);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void nd_isr(netdev_t *netdev)
|
||||
{
|
||||
enc28j60_t *dev = (enc28j60_t *)netdev;
|
||||
uint8_t eir = cmd_rcr(dev, REG_EIR, -1);
|
||||
|
||||
while (eir != 0) {
|
||||
/* disable global interrupt enable bit to avoid losing interrupts */
|
||||
cmd_bfc(dev, REG_EIE, -1, EIE_INTIE);
|
||||
|
||||
uint8_t eir;
|
||||
int loop;
|
||||
do {
|
||||
loop = 0;
|
||||
eir = cmd_rcr(dev, REG_EIR, -1);
|
||||
|
||||
if (eir & EIR_LINKIF) {
|
||||
loop++;
|
||||
/* clear link state interrupt flag */
|
||||
cmd_r_phy(dev, REG_PHY_PHIR);
|
||||
/* go and tell the new link layer state to upper layers */
|
||||
@ -469,27 +491,27 @@ static void nd_isr(netdev_t *netdev)
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_LINK_DOWN);
|
||||
}
|
||||
}
|
||||
if (eir & EIR_PKTIF) {
|
||||
do {
|
||||
DEBUG("[enc28j60] isr: packet received\n");
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_RX_COMPLETE);
|
||||
} while (cmd_rcr(dev, REG_B1_EPKTCNT, 1) > 0);
|
||||
if (rx_interrupt(netdev)) {
|
||||
loop++;
|
||||
}
|
||||
if (eir & EIR_RXERIF) {
|
||||
loop++;
|
||||
DEBUG("[enc28j60] isr: incoming packet dropped - RX buffer full\n");
|
||||
cmd_bfc(dev, REG_EIR, -1, EIR_RXERIF);
|
||||
}
|
||||
if (eir & EIR_TXIF) {
|
||||
loop++;
|
||||
DEBUG("[enc28j60] isr: packet transmitted\n");
|
||||
netdev->event_callback(netdev, NETDEV_EVENT_TX_COMPLETE);
|
||||
cmd_bfc(dev, REG_EIR, -1, EIR_TXIF);
|
||||
}
|
||||
if (eir & EIR_TXERIF) {
|
||||
loop++;
|
||||
DEBUG("[enc28j60] isr: error during transmission - pkt dropped\n");
|
||||
cmd_bfc(dev, REG_EIR, -1, EIR_TXERIF);
|
||||
}
|
||||
eir = cmd_rcr(dev, REG_EIR, -1);
|
||||
}
|
||||
} while (loop);
|
||||
|
||||
/* enable global interrupt enable bit again */
|
||||
cmd_bfs(dev, REG_EIE, -1, EIE_INTIE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user