Skip to content

Commit eb30594

Browse files
Merge pull request #690 from Big-mouth-c/master
Update: ESP32+RGB
2 parents ba04f30 + eca21ba commit eb30594

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

src/databus/Arduino_ESP32RGBPanel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
#include "Arduino_ESP32RGBPanel.h"
44

5-
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
5+
//#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
6+
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4) //Modify
67
Arduino_ESP32RGBPanel::Arduino_ESP32RGBPanel(
78
int8_t de, int8_t vsync, int8_t hsync, int8_t pclk,
89
int8_t r0, int8_t r1, int8_t r2, int8_t r3, int8_t r4,

src/databus/Arduino_ESP32RGBPanel.h

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,46 @@
1717

1818
#include "Arduino_DataBus.h"
1919

20-
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
20+
//#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
21+
22+
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4) //Modify
2123

2224
#include "esp_lcd_panel_rgb.h"
2325
#include "esp_lcd_panel_ops.h"
2426

25-
#include "esp32s3/rom/cache.h"
26-
// This function is located in ROM (also see esp_rom/${target}/ld/${target}.rom.ld)
27-
extern int Cache_WriteBack_Addr(uint32_t addr, uint32_t size);
2827

29-
#if (!defined(ESP_ARDUINO_VERSION_MAJOR)) || (ESP_ARDUINO_VERSION_MAJOR < 3)
28+
//#include "esp32s3/rom/cache.h"
29+
// This function is located in ROM (also see esp_rom/${target}/ld/${target}.rom.ld)
30+
//extern int Cache_WriteBack_Addr(uint32_t addr, uint32_t size);
31+
32+
//Modify
33+
// 根据目标芯片选择不同的头文件 (Select different header files according to the target chip)
34+
#if defined(CONFIG_IDF_TARGET_ESP32S3)
35+
#include "esp32s3/rom/cache.h"
36+
#elif defined(CONFIG_IDF_TARGET_ESP32P4)
37+
#include "esp32p4/rom/cache.h"
38+
#else
39+
#error "Unsupported target chip! Please use ESP32-S3 or ESP32-P4."
40+
#endif
41+
42+
// 根据芯片类型选择正确的函数签名 (Select different header files according to the target chip)
43+
#if defined(CONFIG_IDF_TARGET_ESP32P4)
44+
// ESP32-P4需要使用带gid和map参数的版本
45+
extern "C" int Cache_WriteBack_Addr_Gid(uint32_t gid, uint32_t map, uint32_t addr, uint32_t size);
46+
47+
// 创建兼容旧版API的包装函数
48+
static inline int Cache_WriteBack_Addr(uint32_t addr, uint32_t size) {
49+
// 使用默认gid=0,并同时操作L1 DCache和L2 Cache
50+
return Cache_WriteBack_Addr_Gid(0, CACHE_MAP_L1_DCACHE | CACHE_MAP_L2_CACHE, addr, size);
51+
}
52+
#else
53+
// ESP32-S3及其他芯片使用原始API
54+
extern "C" int Cache_WriteBack_Addr(uint32_t addr, uint32_t size);
55+
#endif
56+
57+
58+
//#if (!defined(ESP_ARDUINO_VERSION_MAJOR)) || (ESP_ARDUINO_VERSION_MAJOR < 3)
59+
#if (!defined(ESP_ARDUINO_VERSION_MAJOR)) || (ESP_ARDUINO_VERSION_MAJOR >5)
3060
#include "esp_lcd_panel_io.h"
3161
#include "esp_lcd_panel_vendor.h"
3262
#include "esp_lcd_panel_interface.h"

src/display/Arduino_RGB_Display.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "../Arduino_DataBus.h"
22

3-
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
3+
//#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
4+
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4) //Modify
45

56
#include "../Arduino_GFX.h"
67
#include "Arduino_RGB_Display.h"

src/display/Arduino_RGB_Display.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
#include "../Arduino_DataBus.h"
44

5-
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
5+
//#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3)
6+
#if defined(ESP32) && (CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4) //Modify
67

78
#include "../Arduino_GFX.h"
89
#include "../databus/Arduino_ESP32RGBPanel.h"

0 commit comments

Comments
 (0)