Integrate the new heap implementation from InfiniTime (https://github.com/InfiniTimeOrg/InfiniTime/pull/1709).

Since FreeRTOS.h, portmacro_cmsis.h and task.h are now built in C (by lv_mem.c), I had to change some includes and declarations to make them compatible with a C compiler.

Integrating the new memory management from InfiniTime in InfiniSim is not easy because InfiniSim does not include the whole FreeRTOS. Which means that, for example, pvPortMalloc() and vPortFree() are not accessible from InfiniSim.
As a first step, I provided custom implementations for pvPortMalloc(), vPortFree() which are based on ... malloc(). These function keep track of the memory that is currently allocated so that xPortGetFreeHeapSize(), xPortGetMinimumEverFreeHeapSize() return something.

Not that this implementation do not keep track of all the memory allocations done in InfiniTime. It can only "see" those done via pvPortMalloc(). It means that the available memory displayed by InfiniSim will probably be very optimistic.
This commit is contained in:
Jean-François Milants
2023-04-09 12:17:10 +02:00
committed by Reinhold Gschweicher
parent e416f2cf74
commit 8ae5ba7c0a
5 changed files with 87 additions and 31 deletions

View File

@@ -29,7 +29,7 @@
#ifndef PORTMACRO_CMSIS_H
#define PORTMACRO_CMSIS_H
#include <cstdint>
#include <stdint.h>
typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
@@ -41,8 +41,8 @@ typedef unsigned long UBaseType_t;
#define pdPASS pdTRUE
/* RTC register */
using NRF_RTC_Type = uint32_t;
constexpr NRF_RTC_Type portNRF_RTC_REG = 1;
typedef uint32_t NRF_RTC_Type;
const NRF_RTC_Type portNRF_RTC_REG = 1;
void portYIELD_FROM_ISR(BaseType_t);