ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
isf_fifo.c File Reference
#include "isf.h"
#include "isf_fifo.h"
#include "isf_util.h"
Include dependency graph for isf_fifo.c:

Go to the source code of this file.

Macros

#define ALLOCATED_BUFFER_BIT   ((uint8)(1<<0))
 
#define FIFO_FULL_BIT   ((uint8)(1<<7))
 
#define FIFO_FULL_CLR_MASK   ((uint8)~FIFO_FULL_BIT)
 

Functions

isf_fifo_status_t isf_fifo_init (isf_fifo_t *pFifo, void *pData, uint16 sampleSize, uint16 bufferCapacity)
 Initializes a new fifo structure with a provided buffer. More...
 
isf_fifo_status_t isf_fifo_alloc (isf_fifo_t *pFifo, uint16 sampleSize, uint16 bufferCapacity)
 Convenience function to initialize a fifo structure and allocate a new fifo buffer. More...
 
isf_fifo_status_t isf_fifo_free (isf_fifo_t *pFifo)
 free a fifo's sample buffer. More...
 
isf_fifo_status_t isf_fifo_resize (isf_fifo_t *pFifo, uint16 newCapacity)
 Routine to change the supported fifo depth. More...
 
uint16 isf_fifo_get_buffer_size (isf_fifo_t *pFifo)
 Routine to query the current fifo buffer size (bytes) More...
 
isf_fifo_status_t isf_fifo_data_copy (isf_fifo_t *pFifo, void *samplePtr)
 Routine to copy the whole sample buffer. More...
 
isf_fifo_status_t isf_fifo_lock (isf_fifo_t *pFifo)
 Lock a sample buffer for exclusive access. More...
 
isf_fifo_status_t isf_fifo_try_lock (isf_fifo_t *pFifo)
 Attempt to lock a sample buffer for exclusive access. More...
 
isf_fifo_status_t isf_fifo_unlock (isf_fifo_t *pFifo)
 Release the exclusive access lock on a sample buffer. More...
 
isf_fifo_status_t isf_fifo_el_clear (isf_fifo_t *pFifo)
 Routine to clear the fifo. More...
 
void * isf_fifo_el_get_insert_pointer (isf_fifo_t *pFifo)
 Routine returns the insert pointer for direct access. More...
 
isf_fifo_status_t isf_fifo_el_increment (isf_fifo_t *pFifo)
 Routine increments the insert pointer after direct access. More...
 
isf_fifo_status_t isf_fifo_el_traverse (isf_fifo_t *pFifo, void **pSamplePtr)
 Routine to traverse a fifo To initiate the traversal set pSamplePtr to NULL. The function will set the pointer to the first available sample and returns ISF_SUCCESS. Subsequent calls will increment the pointer to each available sample and return ISF_SUCCESS. When ISF_SUCCESS is returned, pSamplePtr may be dereferenced to obtain a fifo entry. When no more samples are available, the function returns ISF_FIFO_NO_MORE_ENTRIES. More...
 

Macro Definition Documentation

#define ALLOCATED_BUFFER_BIT   ((uint8)(1<<0))

Definition at line 17 of file isf_fifo.c.

Referenced by isf_fifo_free(), isf_fifo_init(), and isf_fifo_resize().

#define FIFO_FULL_BIT   ((uint8)(1<<7))

Definition at line 18 of file isf_fifo.c.

Referenced by isf_fifo_el_increment(), and isf_fifo_el_traverse().

#define FIFO_FULL_CLR_MASK   ((uint8)~FIFO_FULL_BIT)

Definition at line 19 of file isf_fifo.c.

Referenced by isf_fifo_el_clear().

Function Documentation

isf_fifo_status_t isf_fifo_alloc ( isf_fifo_t pFifo,
uint16  sampleSize,
uint16  bufferCapacity 
)

Convenience function to initialize a fifo structure and allocate a new fifo buffer.

