ESPHome  2024.12.2
psram.cpp
Go to the documentation of this file.
1 #include "psram.h"
2 
3 #ifdef USE_ESP32
4 
5 #include "esphome/core/log.h"
6 
7 #include <esp_heap_caps.h>
8 #include <esp_idf_version.h>
9 
10 namespace esphome {
11 namespace psram {
12 
13 static const char *const TAG = "psram";
14 
15 void PsramComponent::dump_config() {
16  // Technically this can be false if the PSRAM is full, but heap_caps_get_total_size() isn't always available, and it's
17  // very unlikely for the PSRAM to be full.
18  bool available = heap_caps_get_free_size(MALLOC_CAP_SPIRAM) > 0;
19 
20  ESP_LOGCONFIG(TAG, "PSRAM:");
21  ESP_LOGCONFIG(TAG, " Available: %s", YESNO(available));
22 #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0)
23  if (available) {
24  ESP_LOGCONFIG(TAG, " Size: %d KB", heap_caps_get_total_size(MALLOC_CAP_SPIRAM) / 1024);
25  }
26 #endif
27 }
28 
29 } // namespace psram
30 } // namespace esphome
31 
32 #endif
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7