#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | RingBuf_Object |
Typedefs | |
typedef struct RingBuf_Object * | RingBuf_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 struct RingBuf_Object * RingBuf_Handle |
void RingBuf_construct | ( | RingBuf_Handle | object, |
unsigned char * | bufPtr, | ||
size_t | bufSize | ||
) |
Initialize circular buffer.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
bufPtr | Pointer to data buffer to be used for the circular buffer. The buffer is NOT stored in RingBuf_Object. |
bufSize | The size of bufPtr in number of unsigned chars. |
void RingBuf_flush | ( | RingBuf_Handle | object | ) |
Flush all the data from the buffer.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
int RingBuf_get | ( | RingBuf_Handle | object, |
unsigned char * | data | ||
) |
Get an unsigned char from the end of the circular buffer and remove it.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | Pointer to an unsigned char to be filled with the data from the front of the circular buffer. |
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.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
size | Number of unsigned characters to advance the get index. |
int RingBuf_getCount | ( | RingBuf_Handle | object | ) |
Get the number of unsigned chars currently stored on the circular buffer.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
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.
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.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | Pointer to an unsigned char to be filled with the data from the front of the circular buffer. |
n | number of unsigned chars to try and remove. |
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.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | Reference to a pointer to set for the memory location in the buffer where data can accessed. |
bool RingBuf_isFull | ( | RingBuf_Handle | object | ) |
Function to determine if the circular buffer is full or not.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
int RingBuf_peek | ( | RingBuf_Handle | object, |
unsigned char * | data | ||
) |
Get an unsigned char from the end of the circular buffer without removing it.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | Pointer 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. |
int RingBuf_put | ( | RingBuf_Handle | object, |
unsigned char | data | ||
) |
Put an unsigned char into the end of the circular buffer.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | unsigned char to be placed at the end of the circular buffer. |
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.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
size | Number of unsigned characters to commit to the put index. |
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.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | unsigned chars to be placed at the end of the circular buffer. |
n | number of unsigned chars to try and remove. |
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.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
data | Reference to a pointer to set for the memory location in the buffer where more data can be added. |
|
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.
object | Pointer to a RingBuf Object that contains the member variables to operate a circular buffer. |
References RingBuf_Object::count, and RingBuf_Object::length.