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. More...
 
void * csp_buffer_get (size_t size)
 Get a reference to a free buffer. More...
 
void * csp_buffer_get_isr (size_t buf_size)
 Get a reference to a free buffer. More...
 
void csp_buffer_free (void *packet)
 Free a buffer after use. More...
 
void csp_buffer_free_isr (void *packet)
 Free a buffer after use in ISR context. More...
 
void * csp_buffer_clone (void *buffer)
 Clone an existing packet and increase/decrease cloned packet size. More...
 
int csp_buffer_remaining (void)
 Return how many buffers that are currently free. More...
 
int csp_buffer_size (void)
 Return the size of the CSP buffers. More...
 

Function Documentation

void* csp_buffer_clone ( void *  buffer)

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

Parameters
bufferExisting buffer to clone.
void csp_buffer_free ( void *  packet)

Free a buffer after use.

Parameters
packetpointer to memory area, must be acquired by csp_buffer_get().
void csp_buffer_free_isr ( void *  packet)

Free a buffer after use in ISR context.

Parameters
packetpointer to memory area, must be acquired by csp_buffer_get().
void* csp_buffer_get ( size_t  size)

Get a reference to a free buffer.

This function can only be called from task context.

Parameters
sizeSpecify what data-size you will put in the buffer
Returns
pointer to a free csp_packet_t or NULL if out of memory
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.

Parameters
buf_sizeSpecify what data-size you will put in the buffer
Returns
pointer to a free csp_packet_t or NULL if out of memory
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.

Parameters
countNumber of buffers to allocate
sizeBuffer size in bytes.
Returns
CSP_ERR_NONE if malloc() succeeded, CSP_ERR message otherwise.
int csp_buffer_remaining ( void  )

Return how many buffers that are currently free.

Returns
number of free buffers
int csp_buffer_size ( void  )

Return the size of the CSP buffers.

Returns
size of CSP buffers