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: changes to use ESP-IDF HAL/LL API #17841

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
18b8d20
cpu/esp32: variant independent bootloader makefile
gschorcht Mar 9, 2022
2d3e8bf
cpu/esp_common: add FreeRTOS functionality required by ESP-IDF 4.4
gschorcht Mar 9, 2022
d625f91
cpu/esp_common: remove ESP32 spi_flash_* funcs in periph/flash
gschorcht Mar 9, 2022
ed5a14b
cpu/esp_common: inverse MCU_* conditionals to deal with ESP32 variants
gschorcht Mar 9, 2022
9282e05
cpu/esp32: ESP32 variant independent makefiles
gschorcht Mar 9, 2022
4a286c5
cpu/esp_common: ESP32 variant independent makefiles
gschorcht Mar 9, 2022
2eb9899
cpu/esp32: replace startup by architecture dependent ESP-IDF startup
gschorcht Mar 9, 2022
7d6e417
cpu/esp32: ESP32 variant independent irq_arch implementation
gschorcht Mar 9, 2022
6cca58a
cpu/esp32: port periph/rtt_hw_rtc to ESP-IDF interrupt HAL
gschorcht Mar 9, 2022
2a9ffee
cpu/esp32: port periph/rtt_hw_sys to ESP-IDF timer HAL
gschorcht Mar 9, 2022
55e98a1
cpu/esp32: port syscalls to ESP-IDF timer HAL
gschorcht Mar 9, 2022
f01f56a
cpu/esp32: add ESP-IDF interface API
gschorcht Mar 9, 2022
520f406
cpu/esp32: add adc to ESP-IDF initerface API
gschorcht Mar 9, 2022
b86b2bb
cpu/esp32: port periph/adc to ESP-IDF interface API
gschorcht Mar 9, 2022
3a2e361
cpu/esp32: add periph_ctrl to ESP-IDF interface API
gschorcht Mar 9, 2022
0631f14
cpu/esp32: add gpio to ESP-IDF interface API
gschorcht Mar 9, 2022
07d731a
cpu/esp32: add dac to ESP-IDF interface API
gschorcht Mar 9, 2022
2463492
cpu/esp32: add ledc to ESP-IDF interface API
gschorcht Mar 9, 2022
ec3937f
cpu/esp32: add uart to ESP-IDF interface API
gschorcht Mar 9, 2022
e969017
cpu/esp32: port periph/gpio to ESP-IDF gpio HAL
gschorcht May 26, 2022
c31c7a9
cpu/esp32: port periph/can to ESP-IDF twai HAL
gschorcht Mar 9, 2022
c8dcdda
cpu/esp32: port periph/dac to ESP-IDF dac API
gschorcht Mar 9, 2022
fc3b749
cpu/esp32: port periph/i2c_hw to ESP-IDF i2c HAL
gschorcht Mar 9, 2022
794cc20
cpu/esp32: port periph/pwm to ESP-IDF ledc HAL
gschorcht Mar 10, 2022
128d91d
cpu/esp32: port periph/pm to ESP-IDF sleep API
gschorcht Mar 10, 2022
3bdcbca
cpu/common: port periph/hwrng to ESP random API
gschorcht Mar 10, 2022
8370a30
cpu/esp_common: move periph/spi to cpu/esp8266
gschorcht Mar 10, 2022
2ed0e06
cpu/esp32: port periph/spi to ESP-IDF spi LL API
gschorcht Mar 10, 2022
9928c1f
cpu/esp32: port priph/timer to ESP-IDF interface API
gschorcht Mar 10, 2022
8de78cc
cpu/esp_common: inverse MCU_* conditionals to deal with ESP32 variants
gschorcht Mar 10, 2022
19114f1
cpu/esp32: periph/uart port to ESP-IDF uart HAL
gschorcht Mar 10, 2022
25017e1
cpu/esp32: DEBUG messages with portable formatting
gschorcht Mar 10, 2022
b3142a4
cpu/esp_common: conditional Xtensa code
gschorcht Mar 10, 2022
bc724a0
cpu/esp_common: calculated delays in periph/i2c_sw
gschorcht Mar 10, 2022
306d2e0
boards/esp32: cleanup board_init_common
gschorcht Mar 10, 2022
3bf016b
cpu/esp32: split esp_idf_wpa_supplicant into several modules
gschorcht Mar 10, 2022
bc75e56
cpu/esp32: small doc fixes
gschorcht Mar 11, 2022
39dee55
cpu/esp32: cleanup of makefiles for peripherals
gschorcht Mar 11, 2022
6181459
cpu/esp32: required changes in Kconfig
gschorcht May 26, 2022
cff2d90
cpu/esp32: port periph/cpu_id to ESP-IDF read_mac
gschorcht Mar 12, 2022
f2fcbcc
cpu/esp_common: inverse MCU_* conditionals to deal with ESP32 variants
gschorcht Mar 20, 2022
156817e
drivers/ws281x: use ESP-IDF CPU HAL
gschorcht Mar 22, 2022
761ac07
boards/esp32: PWM configuration cleanup
gschorcht Jun 4, 2022
ae31cb1
cpu/esp32: doc changs for PWM
gschorcht Jun 4, 2022
10c7a77
fixup! cpu/esp32: port syscalls to ESP-IDF timer HAL
gschorcht Jun 19, 2022
ebec3b1
fixup! cpu/esp32: port syscalls to ESP-IDF timer HAL
gschorcht Jun 19, 2022
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
4 changes: 0 additions & 4 deletions boards/common/esp32/board_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
extern "C" {
#endif

void board_init_common(void)
{
}

extern void adc_print_config(void);
extern void dac_print_config(void);
extern void pwm_print_config(void);
Expand Down
10 changes: 0 additions & 10 deletions boards/common/esp32/include/board_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,6 @@ extern mtd_dev_t *mtd0;
/** @} */
#endif /* MODULE_SPIFFS || DOXYGEN */

/**
* @brief Initialize the hardware that is common for all ESP32 boards.
*
* This function has to be called from the board specific `board_init` function.
*/
void board_init_common(void);

/**
* @brief Print the board configuration in a human readable format
*/
Expand All @@ -171,9 +164,6 @@ void print_board_config(void);
extern "C"
#endif

/* declaration of `board_init_common` is required when compiling vendor code */
extern void board_init_common(void);

#ifdef __cplusplus
}
#endif
Expand Down
125 changes: 104 additions & 21 deletions boards/common/esp32/include/periph_conf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,48 @@ static const gpio_t dac_channels[] = DAC_GPIOS;
* @{
*/

#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)
#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)
#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
#endif
};

