19
19
#include "esp_heap_caps.h"
20
20
21
21
#include "esp_system.h"
22
- #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
22
+ #include "esp_psram.h"
23
+ #include "esp_private/esp_psram_extram.h"
23
24
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
24
- #include "esp32/spiram .h"
25
+ #include "esp32/rom/cache .h"
25
26
#elif CONFIG_IDF_TARGET_ESP32S2
26
- #include "esp32s2/spiram.h"
27
27
#include "esp32s2/rom/cache.h"
28
28
#elif CONFIG_IDF_TARGET_ESP32S3
29
- #include "esp32s3/spiram.h"
30
29
#include "esp32s3/rom/cache.h"
31
30
#else
32
31
#error Target CONFIG_IDF_TARGET is not supported
33
32
#endif
34
- #else // ESP32 Before IDF 4.0
35
- #include "esp_spiram.h"
36
- #endif
37
33
38
34
static volatile bool spiramDetected = false;
39
35
static volatile bool spiramFailed = false;
40
36
41
37
//allows user to bypass SPI RAM test routine
42
38
__attribute__((weak )) bool testSPIRAM (void )
43
39
{
44
- return esp_spiram_test ();
40
+ return esp_psram_extram_test ();
45
41
}
46
42
47
43
@@ -66,7 +62,7 @@ bool psramInit(){
66
62
esp_config_data_cache_mode ();
67
63
Cache_Enable_DCache (0 );
68
64
#endif
69
- if (esp_spiram_init () != ESP_OK ) {
65
+ if (esp_psram_init () != ESP_OK ) {
70
66
spiramFailed = true;
71
67
log_w ("PSRAM init failed!" );
72
68
#if CONFIG_IDF_TARGET_ESP32
@@ -77,14 +73,14 @@ bool psramInit(){
77
73
#endif
78
74
return false;
79
75
}
80
- esp_spiram_init_cache ();
76
+
81
77
//testSPIRAM() allows user to bypass SPI RAM test routine
82
78
if (!testSPIRAM ()) {
83
79
spiramFailed = true;
84
80
log_e ("PSRAM test failed!" );
85
81
return false;
86
82
}
87
- if (esp_spiram_add_to_heapalloc () != ESP_OK ) {
83
+ if (esp_psram_extram_add_to_heap_allocator () != ESP_OK ) {
88
84
spiramFailed = true;
89
85
log_e ("PSRAM could not be added to the heap!" );
90
86
return false;
0 commit comments