11.07.2015 Views

CrossWorks for ARM User Guide

CrossWorks for ARM User Guide

CrossWorks for ARM User Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

27Memory areasMemory areas provide your application with dynamic allocation of fixed sizedmemory blocks. Memory areas should be used in preference to the standard C librarymalloc and free functions if the calling task (or interrupt service routine) cannot block.You allocate a memory area by declaring it as a C variableCTL_MEMORY_AREA_t m1;A message queue is initialised using the ctl_memory_area_init function.unsigned mem[20];…ctl_message_queue_init(&m1, mem, 2, 10);This example uses an 20 element array <strong>for</strong> the memory. The array is split into 10blocks of each of which two words in size.You can allocate a memory block from a memory area using thectl_memory_area_allocate function. If the memory block cannot be allocated thenzero is returned.unsigned *block = ctl_memory_area_allocate(&m1);if (block)// block has been allocatedelse// no block has been allocatedWhen you have finished with a memory block you should return it to the memoryarea from which it was allocated using ctl_memory_area_free:ctl_memory_area_free(&m1, block);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!