/**
Expand All @@ -138,33 +162,92 @@ static const i2c_conf_t i2c_config[] = {
*/

/**
* @brief Static array of GPIOs that can be used as channels of PWM0
* @brief GPIOs used as channels for the according PWM device
*/
#ifdef PWM0_GPIOS
static const gpio_t pwm0_channels[] = PWM0_GPIOS;
static const gpio_t pwm0_gpios[] = PWM0_GPIOS;
#endif

/**
* @brief Static array of GPIOs that can be used as channels of PWM0
* @brief GPIOs used as channels for the according PWM device
*/
#ifdef PWM1_GPIOS
static const gpio_t pwm1_channels[] = 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 PWM0_GPIOS and PWM1_GPIOS
* definitions.
* The number of PWM devices is determined from the PWM device configuration.
*
* @note PWM_NUMOF definition must not be changed.
*/
#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
#define PWM_NUMOF ARRAY_SIZE(pwm_config)

/** @} */

Expand Down Expand Up @@ -228,18 +311,18 @@ static const uart_conf_t uart_config[] = {
.txd = UART0_TXD,
.rxd = UART0_RXD,
},
#if defined(UART1_TXD) && defined(UART1_RXD)
#if defined(UART1_TXD) && defined(UART1_RXD)
{
.txd = UART1_TXD,
.rxd = UART1_RXD,
},
#endif
#if defined(UART2_TXD) && defined(UART2_RXD)
#endif
#if defined(UART2_TXD) && defined(UART2_RXD)
{
.txd = UART2_TXD,
.rxd = UART2_RXD,
},
#endif
#endif
};

/**
Expand Down
4 changes: 0 additions & 4 deletions boards/esp32-ethernet-kit-v1_0/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@
#endif
#endif /* PWM0_GPIOS */

/** PWM_DEV(1) is not used */
#ifndef PWM1_GPIOS
#define PWM1_GPIOS { }
#endif
/** @} */

