R1 code for micro:bit based train controller code, requires second micro:bit running rx code to operate - see https://meanderingpi.wordpress.com/ for more information

Fork of nrf51-sdk by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

Buffer

An internal module of Peer_manager. More...

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.
uint8_t pm_buffer_block_acquire (pm_buffer_t *p_buffer, uint32_t n_blocks)
 Function for acquiring a buffer block in a buffer.
uint8_t * pm_buffer_ptr_get (pm_buffer_t *p_buffer, uint8_t id)
 Function for getting a pointer to a specific buffer block.
void pm_buffer_release (pm_buffer_t *p_buffer, uint8_t id)
 Function for releasing a buffer block.

Detailed Description

An internal module of Peer_manager.

This module provides a simple buffer.


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.

Definition at line 79 of file pm_buffer.c.

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.

Definition at line 48 of file pm_buffer.c.

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.

Definition at line 115 of file pm_buffer.c.

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.

Definition at line 134 of file pm_buffer.c.