ソースを参照

esp_wifi: Add API to get available internal heap size.

xiehang 5 年 前
コミット
4e831ac080

+ 1 - 1
components/esp32/esp_adapter.c

@@ -555,7 +555,7 @@ wifi_osi_funcs_t g_wifi_osi_funcs = {
     ._malloc = malloc,
     ._free = free,
     ._event_post = esp_event_post_wrapper,
-    ._get_free_heap_size = esp_get_free_heap_size,
+    ._get_free_heap_size = esp_get_free_internal_heap_size,
     ._rand = esp_random,
     ._dport_access_stall_other_cpu_start_wrap = esp_dport_access_stall_other_cpu_start_wrap,
     ._dport_access_stall_other_cpu_end_wrap = esp_dport_access_stall_other_cpu_end_wrap,

+ 5 - 0
components/esp32/system_api.c

@@ -340,6 +340,11 @@ uint32_t esp_get_free_heap_size( void )
     return heap_caps_get_free_size( MALLOC_CAP_DEFAULT );
 }
 
+uint32_t esp_get_free_internal_heap_size( void )
+{
+    return heap_caps_get_free_size( MALLOC_CAP_8BIT | MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL );
+}
+
 uint32_t esp_get_minimum_free_heap_size( void )
 {
     return heap_caps_get_minimum_free_size( MALLOC_CAP_DEFAULT );

+ 10 - 0
components/esp_common/include/esp_system.h

@@ -113,6 +113,16 @@ esp_reset_reason_t esp_reset_reason(void);
   */
 uint32_t esp_get_free_heap_size(void);
 
+/**
+  * @brief  Get the size of available internal heap.
+  *
+  * Note that the returned value may be larger than the maximum contiguous block
+  * which can be allocated.
+  *
+  * @return Available internal heap size, in bytes.
+  */
+uint32_t esp_get_free_internal_heap_size(void);
+
 /**
   * @brief Get the minimum heap that has ever been available
   *