nRF51 SDK v10.0.0
Data Structures | Macros | Functions

An internal module of Peer Manager. This module provides a simple buffer. More...

Data Structures

struct  pm_buffer_t
 

Macros

#define BUFFER_INVALID_ID   0xFF
 
#define PM_BUFFER_INIT(p_buffer, n_blocks, block_size, err_code)
 

Functions

ret_code_t pm_buffer_init (pm_buffer_t *p_buffer, uint8_t *p_buffer_memory, uint32_t buffer_memory_size, uint8_t *p_mutex_memory, uint32_t mutex_memory_size, uint32_t n_blocks, uint32_t block_size)
 Function for initializing a buffer instance. More...
 
uint8_t pm_buffer_block_acquire (pm_buffer_t *p_buffer, uint32_t n_blocks)
 Function for acquiring a buffer block in a buffer. More...
 
uint8_t * pm_buffer_ptr_get (pm_buffer_t *p_buffer, uint8_t id)
 Function for getting a pointer to a specific buffer block. More...
 
void pm_buffer_release (pm_buffer_t *p_buffer, uint8_t id)
 Function for releasing a buffer block. More...
 

Detailed Description

An internal module of Peer Manager. This module provides a simple buffer.

Macro Definition Documentation

#define PM_BUFFER_INIT (   p_buffer,
  n_blocks,
  block_size,
  err_code 
)
Value:
do \
{ \
static uint8_t buffer_memory[(n_blocks) * (block_size)]; \
static uint8_t mutex_memory[MUTEX_STORAGE_SIZE(n_blocks)]; \
err_code = pm_buffer_init((p_buffer), \
buffer_memory, \
(n_blocks) * (block_size), \
mutex_memory, \
MUTEX_STORAGE_SIZE(n_blocks), \
(n_blocks), \
(block_size)); \
} while(0)

Function Documentation

uint8_t pm_buffer_block_acquire ( pm_buffer_t p_buffer,
uint32_t  n_blocks 
)

Function for acquiring a buffer block in a buffer.

Parameters
[in]p_bufferThe buffer instance acquire from.
[in]n_blocksThe number of contiguous blocks to acquire.
Returns
The id of the acquired block, if successful.
Return values
BUFFER_INVALID_IDIf unsuccessful.
ret_code_t pm_buffer_init ( pm_buffer_t p_buffer,
uint8_t *  p_buffer_memory,
uint32_t  buffer_memory_size,
uint8_t *  p_mutex_memory,
uint32_t  mutex_memory_size,
uint32_t  n_blocks,
uint32_t  block_size 
)

Function for initializing a buffer instance.

Parameters
[out]p_bufferThe buffer instance to initialize.
[in]p_buffer_memoryThe memory this buffer will use.
[in]buffer_memory_sizeThe size of p_buffer_memory. This must be at least n_blocks*block_size.
[in]p_mutex_memoryThe memory for the mutexes. This must be at least MUTEX_STORAGE_SIZE(n_blocks).
[in]mutex_memory_sizeThe size of p_mutex_memory.
[in]n_blocksThe number of blocks in the buffer.
[in]block_sizeThe size of each block.
Return values
NRF_SUCCESSSuccessfully initialized buffer instance.
NRF_ERROR_INVALID_PARAMA parameter was 0 or NULL or a size was too small.
uint8_t* pm_buffer_ptr_get ( pm_buffer_t p_buffer,
uint8_t  id 
)

Function for getting a pointer to a specific buffer block.

Parameters
[in]p_bufferThe buffer instance get from.
[in]idThe id of the buffer to get the pointer for.
Returns
A pointer to the buffer for the specified id, if the id is valid.
Return values
NULLIf the id is invalid.
void pm_buffer_release ( pm_buffer_t p_buffer,
uint8_t  id 
)

Function for releasing a buffer block.

Parameters
[in]p_bufferThe buffer instance containing the block to release.
[in]idThe id of the block to release.

This document was last updated on Mon Nov 9 2015.
Please send us your feedback about the documentation! For technical questions, visit the Nordic Developer Zone.