...
Code Block | ||
---|---|---|
| ||
OS_MEM MyPartition; (1) CPU_INT08U MyPartitionStorage[12][100]; (2) void main (void) (3) { OS_ERR err; : : OSInit(&err); : OSMemCreate((OS_MEM *)&MyPartition, (4) (CPU_CHAR *)"My Partition", (5) (void *)&MyPartitionStorage[0][0], (6) (OS_MEM_QTY ) 12, (7) (OS_MEM_SIZE)100, (8) (OS_ERR *)&err); (9) /* Check 'err' */ : : OSStart(&err); } |
Panel | ||
---|---|---|
| ||
(1) An application needs to allocate storage for a memory partition control block (i.e. (2) The application also needs to allocate storage for the memory that will be split into memory blocks. This can also be a static allocation or (3) Memory partition must be created before allocating and deallocating blocks from the partition. One of the best places to create memory partitions is in (4) You pass the address of the memory partition control block to (5) You can assign a name to the memory partition. There is no limit to the length of the ASCII string as µC/OS-III saves a pointer to the ASCII string in the partition control block and not the actual characters. (6) You then need to pass the base address of the storage area reserved for the memory blocks. (7) Here, you specify how many memory blocks are available from this memory partition. Hard coded numbers are used for the sake of the illustration but you should instead use (8) You need to specify the size of each memory block in the partition. Again, a hard coded value is used for illustration, which is not recommended in real code. (9) As with most µC/OS-III services, |
...