make menuconfig进入到配置
Component config --->ESP32-specific
启用 Support for external, SPI-connected RAM
进入到 SPI RAM config ---> SPI RAM access method
选择 Make RAM allocatable using heap_caps_malloc
使用方法:
char *buf =(char*)heap_caps_malloc(1024*1, MALLOC_CAP_SPIRAM);
heap_caps_free(buf);
查看剩余空间:
heap_caps_get_free_size( MALLOC_CAP_SPIRAM );
具体的查看官方说明:https://docs.espressif.com/projects/esp-idf/zh_CN/stable/api-guides/external-ram.html