From 1d572ea304a97fcff7b68a80f8f3605037b72c6f Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Mon, 4 Jan 2021 16:39:00 +0100 Subject: [PATCH] special malloc --- tasmota/support_esp32.ino | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tasmota/support_esp32.ino b/tasmota/support_esp32.ino index 0554129e8..79821806b 100644 --- a/tasmota/support_esp32.ino +++ b/tasmota/support_esp32.ino @@ -86,6 +86,11 @@ uint32_t FlashWriteMaxSector(void) { uint8_t* FlashDirectAccess(void) { return (uint8_t*)(0x40200000 + (FlashWriteStartSector() * SPI_FLASH_SEC_SIZE)); } + +void *special_malloc(uint32_t size) { + return malloc(size); +} + #endif /*********************************************************************************************\ @@ -414,4 +419,13 @@ uint8_t* FlashDirectAccess(void) { return data; } -#endif // ESP32 \ No newline at end of file + +void *special_malloc(uint32_t size) { + if (psramFound()) { + return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); + } else { + return malloc(size); + } +} + +#endif // ESP32