Ring Buffer Driver

The ring buffer driver is used for providing generic data structures.

Functions

bool ATMO_RingBuffer_Init(ATMO_RingBuffer_t *buf, uint32_t capacity, uint32_t elementSize)

Initialize ring buffer storage.

Parameter Direction Type
elementSize in uint32_t
capacity in uint32_t
buf in ATMO_RingBuffer_t *
Return Type Description
bool True if successful, false if error

bool ATMO_RingBuffer_Full(ATMO_RingBuffer_t *buf)

Is the ring buffer full?

Parameter Direction Type
buf in ATMO_RingBuffer_t *
Return Type Description
bool True if full, false if not

bool ATMO_RingBuffer_Empty(ATMO_RingBuffer_t *buf)

Is the ring buffer empty?

Parameter Direction Type
buf in ATMO_RingBuffer_t *
Return Type Description
bool True if empty, false if not

void* ATMO_RingBuffer_Head(ATMO_RingBuffer_t *buf)

Retrieve the head of the ring buffer. Does not pop.

Parameter Direction Type
buf in ATMO_RingBuffer_t *
Return Type Description
void * Pointer to the head of the ring buffer. NULL if buffer is empty.

void* ATMO_RingBuffer_Index(ATMO_RingBuffer_t *buf, uint32_t index)

Retrieve pointer to element at specific index of ring buffer.

Parameter Direction Type
index in uint32_t
buf in ATMO_RingBuffer_t *
Return Type Description
void * Pointer to element. NULL if element does not exist.

void* ATMO_RingBuffer_Tail(ATMO_RingBuffer_t *buf)

Retrieve the tail of the ring buffer. Does not pop.

Parameter Direction Type
buf in ATMO_RingBuffer_t *
Return Type Description
void * Pointer to the tail of the ring buffer. NULL if buffer is empty.

void* ATMO_RingBuffer_Pop(ATMO_RingBuffer_t *buf)

Pop element off of the front of the ring buffer.

Parameter Direction Type
buf in ATMO_RingBuffer_t *
Return Type Description
void * Pointer to element. You must free element yourself if it was malloc’d.

bool ATMO_RingBuffer_Push(ATMO_RingBuffer_t *buf, void *data)

Push element onto back of ring buffer.

Parameter Direction Type
data in void *
buf in ATMO_RingBuffer_t *
Return Type Description
bool True if pushed, false if full or error