Buffer

nRF5 SDK v10.0.0

nRF51 SDK v10.0.0

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_buffer The buffer instance acquire from.
[in] n_blocks The number of contiguous blocks to acquire.
Returns
The id of the acquired block, if successful.
Return values
BUFFER_INVALID_ID If 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_buffer The buffer instance to initialize.
[in] p_buffer_memory The memory this buffer will use.
[in] buffer_memory_size The size of p_buffer_memory. This must be at least n_blocks*block_size.
[in] p_mutex_memory The memory for the mutexes. This must be at least MUTEX_STORAGE_SIZE(n_blocks) .
[in] mutex_memory_size The size of p_mutex_memory.
[in] n_blocks The number of blocks in the buffer.
[in] block_size The size of each block.
Return values
NRF_SUCCESS Successfully initialized buffer instance.
NRF_ERROR_INVALID_PARAM A 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_buffer The buffer instance get from.
[in] id The 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
NULL If 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_buffer The buffer instance containing the block to release.
[in] id The id of the block to release.

Please send us your feedback about the documentation! For technical questions, visit the Nordic Developer Zone .