Microchip® Advanced Software Framework

mimem.c File Reference

Memory Buffer handling for MiWi Protocol implementation.

Copyright (c) 2018 - 2019 Microchip Technology Inc. and its subsidiaries.

#include <string.h>
#include "compiler.h"
#include "mimem.h"

Data Structures

struct  _Block_t
 

Macros

#define ALIGN(X)   ((((X-1) >> ALIGNMENT_FACTOR) << ALIGNMENT_FACTOR) + BYTE_ALIGNMENT)
 
#define ALIGNMENT_FACTOR   2U
 
#define BYTE_ALIGNMENT   4U
 
#define HEAP_MINIMUM_BLOCK_SIZE   (( size_t )( blockMetaDataSize + 4U))
 
#define HEAP_SIZE   (6144UL)
 

Typedefs

typedef struct _Block_t Block_t
 

Functions

void * MiMem_Alloc (uint8_t size)
 
void MiMem_Free (void *ptr)
 
void MiMem_Init (void)
 
uint8_t MiMem_PercentageOfFreeBuffers (void)
 
static void splitBlock (Block_t *blockTobeSplitted, size_t size)
 

Variables

static Block_tbase = NULL
 
static const size_t blockMetaDataSize = ALIGN(sizeof(Block_t))
 
static uint8_t heapMem [HEAP_SIZE]
 
static size_t totalFreeBytesRemaining
 

#define ALIGN (   X)    ((((X-1) >> ALIGNMENT_FACTOR) << ALIGNMENT_FACTOR) + BYTE_ALIGNMENT)

Referenced by MiMem_Alloc(), and MiMem_Init().

#define ALIGNMENT_FACTOR   2U
#define BYTE_ALIGNMENT   4U
#define HEAP_MINIMUM_BLOCK_SIZE   (( size_t )( blockMetaDataSize + 4U))

Referenced by MiMem_Alloc().

#define HEAP_SIZE   (6144UL)

typedef struct _Block_t Block_t

uint8_t MiMem_PercentageOfFreeBuffers ( void  )

References HEAP_SIZE, and totalFreeBytesRemaining.

Referenced by frameParse(), and MiApp_SendData().

static void splitBlock ( Block_t blockTobeSplitted,
size_t  size 
)
static

Block_t* base = NULL
static

Referenced by MiMem_Alloc(), and MiMem_Free().

const size_t blockMetaDataSize = ALIGN(sizeof(Block_t))
static

Referenced by MiMem_Alloc(), and MiMem_Free().

uint8_t heapMem[HEAP_SIZE]
static

Referenced by MiMem_Init().

size_t totalFreeBytesRemaining
static