Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /***************************************************************************//**
sahilmgandhi 18:6a4db94011d3 2 * @file buffer_pool_allocator.h
sahilmgandhi 18:6a4db94011d3 3 * @brief This is a simple memory allocator that uses a build time defined pool
sahilmgandhi 18:6a4db94011d3 4 * of constant sized buffers. It's a very simple allocator, but one that can
sahilmgandhi 18:6a4db94011d3 5 * be easily used in any application.
sahilmgandhi 18:6a4db94011d3 6 *
sahilmgandhi 18:6a4db94011d3 7 * @copyright Copyright 2015 Silicon Laboratories, Inc. http://www.silabs.com
sahilmgandhi 18:6a4db94011d3 8 ******************************************************************************/
sahilmgandhi 18:6a4db94011d3 9
sahilmgandhi 18:6a4db94011d3 10 #ifndef BUFFER_POOL_ALLOCATOR_H__
sahilmgandhi 18:6a4db94011d3 11 #define BUFFER_POOL_ALLOCATOR_H__
sahilmgandhi 18:6a4db94011d3 12
sahilmgandhi 18:6a4db94011d3 13 // Get the standard include types
sahilmgandhi 18:6a4db94011d3 14 #include <stdint.h>
sahilmgandhi 18:6a4db94011d3 15
sahilmgandhi 18:6a4db94011d3 16 /**
sahilmgandhi 18:6a4db94011d3 17 * Allocate a buffer with at least the number of bytes specified. If there is
sahilmgandhi 18:6a4db94011d3 18 * not enough space then this function will return NULL.
sahilmgandhi 18:6a4db94011d3 19 * @param size The number of bytes to allocate for this buffer
sahilmgandhi 18:6a4db94011d3 20 * @return Returns a handle to a buffer at least size bytes long or NULL if no
sahilmgandhi 18:6a4db94011d3 21 * buffer could be allocated.
sahilmgandhi 18:6a4db94011d3 22 */
sahilmgandhi 18:6a4db94011d3 23 void* memoryAllocate(uint32_t size);
sahilmgandhi 18:6a4db94011d3 24
sahilmgandhi 18:6a4db94011d3 25 /**
sahilmgandhi 18:6a4db94011d3 26 * Free the buffer pointed to by handle. This will only decrement the reference
sahilmgandhi 18:6a4db94011d3 27 * counter for this buffer. The memory is not freed until the reference counter
sahilmgandhi 18:6a4db94011d3 28 * reaches zero.
sahilmgandhi 18:6a4db94011d3 29 * @param handle The handle to free. Must match the value returned by
sahilmgandhi 18:6a4db94011d3 30 * the memoryAllocate() function.
sahilmgandhi 18:6a4db94011d3 31 */
sahilmgandhi 18:6a4db94011d3 32 void memoryFree(void *handle);
sahilmgandhi 18:6a4db94011d3 33
sahilmgandhi 18:6a4db94011d3 34 /**
sahilmgandhi 18:6a4db94011d3 35 * Take a memory handle and get the data pointer associated with it. This will
sahilmgandhi 18:6a4db94011d3 36 * return NULL if passed an invalid or unallocated handle.
sahilmgandhi 18:6a4db94011d3 37 * @param handle The handle to get the pointer for. Must match the value
sahilmgandhi 18:6a4db94011d3 38 * returned by the memoryAllocate() function.
sahilmgandhi 18:6a4db94011d3 39 */
sahilmgandhi 18:6a4db94011d3 40 void *memoryPtrFromHandle(void *handle);
sahilmgandhi 18:6a4db94011d3 41
sahilmgandhi 18:6a4db94011d3 42 /**
sahilmgandhi 18:6a4db94011d3 43 * Increment the reference counter on the memory pointed to by handle. After
sahilmgandhi 18:6a4db94011d3 44 * doing this there will have to be an additional call to memoryFree() to
sahilmgandhi 18:6a4db94011d3 45 * release the memory.
sahilmgandhi 18:6a4db94011d3 46 * @param handle The handle to the object which needs its reference count
sahilmgandhi 18:6a4db94011d3 47 * increased. Must match the value returned by the memoryAllocate() function.
sahilmgandhi 18:6a4db94011d3 48 */
sahilmgandhi 18:6a4db94011d3 49 void memoryTakeReference(void *handle);
sahilmgandhi 18:6a4db94011d3 50
sahilmgandhi 18:6a4db94011d3 51 #endif // BUFFER_POOL_ALLOCATOR_H__