Skip to content

Commit 65015d5

Browse files
authored
Refactor includes for ESP32 chip compatibility
Updated includes for modern ESP32 chips to prioritize newer spi_mem_c_struct.h.
1 parent 832de97 commit 65015d5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cores/esp32/Esp.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ extern "C" {
4141
#include "hal/spi_flash_ll.h"
4242
#if CONFIG_IDF_TARGET_ESP32
4343
#include "soc/spi_struct.h"
44-
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
45-
#include "hal/spimem_flash_ll.h"
46-
#include "soc/spi_mem_struct.h"
4744
#else
48-
// ESP32-P4, ESP32-C5, and future chips use spi_mem_c_struct.h
45+
// All modern chips (S2, S3, C2, C3, C5, C6, H2, P4) use spimem
4946
#include "hal/spimem_flash_ll.h"
47+
// Try to include the newer c_struct header first, fall back to regular struct
48+
#if __has_include("soc/spi_mem_c_struct.h")
5049
#include "soc/spi_mem_c_struct.h"
50+
#else
51+
#include "soc/spi_mem_struct.h"
52+
#endif
5153
#endif
5254

5355
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+

0 commit comments

Comments
 (0)