Jeroen Lodder / xIFO
Embed: (wiki syntax)

« Back to documentation index

Xifo< xifo_dtype > Class Template Reference

Xifo< xifo_dtype > Class Template Reference

Circular Buffer object. More...

#include <xIFO.h>

Public Member Functions

 Xifo (uint32_t size)
 Initialise xifo.
 Xifo (uint32_t size, xifo_dtype *sp)
 Initialise xifo.
 ~Xifo (void)
 Deinitialise (and deallocate) buffer xifo.
void clear (void)
 Clear buffer memory pool.
void reset (void)
 Reset buffer.
uint32_t write (xifo_dtype data)
 Write to buffer.
xifo_dtype read_lr (uint32_t index)
 Read from buffer (lr) Least Recent oriented (fifo)
xifo_dtype pop_lr ()
 Pop (lr) least recent from buffer (fifo)
xifo_dtype read_mr (uint32_t index)
 Read from buffer (mr) Most Recent oriented (filo)
xifo_dtype pop_mr ()
 Pop (mr) most recent from buffer (filo)
uint32_t size ()
 Get buffer size.
uint32_t used ()
 Get number of used elements.
uint32_t full ()
 Get full flag.
uint32_t free ()
 Get number of free elements.

Detailed Description

template<class xifo_dtype>
class Xifo< xifo_dtype >

Circular Buffer object.

This class holds the object of a circular buffer

Definition at line 75 of file xIFO.h.


Constructor & Destructor Documentation

Xifo ( uint32_t  size )

Initialise xifo.

Note:
Does not clear memory pool.
Parameters:
[in]Numberof elements buffer can hold (size).

Definition at line 83 of file xIFO.h.

Xifo ( uint32_t  size,
xifo_dtype *  sp 
)

Initialise xifo.

Note:
Does not clear memory pool.
Parameters:
[in]Numberof elements buffer can hold (size).
[in]Startof pre-allocated memory pool.

Definition at line 100 of file xIFO.h.

~Xifo ( void   )

Deinitialise (and deallocate) buffer xifo.

Note:
Does not clear memory pool.

Definition at line 115 of file xIFO.h.


Member Function Documentation

void clear ( void   )

Clear buffer memory pool.

Note:
Must be used on initialised buffer object.
Parameters:
[in]cPointer to xifo_SIZETYPE_t object.

Definition at line 127 of file xIFO.h.

uint32_t free (  )

Get number of free elements.

Definition at line 355 of file xIFO.h.

uint32_t full (  )

Get full flag.

Definition at line 354 of file xIFO.h.

xifo_dtype pop_lr (  )

Pop (lr) least recent from buffer (fifo)

Note:
Buffer state will be altered
Warning:
Consider this opertaion as atomic!

Read and remove the least recently added from the buffer. Using this results in a fifo type of buffer.

Parameters:
[in]cPointer to xifo_SIZETYPE_t used for configuration.
Returns:
Contents of element or 0 if failed (element can hold 0)

Definition at line 243 of file xIFO.h.

xifo_dtype pop_mr (  )

Pop (mr) most recent from buffer (filo)

Note:
Buffer state will be altered
Warning:
Consider this opertaion as atomic!

Read and remove the most recently added from the buffer. Using this results in a stack type of buffer.

Parameters:
[in]cPointer to xifo_SIZETYPE_t used for configuration.
Returns:
Contents of element or 0 if failed (element can hold 0)

Definition at line 324 of file xIFO.h.

xifo_dtype read_lr ( uint32_t  index )

Read from buffer (lr) Least Recent oriented (fifo)

Note:
Buffer state will be preserved
Warning:
Consider this opertaion as atomic!

Read n elements from the oldest element to the most recent. As for index[0] the least recently added element is returned. And for index[count] the most recent element is returned. This makes it possible to peek in fifo.

Parameters:
[in]cPointer to xifo_SIZETYPE_t used for configuration.
[in]indexIndex relative from least recent
Returns:
Contents of element or 0 if failed (element can hold 0)

Definition at line 208 of file xIFO.h.

xifo_dtype read_mr ( uint32_t  index )

Read from buffer (mr) Most Recent oriented (filo)

Note:
Buffer state will be preserved
Warning:
Consider this opertaion as atomic!

Read n elements back in time. As for index[0] the most recently added element is returned. And for index[count] the oldest element is returned. This makes it possible to keep history. For DSP application.

Parameters:
[in]cPointer to xifo_SIZETYPE_t used for configuration.
[in]indexIndex relative from most recent
Returns:
Contents of element or 0 if failed (element can hold 0)

Definition at line 290 of file xIFO.h.

void reset ( void   )

Reset buffer.

Note:
Must be used on initialised buffer object.
Parameters:
[in]cPointer to xifo_SIZETYPE_t object.

Definition at line 140 of file xIFO.h.

uint32_t size (  )

Get buffer size.

Definition at line 352 of file xIFO.h.

uint32_t used (  )

Get number of used elements.

Definition at line 353 of file xIFO.h.

uint32_t write ( xifo_dtype  data )

Write to buffer.

Note:
Readpointer is automatically set to the last added element.
Warning:
Consider this opertaion as atomic!

Adds a value to the buffer. Automatically overwrites oldest elements when full.

Parameters:
[in]cPointer to xifo_SIZETYPE_t used for configuration.
[in]dataData to add to buffer
Returns:
Number of free buffer elements

Definition at line 167 of file xIFO.h.