File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
ports/espressif/supervisor Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 107
107
#include "esp_log.h"
108
108
#define TAG "port"
109
109
110
- uint32_t * heap ;
111
- uint32_t heap_size ;
112
-
113
110
STATIC esp_timer_handle_t _tick_timer ;
114
111
STATIC esp_timer_handle_t _sleep_timer ;
115
112
@@ -255,9 +252,6 @@ safe_mode_t port_init(void) {
255
252
esp_rom_install_uart_printf ();
256
253
#endif
257
254
258
- heap = NULL ;
259
- heap_size = 0 ;
260
-
261
255
#define pin_GPIOn (n ) pin_GPIO##n
262
256
#define pin_GPIOn_EXPAND (x ) pin_GPIOn(x)
263
257
@@ -329,7 +323,16 @@ void *port_malloc(size_t size, bool dma_capable) {
329
323
if (dma_capable ) {
330
324
caps |= MALLOC_CAP_DMA ;
331
325
}
332
- return heap_caps_malloc (size , caps );
326
+
327
+ void * ptr = NULL ;
328
+ // Try SPIRAM first when available.
329
+ #ifdef CONFIG_SPIRAM
330
+ ptr = heap_caps_malloc (size , caps | MALLOC_CAP_SPIRAM );
331
+ #endif
332
+ if (ptr == NULL ) {
333
+ ptr = heap_caps_malloc (size , caps );
334
+ }
335
+ return ptr ;
333
336
}
334
337
335
338
void port_free (void * ptr ) {
@@ -341,7 +344,7 @@ void *port_realloc(void *ptr, size_t size) {
341
344
}
342
345
343
346
size_t port_heap_get_largest_free_size (void ) {
344
- size_t free_size = heap_caps_get_largest_free_block (0 );
347
+ size_t free_size = heap_caps_get_largest_free_block (MALLOC_CAP_8BIT );
345
348
return free_size ;
346
349
}
347
350
You can’t perform that action at this time.
0 commit comments