Forráskód Böngészése

spiram: add getter function to check psram initialization state

morris 4 éve
szülő
commit
21067a0455

+ 1 - 1
components/esp_hw_support/Kconfig.spiram.common

@@ -2,7 +2,7 @@
 #
 #
 # sourced into the "SPIRAM config" submenu for ESP32 or ESP32S2
 # sourced into the "SPIRAM config" submenu for ESP32 or ESP32S2
 
 
-# invisible option selected by ESP32_SPIRAM_SUPPORT || ESP32S2_SPIRAM_SUPPORT
+# invisible option selected by ${target}_SPIRAM_SUPPORT
 config SPIRAM
 config SPIRAM
     bool
     bool
 
 

+ 1 - 1
components/esp_hw_support/component.mk

@@ -1,5 +1,5 @@
 COMPONENT_SRCDIRS := . port/$(IDF_TARGET)
 COMPONENT_SRCDIRS := . port/$(IDF_TARGET)
-COMPONENT_ADD_INCLUDEDIRS := . include port/$(IDF_TARGET)/ include/soc port/$(IDF_TARGET)/private_include
+COMPONENT_ADD_INCLUDEDIRS := . include port/$(IDF_TARGET)/ include/soc include/soc/${IDF_TARGET} port/$(IDF_TARGET)/private_include
 COMPONENT_ADD_LDFRAGMENTS := linker.lf
 COMPONENT_ADD_LDFRAGMENTS := linker.lf
 
 
 ifdef IS_BOOTLOADER_BUILD
 ifdef IS_BOOTLOADER_BUILD

+ 9 - 0
components/esp_hw_support/include/soc/esp32s2/spiram.h

@@ -91,6 +91,15 @@ void esp_spiram_writeback_cache(void);
  */
  */
 esp_err_t esp_spiram_reserve_dma_pool(size_t size);
 esp_err_t esp_spiram_reserve_dma_pool(size_t size);
 
 
+/**
+ * @brief If SPI RAM(PSRAM) has been initialized
+ *
+ * @return
+ *          - true SPI RAM has been initialized successfully
+ *          - false SPI RAM hasn't been initialized or initialized failed
+ */
+bool esp_spiram_is_initialized(void);
+
 #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS
 #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS
 
 
 extern int _instruction_reserved_start, _instruction_reserved_end;
 extern int _instruction_reserved_start, _instruction_reserved_end;

+ 17 - 1
components/esp_hw_support/include/soc/esp32s3/spiram.h

@@ -78,7 +78,14 @@ size_t esp_spiram_get_size(void);
  */
  */
 void esp_spiram_writeback_cache(void);
 void esp_spiram_writeback_cache(void);
 
 
-
+/**
+ * @brief If SPI RAM(PSRAM) has been initialized
+ *
+ * @return
+ *          - true SPI RAM has been initialized successfully
+ *          - false SPI RAM hasn't been initialized or initialized failed
+ */
+bool esp_spiram_is_initialized(void);
 
 
 /**
 /**
  * @brief Reserve a pool of internal memory for specific DMA/internal allocations
  * @brief Reserve a pool of internal memory for specific DMA/internal allocations
@@ -91,6 +98,15 @@ void esp_spiram_writeback_cache(void);
  */
  */
 esp_err_t esp_spiram_reserve_dma_pool(size_t size);
 esp_err_t esp_spiram_reserve_dma_pool(size_t size);
 
 
+/**
+ * @brief If SPI RAM(PSRAM) has been initialized
+ *
+ * @return
+ *          - true SPI RAM has been initialized successfully
+ *          - false SPI RAM hasn't been initialized or initialized failed
+ */
+bool esp_spiram_is_initialized(void);
+
 #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS
 #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS
 
 
 extern int _instruction_reserved_start, _instruction_reserved_end;
 extern int _instruction_reserved_start, _instruction_reserved_end;

+ 10 - 1
components/esp_hw_support/port/esp32s2/spiram.c

@@ -375,6 +375,15 @@ void IRAM_ATTR esp_spiram_writeback_cache(void)
     Cache_WriteBack_All();
     Cache_WriteBack_All();
 }
 }
 
 
-
+/**
+ * @brief If SPI RAM(PSRAM) has been initialized
+ *
+ * @return true SPI RAM has been initialized successfully
+ * @return false SPI RAM hasn't been initialized or initialized failed
+ */
+bool esp_spiram_is_initialized(void)
+{
+    return spiram_inited;
+}
 
 
 #endif
 #endif

+ 11 - 0
components/esp_hw_support/port/esp32s3/spiram.c

@@ -329,4 +329,15 @@ void IRAM_ATTR esp_spiram_writeback_cache(void)
     Cache_WriteBack_All();
     Cache_WriteBack_All();
 }
 }
 
 
+/**
+ * @brief If SPI RAM(PSRAM) has been initialized
+ *
+ * @return true SPI RAM has been initialized successfully
+ * @return false SPI RAM hasn't been initialized or initialized failed
+ */
+bool esp_spiram_is_initialized(void)
+{
+    return s_spiram_inited;
+}
+
 #endif
 #endif