CooCox CoOS User's Guide
CooCox CoOS User's Guide
CooCox CoOS User's Guide
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Description:<br />
Create a memory partition with a certain length.<br />
Parameters:<br />
[IN] memBuf<br />
The initial address of the partition<br />
[IN] blockSize<br />
The size of each memory block in the partition<br />
[IN] blockNum<br />
Returns:<br />
The number of the memory block in the partition<br />
The ID of the memory partition, Create the partition successfully and<br />
return the partition ID.<br />
-1, Failed to create.<br />
Example usage:<br />
Note:<br />
#include "CCRTOS.h"<br />
#define MEM_BLOCK_NUM 10<br />
OS_MMID mmc;<br />
unsigned int MemoryBlock[100];<br />
void TaskN (void *pdata)<br />
{<br />
}<br />
...<br />
/* Create a memory partition */<br />
/* Memory size: 100*4 bytes, */<br />
/* Block num: 10 */<br />
/* Block size 100*4/10 = 40 bytes */<br />
mmc=CoCreateMemPartition((U8*)MemoryBlock,<br />
if (mmc == E_CREATE_FAIL)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
...<br />
100*4/MEM_BLOCK_NUM,<br />
MEM_BLOCK_NUM);<br />
printf("Create memory partition fail !\n");<br />
printf("Memory Partition ID : %d \n", mmc);<br />
1) Once a memory partition is created successfully, the system will<br />
distribute a memory control block to manage the memory blocks.<br />
2) blockSize cannot be 0 and blockNum must larger than 2.<br />
71