/**
Expand Down
4 changes: 0 additions & 4 deletions boards/esp32-mh-et-live-minikit/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@
#define PWM0_GPIOS { GPIO2, GPIO0, GPIO4, GPIO15 }
#endif

/** PWM_DEV(1) is not used */
#ifndef PWM1_GPIOS
#define PWM1_GPIOS { }
#endif
/** @} */

/**
Expand Down
5 changes: 0 additions & 5 deletions boards/esp32-olimex-evb/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,9 @@ extern "C" {
#else
#error Configuration problem: Flash mode qio or qout is used, \
GPIO9 and GPIO10 cannot be used as PWM channels as configured
#define PWM0_GPIOS { }
#endif
#endif

/** PWM_DEV(1) is not used */
#ifndef PWM1_GPIOS
#define PWM1_GPIOS { }
#endif
/** @} */

/**
Expand Down
2 changes: 0 additions & 2 deletions boards/esp32-ttgo-t-beam/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

void board_init(void)
{
board_init_common();

#if MODULE_ESP32_TTGO_T_BEAM_V1_0
uint8_t reg;

Expand Down
4 changes: 0 additions & 4 deletions boards/esp32-wemos-lolin-d32-pro/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@
#define PWM0_GPIOS { GPIO0, GPIO2 }
#endif

/** PWM_DEV(1) is not used */
#ifndef PWM1_GPIOS
#define PWM1_GPIOS { }
#endif
/** @} */

/**
Expand Down
3 changes: 0 additions & 3 deletions boards/esp32-wrover-kit/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,4 @@ void board_init(void)
#if MODULE_ILI9341
gpio_init(LCD_BACKLIGHT, GPIO_OUT);
#endif

/* there is nothing special to initialize on this board */
board_init_common();
}
4 changes: 0 additions & 4 deletions boards/esp32-wrover-kit/include/periph_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@
#endif
#endif

/** PWM_DEV(1) is not used */
#ifndef PWM1_GPIOS
#define PWM1_GPIOS { }
#endif
/** @} */

/**
Expand Down
14 changes: 7 additions & 7 deletions cpu/esp32/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ config CPU_FAM_ESP32
select CPU_CORE_XTENSA_LX6
select HAS_ARCH_ESP32
select HAS_CPU_ESP32
select HAS_ESP_HW_COUNTER
select HAS_ESP_WIFI_ENTERPRISE
select HAS_PERIPH_ADC_CTRL
select HAS_PUF_SRAM

select PACKAGE_ESP32_SDK if TEST_KCONFIG
Expand Down Expand Up @@ -63,6 +63,11 @@ config HAS_CPU_ESP32
help
Indicates that the current CPU is 'esp32'.

config HAS_ESP_HW_COUNTER
bool
help
Indicates that HW counters can be used.

config HAS_ESP_RTC_TIMER_32K
bool
help
Expand All @@ -75,11 +80,6 @@ config HAS_ESP_SPI_RAM
Indicates that an external RAM is connected via the FSPI interface in
the board.

config HAS_PERIPH_ADC_CTRL
bool
help
Indicates that an ESP32 ADC controller peripheral is present.

## Common CPU symbols
config CPU_CORE
default "xtensa-lx6" if CPU_CORE_XTENSA_LX6
Expand Down Expand Up @@ -120,7 +120,6 @@ menu "ESP32 specific configurations"
config MODULE_ESP_SPI_RAM
bool "SPI RAM support"
depends on HAS_ESP_SPI_RAM
select MODULE_ESP_IDF_EFUSE
select MODULE_ESP_IDF_GPIO
select MODULE_ESP_IDF_HEAP
select MODULE_ESP_IDF_SPI_FLASH
Expand All @@ -136,5 +135,6 @@ endmenu

rsource "bootloader/Kconfig"
rsource "esp-idf/Kconfig"
rsource "esp-idf-api/Kconfig"
rsource "periph/Kconfig"
source "$(RIOTCPU)/esp_common/Kconfig"
1 change: 1 addition & 0 deletions cpu/esp32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SRC = irq_arch.c startup.c syscalls.c
DIRS += $(RIOTCPU)/esp_common
DIRS += periph
DIRS += esp-idf
DIRS += esp-idf-api

ifneq (, $(filter esp_bootloader, $(USEMODULE)))
DIRS += bootloader
Expand Down
Loading