Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 107 additions & 6 deletions boards/common/esp32/include/periph_conf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ extern "C" {
#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
*
Expand All @@ -54,7 +59,7 @@ extern "C" {
*
* @note ADC_NUMOF definition must not be changed.
*/
#define ADC_NUMOF (adc_chn_num)
#define ADC_NUMOF (sizeof(adc_channels) / sizeof(adc_channels[0]))
/** @} */

/**
Expand All @@ -73,6 +78,11 @@ extern "C" {
#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
*
Expand All @@ -81,15 +91,34 @@ extern "C" {
*
* @note DAC_NUMOF definition must not be changed.
*/
#define DAC_NUMOF (dac_chn_num)
#define DAC_NUMOF (sizeof(dac_channels) / sizeof(dac_channels[0]))
/** @} */


/**
* @name I2C configuration
* @{
*/

/**
* @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)
{
.speed = I2C0_SPEED,
.scl = I2C0_SCL,
.sda = I2C0_SDA,
},
#endif
#if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED)
{
.speed = I2C1_SPEED,
.scl = I2C1_SCL,
.sda = I2C1_SDA,
},
#endif
};

/**
* @brief Number of I2C interfaces
*
Expand All @@ -98,7 +127,7 @@ extern "C" {
*
* @note I2C_NUMOF definition must not be changed.
*/
#define I2C_NUMOF (i2c_bus_num)
#define I2C_NUMOF (sizeof(i2c_config) / sizeof(i2c_config[0]))

/** @} */

Expand All @@ -107,6 +136,19 @@ extern "C" {
* @{
*/

/**
* @brief Static array of GPIOs that can be used as channels of PWM0
*/
#ifdef PWM0_GPIOS
static const gpio_t pwm0_channels[] = PWM0_GPIOS;
#endif
/**
* @brief Static array of GPIOs that can be used as channels of PWM0
*/
#ifdef PWM1_GPIOS
static const gpio_t pwm1_channels[] = PWM1_GPIOS;
#endif

/**
* @brief Number of PWM devices
*
Expand All @@ -115,14 +157,44 @@ extern "C" {
*
* @note PWM_NUMOF definition must not be changed.
*/
#define PWM_NUMOF (pwm_dev_num)
#if defined(PWM0_GPIOS) && defined(PWM1_GPIOS)
#define PWM_NUMOF (2)
#elif defined(PWM0_GPIOS) || defined(PWM1_GPIOS)
#define PWM_NUMOF (1)
#else
#define PWM_NUMOF (0)
#endif

/** @} */

/**
* @name SPI configuration
*/

/**
* @brief Static array with configuration for declared I2C 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
*
Expand All @@ -131,14 +203,43 @@ extern "C" {
*
* @note SPI_NUMOF definition must not be changed.
*/
#define SPI_NUMOF (spi_bus_num)
#define SPI_NUMOF (sizeof(spi_config) / sizeof(spi_config[0]))

/** @} */

/**
* @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 I2C 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
*
Expand Down
2 changes: 0 additions & 2 deletions boards/esp32-olimex-evb/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
include $(RIOTBOARD)/common/esp32/Makefile.features

# additional features provided by the board (no ADC and no DAC)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_dac
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_spi
Expand Down
1 change: 0 additions & 1 deletion boards/esp32-wrover-kit/Makefile.features
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ include $(RIOTBOARD)/common/esp32/Makefile.features

# additional features provided by the board
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_dac
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_spi
Expand Down
2 changes: 1 addition & 1 deletion boards/esp32-wrover-kit/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
*/
#ifndef PWM0_GPIOS
#if !MODULE_ESP32_WROVER_KIT_CAMERA || DOXYGEN
#define PWM0_GPIOS { LED0_PIN, LED2_PIN } /**< only available when camera is not connected */
#define PWM0_GPIOS { GPIO0, GPIO4 } /**< only available when camera is not connected */
#else
#define PWM0_GPIOS { }
#endif
Expand Down
1 change: 1 addition & 0 deletions cpu/esp32/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ endif

ifneq (,$(filter esp_i2c_hw,$(USEMODULE)))
USEMODULE += xtimer
USEMODULE += core_thread_flags
else
# PLEASE NOTE: because of the very poor and faulty hardware implementation
# we use software implementation by default for the moment (if module
Expand Down
Loading