AIROC™ BTSDK v4.4 - Documentation | ||||
Helper APIs to create heaps and pools and allocate/free buffers from those pools or heaps. More...
Data Structures | |
struct | wiced_bt_pool_statistics_s |
wiced bt buffer pool statistics More... | |
struct | wiced_bt_heap_statistics_s |
wiced bt heap statistics More... | |
struct | wiced_bt_buffer_q_t |
This queue is a general purpose buffer queue, for application use. More... | |
Macros | |
#define | memcpy __aeabi_memcpy |
#define | memset(dest, val, len) __aeabi_memset(dest, len, val) |
#define | memmove mpaf_memmove |
#define | wiced_bt_buffer_pool_t wiced_bt_pool_t |
#define | WICED_DEFAULT_HEAP ((wiced_bt_heap_t *)NULL) |
If an application wants to get a buffer from the default heap, he can use this. More... | |
#define | wiced_memory_permanent_allocate(a) dynamic_memory_AllocatePermanent(a, WICED_FALSE) |
Allocates memory for permanent usage. More... | |
#define | wiced_bt_get_buffer(size) wiced_bt_get_buffer_from_heap(WICED_DEFAULT_HEAP, (size)) |
Allocates a buffer from the DEFAULT heap . More... | |
Typedefs | |
typedef void | wiced_bt_buffer_t |
WICED BT Buffer. | |
typedef struct t_wiced_bt_pool | wiced_bt_pool_t |
WICED BT Pool. | |
typedef struct t_wiced_bt_heap | wiced_bt_heap_t |
WICED BT Heap. | |
typedef struct wiced_bt_pool_statistics_s | wiced_bt_pool_statistics_t |
wiced bt buffer pool statistics | |
typedef struct wiced_bt_heap_statistics_s | wiced_bt_heap_statistics_t |
wiced bt heap statistics | |
Functions | |
void * | __aeabi_memcpy (void *dst, const void *src, int len) |
void * | __aeabi_memset (void *ptr, int value, int num) |
void * | mpaf_memmove (void *destination, const void *source, int num) |
void * | dynamic_memory_AllocatePermanent (uint32_t size_bytes, wiced_bool_t allow_use_by_minidriver) |
uint32_t | wiced_memory_get_free_bytes (void) |
Returns the number of free bytes of RAM left. More... | |
wiced_bt_heap_t * | wiced_bt_create_heap (const char *name, void *p_area, int size, wiced_bt_lock_t *p_lock, wiced_bool_t b_make_default) |
Initializes dynamic memory area. More... | |
void | wiced_bt_delete_heap (wiced_bt_heap_t *p_heap) |
Deletes the heap created with wiced_bt_create_heap. More... | |
wiced_bt_pool_t * | wiced_bt_create_pool (const char *name, uint32_t buffer_size, uint32_t buffer_cnt, wiced_bt_lock_t *p_lock) |
Creates a buffer pool for application usage. More... | |
void | wiced_bt_delete_pool (wiced_bt_pool_t *p_pool) |
Deletes a buffer pool created using wiced_bt_create_pool. More... | |
wiced_bt_buffer_t * | wiced_bt_get_buffer_from_pool (wiced_bt_pool_t *p_pool) |
Get buffer from requested pool. More... | |
wiced_bt_buffer_t * | wiced_bt_get_buffer_from_heap (wiced_bt_heap_t *p_heap, uint32_t size) |
Allocates a buffer from the requested heap. More... | |
uint32_t | wiced_bt_get_pool_free_count (wiced_bt_pool_t *p_pool) |
To get the number of buffers available in the pool. More... | |
uint32_t | wiced_bt_get_largest_heap_buffer (wiced_bt_heap_t *p_heap) |
To get the size of the largest buffer available in the heap. More... | |
uint32_t | wiced_bt_get_largest_stack_heap_buffer (void) |
To get the size of the largest buffer available in the stack heap. More... | |
void | wiced_bt_free_buffer (wiced_bt_buffer_t *p_buf) |
Frees a buffer back to the pool or heap it came from. More... | |
uint32_t | wiced_bt_get_buffer_size (wiced_bt_buffer_t *p_buf) |
Gets the buffer size. More... | |
void | wiced_bt_init_q (wiced_bt_buffer_q_t *p_q, wiced_bt_lock_t *p_lock) |
Called by an application to initialize a WICED buffer queue. More... | |
void | wiced_bt_enqueue (wiced_bt_buffer_q_t *p_q, wiced_bt_buffer_t *p_buf) |
Enqueue a buffer at the tail of the queue. More... | |
void | wiced_bt_enqueue_head (wiced_bt_buffer_q_t *p_q, wiced_bt_buffer_t *p_buf) |
Enqueue a buffer at the head of the queue. More... | |
wiced_bt_buffer_t * | wiced_bt_dequeue (wiced_bt_buffer_q_t *p_q) |
Dequeues a buffer from the head of a queue. More... | |
wiced_bt_buffer_t * | wiced_bt_remove_from_queue (wiced_bt_buffer_q_t *p_q, wiced_bt_buffer_t *p_buf) |
Dequeue a buffer from the middle of the queue. More... | |
wiced_bt_buffer_t * | wiced_bt_getfirst (wiced_bt_buffer_q_t *p_q) |
Return a pointer to the first buffer in a queue. More... | |
wiced_bt_buffer_t * | wiced_bt_getlast (wiced_bt_buffer_q_t *p_q) |
Return a pointer to the last buffer in a queue. More... | |
wiced_bt_buffer_t * | wiced_bt_getnext (wiced_bt_buffer_t *p_buf) |
Return a pointer to the next buffer in a queue. More... | |
uint32_t | wiced_bt_queue_is_empty (wiced_bt_buffer_q_t *p_q) |
Check the status of a queue. More... | |
uint32_t | wiced_bt_queue_get_count (wiced_bt_buffer_q_t *p_q) |
Get the number of items in the queue. More... | |
wiced_bt_buffer_t * | wiced_memory_alloc_long_term_mem_block (int size, const char *block_name) |
Allocate long term memory, typically used for control blocks allocated through config, not expected to be freed during the lifetime of the application. More... | |
void | wiced_memory_free_long_term_mem_block (wiced_bt_buffer_t *p_mem) |
Free long term memory, used to free memory allocated with wiced_memory_alloc_long_term_mem_block, typically called during application shutdown. More... | |
wiced_bool_t | wiced_bt_get_heap_statistics (void *p_heap, wiced_bt_heap_statistics_t *p_stats) |
Get heap stats. More... | |
wiced_bool_t | wiced_bt_get_heap_statistics_with_index (int index, wiced_bt_heap_statistics_t *p_stats) |
Get heap stats of heap at index. More... | |
wiced_result_t | wiced_bt_get_pool_statistics (wiced_bt_pool_t *p_pool, wiced_bt_pool_statistics_t *p_stats) |
Get pool stats. More... | |
void | wiced_set_exception_callback (pf_wiced_exception pf_handler) |
Set the exception callback. More... | |
Helper APIs to create heaps and pools and allocate/free buffers from those pools or heaps.
When a heap or a pool is created, this utility allocates required chunk of memory from the system and manages it for the creator.
#define wiced_bt_get_buffer | ( | size | ) | wiced_bt_get_buffer_from_heap(WICED_DEFAULT_HEAP, (size)) |
Allocates a buffer from the DEFAULT heap .
[in] | size | : size to be allocated |
#define WICED_DEFAULT_HEAP ((wiced_bt_heap_t *)NULL) |
If an application wants to get a buffer from the default heap, he can use this.
#define wiced_memory_permanent_allocate | ( | a | ) | dynamic_memory_AllocatePermanent(a, WICED_FALSE) |
Allocates memory for permanent usage.
size | The size of the memory to be allocated |
wiced_bt_heap_t* wiced_bt_create_heap | ( | const char * | name, |
void * | p_area, | ||
int | size, | ||
wiced_bt_lock_t * | p_lock, | ||
wiced_bool_t | b_make_default | ||
) |
Initializes dynamic memory area.
Application reserves an area for dynamic variable memory allocations with this call. Application can now allocate variable sized buffers as against fixed sized buffer allocations from the pools initialized with calls to wiced_bt_create_pool and allocated using wiced_bt_get_buffer_from_pool.
[in] | name | : Friendly name of the heap |
[in] | p_area | : Pointer to area to use for the heap. If NULL, WICED will allocate the area. |
[in] | size | : Size the area passed in. If no area passed in, this is the size of the heap desired. |
[in] | p_lock | : Pointers to lock functions to use during heap manipulation. If NULL, then it is assumed that the application handles disabling of preemption. |
[in] | b_make_default | Flag as to whether the heap will be the default heap. |
wiced_bt_pool_t* wiced_bt_create_pool | ( | const char * | name, |
uint32_t | buffer_size, | ||
uint32_t | buffer_cnt, | ||
wiced_bt_lock_t * | p_lock | ||
) |
Creates a buffer pool for application usage.
[in] | name | : Friendly name of the heap |
[in] | buffer_size | Size of the buffers in the pool |
[in] | buffer_cnt | : Number of buffers in the pool |
[in] | p_lock | : Pointers to lock functions to use during heap manipulation. If NULL, then it is assumed that the application handles disabling of preemption. |
void wiced_bt_delete_heap | ( | wiced_bt_heap_t * | p_heap | ) |
Deletes the heap created with wiced_bt_create_heap.
The heap area is freed back to the platform in case the wiced_bt_create_heap was called with p_area set to NULL.
[in] | p_heap | : Heap created with wiced_bt_create_heap |
void wiced_bt_delete_pool | ( | wiced_bt_pool_t * | p_pool | ) |
Deletes a buffer pool created using wiced_bt_create_pool.
[in] | p_pool | : pointer of type wiced_bt_pool_t returned through a call to wiced_bt_create_pool |
wiced_bt_buffer_t* wiced_bt_dequeue | ( | wiced_bt_buffer_q_t * | p_q | ) |
Dequeues a buffer from the head of a queue.
[in] | p_q | : pointer to a queue. |
void wiced_bt_enqueue | ( | wiced_bt_buffer_q_t * | p_q, |
wiced_bt_buffer_t * | p_buf | ||
) |
Enqueue a buffer at the tail of the queue.
[in] | p_q | : pointer to a queue. |
[in] | p_buf | : address of the buffer to enqueue |
void wiced_bt_enqueue_head | ( | wiced_bt_buffer_q_t * | p_q, |
wiced_bt_buffer_t * | p_buf | ||
) |
Enqueue a buffer at the head of the queue.
[in] | p_q | : pointer to a queue. |
[in] | p_buf | : address of the buffer to enqueue |
void wiced_bt_free_buffer | ( | wiced_bt_buffer_t * | p_buf | ) |
Frees a buffer back to the pool or heap it came from.
[in] | p_buf | : pointer to the start of the (pool/heap) buffer to be freed |
wiced_bt_buffer_t* wiced_bt_get_buffer_from_heap | ( | wiced_bt_heap_t * | p_heap, |
uint32_t | size | ||
) |
Allocates a buffer from the requested heap.
[in] | p_heap | : pointer to heap from which to get the buffer |
[in] | size | : size to be allocated |
wiced_bt_buffer_t* wiced_bt_get_buffer_from_pool | ( | wiced_bt_pool_t * | p_pool | ) |
Get buffer from requested pool.
Allocates a buffer from the requested pool.
[in] | p_pool | : pointer to pool from which to get the buffer |
uint32_t wiced_bt_get_buffer_size | ( | wiced_bt_buffer_t * | p_buf | ) |
Gets the buffer size.
[in] | p_buf | : pointer to the start of the buffer |
wiced_bool_t wiced_bt_get_heap_statistics | ( | void * | p_heap, |
wiced_bt_heap_statistics_t * | p_stats | ||
) |
Get heap stats.
[in] | p_heap | : heap pointer (output of wiced_bt_create_heap) |
[out] | p_stats | : pointer to receive the heap statistics |
wiced_bool_t wiced_bt_get_heap_statistics_with_index | ( | int | index, |
wiced_bt_heap_statistics_t * | p_stats | ||
) |
Get heap stats of heap at index.
Application calls the function in a loop incrementing the index till the function returns WICED_FALSE
[in] | index | : index of heap, starts from 0 |
[out] | p_stats | : pointer to receive the heap statistics |
uint32_t wiced_bt_get_largest_heap_buffer | ( | wiced_bt_heap_t * | p_heap | ) |
To get the size of the largest buffer available in the heap.
[in] | p_heap | : heap pointer |
uint32_t wiced_bt_get_largest_stack_heap_buffer | ( | void | ) |
To get the size of the largest buffer available in the stack heap.
uint32_t wiced_bt_get_pool_free_count | ( | wiced_bt_pool_t * | p_pool | ) |
To get the number of buffers available in the pool.
[in] | p_pool | : pool pointer |
wiced_result_t wiced_bt_get_pool_statistics | ( | wiced_bt_pool_t * | p_pool, |
wiced_bt_pool_statistics_t * | p_stats | ||
) |
Get pool stats.
[in] | p_pool | : pool pointer (output of wiced_bt_create_pool) |
[out] | p_stats | : pointer to receive the pool statistics |
wiced_bt_buffer_t* wiced_bt_getfirst | ( | wiced_bt_buffer_q_t * | p_q | ) |
Return a pointer to the first buffer in a queue.
[in] | p_q | : pointer to a queue. |
wiced_bt_buffer_t* wiced_bt_getlast | ( | wiced_bt_buffer_q_t * | p_q | ) |
Return a pointer to the last buffer in a queue.
[in] | p_q | : pointer to a queue. |
wiced_bt_buffer_t* wiced_bt_getnext | ( | wiced_bt_buffer_t * | p_buf | ) |
Return a pointer to the next buffer in a queue.
[in] | p_buf | : pointer to the buffer to find the next one from. |
void wiced_bt_init_q | ( | wiced_bt_buffer_q_t * | p_q, |
wiced_bt_lock_t * | p_lock | ||
) |
Called by an application to initialize a WICED buffer queue.
Pointers to lock and unlock functions may be NULL if application has handled preemption outside of the queue management code.
uint32_t wiced_bt_queue_get_count | ( | wiced_bt_buffer_q_t * | p_q | ) |
Get the number of items in the queue.
[in] | p_q | : pointer to a queue. |
uint32_t wiced_bt_queue_is_empty | ( | wiced_bt_buffer_q_t * | p_q | ) |
Check the status of a queue.
[in] | p_q | : pointer to a queue. |
wiced_bt_buffer_t* wiced_bt_remove_from_queue | ( | wiced_bt_buffer_q_t * | p_q, |
wiced_bt_buffer_t * | p_buf | ||
) |
Dequeue a buffer from the middle of the queue.
[in] | p_q | : pointer to a queue. |
[in] | p_buf | : address of the buffer to dequeue |
wiced_bt_buffer_t* wiced_memory_alloc_long_term_mem_block | ( | int | size, |
const char * | block_name | ||
) |
Allocate long term memory, typically used for control blocks allocated through config, not expected to be freed during the lifetime of the application.
[in] | size | : size of memory to be allocated |
[in] | block_name | friendly name of memory block to be allocated. |
void wiced_memory_free_long_term_mem_block | ( | wiced_bt_buffer_t * | p_mem | ) |
Free long term memory, used to free memory allocated with wiced_memory_alloc_long_term_mem_block, typically called during application shutdown.
[in] | p_mem | : pointer memory to be freed |
uint32_t wiced_memory_get_free_bytes | ( | void | ) |
Returns the number of free bytes of RAM left.
void wiced_set_exception_callback | ( | pf_wiced_exception | pf_handler | ) |
Set the exception callback.
[in] | pf_handler | : Exception callback function |