Buffer API

group Buffer

Functions

int csp_buffer_init(int count, int size)

Start the buffer handling system You must specify the number for buffers and the size.

All buffers are fixed size so you must specify the size of your largest buffer.

Return
CSP_ERR_NONE if malloc() succeeded, CSP_ERR message otherwise.
Parameters
  • count: Number of buffers to allocate
  • size: Buffer size in bytes.

void csp_buffer_cleanup(void)

Shutdown the buffer handling system and free all buffers.

void *csp_buffer_get(size_t size)

Get a reference to a free buffer.

This function can only be called from task context.

Return
pointer to a free csp_packet_t or NULL if out of memory
Parameters
  • size: Specify what data-size you will put in the buffer

void *csp_buffer_get_isr(size_t buf_size)

Get a reference to a free buffer.

This function can only be called from interrupt context.

Return
pointer to a free csp_packet_t or NULL if out of memory
Parameters
  • buf_size: Specify what data-size you will put in the buffer

void csp_buffer_free(void *packet)

Free a buffer after use.

Parameters

void csp_buffer_free_isr(void *packet)

Free a buffer after use in ISR context.

Parameters

void *csp_buffer_clone(void *buffer)

Clone an existing packet and increase/decrease cloned packet size.

Parameters
  • buffer: Existing buffer to clone.

int csp_buffer_remaining(void)

Return how many buffers that are currently free.

Return
number of free buffers

int csp_buffer_size(void)

Return the size of the CSP buffers.

Return
size of CSP buffers