Skip to content

Commit 48f023e

Browse files
committed
Merge branch 'feature/add_get_dram_size' into 'master'
heap: add function to get DRAM region free size See merge request sdk/ESP8266_RTOS_SDK!1100
2 parents d501eba + 3361cbc commit 48f023e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Diff for: components/heap/port/esp8266/esp_heap_init.c

+11
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,23 @@
1313
// limitations under the License.
1414

1515
#include "esp_heap_caps.h"
16+
#include "esp_attr.h"
1617

1718
#define HEAP_REGION_IRAM_MIN 512
1819
#define HEAP_REGION_IRAM_MAX 0x00010000
1920

2021
heap_region_t g_heap_region[HEAP_REGIONS_MAX];
2122

23+
size_t IRAM_ATTR heap_caps_get_dram_free_size(void)
24+
{
25+
#ifndef CONFIG_HEAP_DISABLE_IRAM
26+
extern size_t g_heap_region_num;
27+
28+
return g_heap_region[g_heap_region_num - 1].free_bytes;
29+
#else
30+
return g_heap_region[0].free_bytes;
31+
#endif
32+
}
2233

2334
/**
2435
* @brief Initialize the capability-aware heap allocator.

Diff for: components/heap/port/esp8266/include/esp_heap_port.h

+16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
#pragma once
1616

17+
#include <stddef.h>
18+
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
1723
#define _heap_caps_lock(_num) \
1824
{ \
1925
extern void vPortETSIntrLock(void); \
@@ -32,3 +38,13 @@
3238
esp_task_wdt_reset(); \
3339
}
3440

41+
/**
42+
* @brief Get the total free size of DRAM region
43+
*
44+
* @return Amount of free bytes in DRAM region
45+
*/
46+
size_t heap_caps_get_dram_free_size(void);
47+
48+
#ifdef __cplusplus
49+
}
50+
#endif

0 commit comments

Comments
 (0)