#include #include "FreeRTOS.h" #include "semphr.h" static xSemaphoreHandle malloc_mutex; static bool malloc_lock() { return xSemaphoreTake(malloc_mutex, 10) == pdTRUE; } static void malloc_unlock() { xSemaphoreGive(malloc_mutex); } void malloc_init() { malloc_mutex = xSemaphoreCreateMutex(); set_malloc_locking(&malloc_lock, &malloc_unlock); } void *pvPortMalloc( size_t xWantedSize ) { return malloc(xWantedSize); } void vPortFree( void *pv ) { free(pv); }