Initializes a fifo structure and allocates a new fifo buffer.

Definition at line 71 of file isf_fifo.c.

References isf_fifo_init().

Here is the call graph for this function:

isf_fifo_status_t isf_fifo_data_copy ( isf_fifo_t pFifo,
void *  samplePtr 
)

Routine to copy the whole sample buffer.

Definition at line 154 of file isf_fifo.c.

References isf_fifo_t::bufferLock, ISF_FIFO_ERR_NO_INIT, isf_mem_copy(), ISF_SUCCESS, isf_fifo_t::pDataBuffer, and isf_fifo_t::pLastEntry.

Here is the call graph for this function:

isf_fifo_status_t isf_fifo_el_clear ( isf_fifo_t pFifo)

Routine to clear the fifo.

Definition at line 217 of file isf_fifo.c.

References FIFO_FULL_CLR_MASK, isf_fifo_t::fifoState, ISF_SUCCESS, isf_fifo_t::pDataBuffer, and isf_fifo_t::pInsertPtr.

Referenced by App1_MainTask(), BasicApp1_MainTask(), and fsl_fusion_virt_3D_orient_PeriodicCallback().

Here is the caller graph for this function:

isf_fifo_status_t isf_fifo_el_traverse ( isf_fifo_t pFifo,
void **  pSamplePtr 
)

Routine to traverse a fifo To initiate the traversal set pSamplePtr to NULL. The function will set the pointer to the first available sample and returns ISF_SUCCESS. Subsequent calls will increment the pointer to each available sample and return ISF_SUCCESS. When ISF_SUCCESS is returned, pSamplePtr may be dereferenced to obtain a fifo entry. When no more samples are available, the function returns ISF_FIFO_NO_MORE_ENTRIES.

Definition at line 259 of file isf_fifo.c.

References FIFO_FULL_BIT, isf_fifo_t::fifoState, ISF_FIFO_NO_MORE_ENTRIES, ISF_SUCCESS, isf_fifo_t::pDataBuffer, isf_fifo_t::pInsertPtr, and isf_fifo_t::sampleSize.

Referenced by App1_MainTask(), and fsl_fusion_virt_3D_orient_PeriodicCallback().

Here is the caller graph for this function:

uint16 isf_fifo_get_buffer_size ( isf_fifo_t pFifo)

Routine to query the current fifo buffer size (bytes)

Routine to query the current fifo size (bytes)

Definition at line 133 of file isf_fifo.c.

References isf_fifo_t::pDataBuffer, isf_fifo_t::pLastEntry, and isf_fifo_t::sampleSize.

Referenced by isf_fifo_resize().

Here is the caller graph for this function:

isf_fifo_status_t isf_fifo_init ( isf_fifo_t pFifo,
void *  pData,
uint16  sampleSize,
uint16  bufferCapacity 
)
isf_fifo_status_t isf_fifo_resize ( isf_fifo_t pFifo,
uint16  newCapacity 
)

Routine to change the supported fifo depth.

Routine to copy the whole sample buffer.

Warning: When the fifo is resized all sample data in the buffer is lost. It is suggested to resize only when empty

Definition at line 101 of file isf_fifo.c.

References ALLOCATED_BUFFER_BIT, isf_fifo_t::bufferLock, isf_fifo_t::fifoState, ISF_FIFO_ERR_NO_INIT, ISF_FIFO_ERR_USER_BUF, isf_fifo_get_buffer_size(), ISF_SUCCESS, isf_fifo_t::pDataBuffer, and isf_fifo_t::sampleSize.

Here is the call graph for this function:

isf_fifo_status_t isf_fifo_try_lock ( isf_fifo_t pFifo)

Attempt to lock a sample buffer for exclusive access.

Definition at line 183 of file isf_fifo.c.

References isf_fifo_t::bufferLock, ISF_FIFO_ERR_BUSY, and ISF_SUCCESS.