Data Structures | Typedefs | Functions
RingBuf.h File Reference
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
Include dependency graph for RingBuf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  RingBuf_Object
 

Typedefs

typedef struct RingBuf_ObjectRingBuf_Handle
 

Functions

void RingBuf_construct (RingBuf_Handle object, unsigned char *bufPtr, size_t bufSize)
 Initialize circular buffer. More...
 
void RingBuf_flush (RingBuf_Handle object)
 Flush all the data from the buffer. More...
 
int RingBuf_get (RingBuf_Handle object, unsigned char *data)
 Get an unsigned char from the end of the circular buffer and remove it. More...
 
int RingBuf_getConsume (RingBuf_Handle object, size_t size)
 Advance the get index and decrement the buffer count. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock. More...
 
int RingBuf_getCount (RingBuf_Handle object)
 Get the number of unsigned chars currently stored on the circular buffer. More...
 
int RingBuf_getMaxCount (RingBuf_Handle object)
 A high-water mark indicating the largest number of unsigned chars stored on the circular buffer since it was constructed. More...
 
int RingBuf_getn (RingBuf_Handle object, unsigned char *data, size_t n)
 Get one or more unsigned chars from the end of the circular buffer and remove them. More...
 
int RingBuf_getPointer (RingBuf_Handle object, unsigned char **data)
 Get a pointer reference to the next chunk of linear memory available for accessing data in the buffer. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock. More...
 
bool RingBuf_isFull (RingBuf_Handle object)
 Function to determine if the circular buffer is full or not. More...
 
int RingBuf_peek (RingBuf_Handle object, unsigned char *data)
 Get an unsigned char from the end of the circular buffer without removing it. More...
 
int RingBuf_put (RingBuf_Handle object, unsigned char data)
 Put an unsigned char into the end of the circular buffer. More...
 
int RingBuf_putAdvance (RingBuf_Handle object, size_t size)
 Advance the committed put index and increment the buffer count. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock. More...
 
int RingBuf_putn (RingBuf_Handle object, unsigned char *data, size_t n)
 Put one or more unsigned chars into the end of the circular buffer. More...
 
int RingBuf_putPointer (RingBuf_Handle object, unsigned char **data)
 Get a pointer reference to the next chunk of linear memory available for adding data to the buffer. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock. More...
 
static size_t RingBuf_space (RingBuf_Handle object)
 Return the number of unsigned characters that the buffer has space for. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock. More...
 

Typedef Documentation

§ RingBuf_Handle

typedef struct RingBuf_Object * RingBuf_Handle

Function Documentation

§ RingBuf_construct()

void RingBuf_construct ( RingBuf_Handle  object,
unsigned char *  bufPtr,
size_t  bufSize 
)

Initialize circular buffer.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
bufPtrPointer to data buffer to be used for the circular buffer. The buffer is NOT stored in RingBuf_Object.
bufSizeThe size of bufPtr in number of unsigned chars.

§ RingBuf_flush()

void RingBuf_flush ( RingBuf_Handle  object)

Flush all the data from the buffer.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.

§ RingBuf_get()

int RingBuf_get ( RingBuf_Handle  object,
unsigned char *  data 
)

Get an unsigned char from the end of the circular buffer and remove it.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
dataPointer to an unsigned char to be filled with the data from the front of the circular buffer.
Returns
Number of unsigned chars on the buffer after taking it out of the circular buffer. If it returns -1, the circular buffer was already empty and data is invalid.

§ RingBuf_getConsume()

int RingBuf_getConsume ( RingBuf_Handle  object,
size_t  size 
)

Advance the get index and decrement the buffer count. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
sizeNumber of unsigned characters to advance the get index.
Returns
Number of unsigned chars that we were able to be advanced.

§ RingBuf_getCount()

int RingBuf_getCount ( RingBuf_Handle  object)

Get the number of unsigned chars currently stored on the circular buffer.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
Returns
Number of unsigned chars on the circular buffer.

§ RingBuf_getMaxCount()

int RingBuf_getMaxCount ( RingBuf_Handle  object)

A high-water mark indicating the largest number of unsigned chars stored on the circular buffer since it was constructed.

Returns
Get the largest number of unsigned chars that were at one point in the circular buffer.

§ RingBuf_getn()

int RingBuf_getn ( RingBuf_Handle  object,
unsigned char *  data,
size_t  n 
)

Get one or more unsigned chars from the end of the circular buffer and remove them.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
dataPointer to an unsigned char to be filled with the data from the front of the circular buffer.
nnumber of unsigned chars to try and remove.
Returns
Number of unsigned chars successfully removed from the buffer and copied into data. May be 0 or less than n.

§ RingBuf_getPointer()

int RingBuf_getPointer ( RingBuf_Handle  object,
unsigned char **  data 
)

Get a pointer reference to the next chunk of linear memory available for accessing data in the buffer. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
dataReference to a pointer to set for the memory location in the buffer where data can accessed.
Returns
Number of unsigned chars in linear memory where data can be accessed, or 0 if it's empty.

§ RingBuf_isFull()

bool RingBuf_isFull ( RingBuf_Handle  object)

Function to determine if the circular buffer is full or not.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
Returns
true if circular buffer is full, else false.

§ RingBuf_peek()

int RingBuf_peek ( RingBuf_Handle  object,
unsigned char *  data 
)

Get an unsigned char from the end of the circular buffer without removing it.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
dataPointer to an unsigned char to be filled with the data from the front of the circular buffer. This function does not remove the data from the circular buffer. Do not evaluate data if the count returned is equal to 0.
Returns
Number of unsigned chars on the circular buffer. If the number != 0, then data will contain the unsigned char at the end of the circular buffer.

§ RingBuf_put()

int RingBuf_put ( RingBuf_Handle  object,
unsigned char  data 
)

Put an unsigned char into the end of the circular buffer.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
dataunsigned char to be placed at the end of the circular buffer.
Returns
Number of unsigned chars on the buffer after it was added, or -1 if it's already full.

§ RingBuf_putAdvance()

int RingBuf_putAdvance ( RingBuf_Handle  object,
size_t  size 
)

Advance the committed put index and increment the buffer count. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
sizeNumber of unsigned characters to commit to the put index.
Returns
Number of unsigned chars that we were able to be committed.

§ RingBuf_putn()

int RingBuf_putn ( RingBuf_Handle  object,
unsigned char *  data,
size_t  n 
)

Put one or more unsigned chars into the end of the circular buffer.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
dataunsigned chars to be placed at the end of the circular buffer.
nnumber of unsigned chars to try and remove.
Returns
Number of unsigned chars placed into the buffer. May be 0 or less than n.

§ RingBuf_putPointer()

int RingBuf_putPointer ( RingBuf_Handle  object,
unsigned char **  data 
)

Get a pointer reference to the next chunk of linear memory available for adding data to the buffer. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
dataReference to a pointer to set for the memory location in the buffer where more data can be added.
Returns
Number of unsigned chars available in linear memory where data can be added, or 0 if it's already full.

§ RingBuf_space()

static size_t RingBuf_space ( RingBuf_Handle  object)
inlinestatic

Return the number of unsigned characters that the buffer has space for. This function should normally be called from a context where HWI is disabled. For efficiency, it is incumbent on the caller to ensure mutual exclusion with the proper HWI lock.

Parameters
objectPointer to a RingBuf Object that contains the member variables to operate a circular buffer.
Returns
Number of unsigned chars that the buffer has space for.

References RingBuf_Object::count, and RingBuf_Object::length.

© Copyright 1995-2021, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale