MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
MemManager

Overview

Data Structures

struct  mem_config_t
 Memory user config. More...
 

Macros

#define MEM_BLOCK_DATA_BUFFER_DEFINE(name, numberOfBlocks, blockSize, id)
 Defines the memory buffer. More...
 
#define MEM_BLOCK_BUFFER(name)   (uint8_t *)&g_poolHeadBuffer##name
 \ More...
 

Enumerations

enum  mem_status_t
 Memory status.
 

Functions

mem_status_t MEM_AddBuffer (uint8_t *buffer)
 Add memory buffer to memory manager buffer list. More...
 
void * MEM_BufferAlloc (uint32_t numBytes)
 Memory buffer allocate. More...
 
mem_status_t MEM_BufferFree (void *buffer)
 Memory buffer free . More...
 
uint16_t MEM_BufferGetSize (void *buffer)
 Returns the size of a given buffer. More...
 

Data Structure Documentation

struct mem_config_t

Macro Definition Documentation

#define MEM_BLOCK_DATA_BUFFER_DEFINE (   name,
  numberOfBlocks,
  blockSize,
  id 
)
Value:
uint32_t \
g_poolBuffer##name[(MEM_POOL_SIZE + numberOfBlocks * MEM_BLOCK_SIZE + numberOfBlocks * blockSize + 3U) >> 2U];

This macro is used to define the shell memory buffer for memory manager. And then uses the macro MEM_BLOCK_BUFFER to get the memory buffer pointer. The macro should not be used in any function.

This is a example,

* MEM_BLOCK_BUFFER_DEFINE(app64, 5, 64,0);
* MEM_BLOCK_BUFFER_DEFINE(app128, 6, 128,0);
* MEM_BLOCK_BUFFER_DEFINE(app256, 7, 256,0);
*
Parameters
nameThe name string of the memory buffer.
numberOfBlocksThe number Of Blocks.
blockSizeThe memory block size.
idThe id Of memory buffer.
#define MEM_BLOCK_BUFFER (   name)    (uint8_t *)&g_poolHeadBuffer##name

Gets the memory buffer pointer \ \ This macro is used to get the memory buffer pointer. The macro should \ not be used before the macro MEM_BLOCK_BUFFER_DEFINE is used. \ \

Parameters
nameThe memory name string of the buffer. \

Function Documentation

mem_status_t MEM_AddBuffer ( uint8_t *  buffer)
Note
This API should be called when need add memory buffer to memory manager buffer list. First use MEM_BLOCK_BUFFER_DEFINE to define memory buffer, then call MEM_AddBuffer function with MEM_BLOCK_BUFFER Macro as the input parameter.
* MEM_BLOCK_BUFFER_DEFINE(app64, 5, 64,0);
* MEM_BLOCK_BUFFER_DEFINE(app128, 6, 128,0);
* MEM_BLOCK_BUFFER_DEFINE(app256, 7, 256,0);
*
*
Parameters
bufferPointer the memory pool buffer, use MEM_BLOCK_BUFFER Macro as the input parameter.
Return values
kStatus_MemSuccessMemory manager add buffer succeed.
kStatus_MemUnknownErrorMemory manager add buffer error occurred.
void* MEM_BufferAlloc ( uint32_t  numBytes)
Parameters
numBytesThe number of bytes will be allocated.
Return values
Memorybuffer address when allocate success, NULL when allocate fail.
mem_status_t MEM_BufferFree ( void *  buffer)
Parameters
bufferThe memory buffer address will be free.
Return values
kStatus_MemSuccessMemory free succeed.
kStatus_MemFreeErrorMemory free error occurred.
uint16_t MEM_BufferGetSize ( void *  buffer)
Parameters
bufferThe memory buffer address will be get size.
Return values
Thesize of a given buffer.