#ifndef _MEMORY_H #define _MEMORY_H #include "includes.h" #include #include #include #define AXISRAMSIZE 512 * 1024 #define SRAM1SIZE 128 * 1024 #define SRAM2SIZE 128 * 1024 #define SDRAMSIZE 28 * 1024 * 1024 /* 定义链表结构。这是用来连接自由块的他们的记忆地址 */ typedef struct A_BLOCK_LINK { struct A_BLOCK_LINK *pxNextFreeBlock; /* 列表中的下一个自由块 */ size_t xBlockSize; /* 自由块的大小 */ } BlockLink_t; typedef struct { volatile uint8_t *pMemory; /* 创建内存地址 */ volatile size_t size; /* 创建内存大小 */ BlockLink_t pStart; /* 创建内存开始 链表标记 */ BlockLink_t *pEnd; /* 创建内存结束 链表标记 */ volatile size_t Free; /* 内存当前最小剩余 */ volatile size_t MinFree; /* 内存历史最小剩余 */ } MemoryStruct; extern MemoryStruct SRAM0; extern MemoryStruct SRAM1; extern MemoryStruct SRAM2; extern MemoryStruct SDRAM; /*内存初始化*/ extern void pMemoryInit(MemoryStruct *mem); /*内存申请*/ extern void *pMemoryMalloc(MemoryStruct *mem, size_t xWantedSize); /*内存重申请*/ extern void *pMemoryReMalloc(MemoryStruct *mem1, MemoryStruct *mem2, void *ptr, size_t size); /*内存释放*/ extern void pMemoryFree(MemoryStruct *mem, void *pv); /*内存当前剩余*/ extern size_t pMemoryGetFreeMemorySize(MemoryStruct *mem); /*内存历史最小剩余*/ extern size_t pMemoryGetMinimumEverFreeMemorySize(MemoryStruct *mem); #endif