Ring Buffer Driver

The ring buffer driver is used for providing a generic ring buffer data structure.

Type Definitions

Name Definition Description
ATMO_RingBuffer_Free_t typedef void(* ATMO_RingBuffer_Free_t) (void *value)  

Functions

bool ATMO_RingBuffer_Init(ATMO_RingBuffer_t *buf, uint8_t capacity, uint32_t elementSize, ATMO_RingBuffer_Free_t freeCb)

Initialize ring buffer storage.

Parameter Direction Type
freeCb N/A ATMO_RingBuffer_Free_t
elementSize in uint32_t
capacity in uint8_t
buf in ATMO_RingBuffer_t *
Return Type
bool

bool ATMO_RingBuffer_InitWithBuf(ATMO_RingBuffer_t *buf, uint8_t *bufData, uint8_t capacity, uint32_t elementSize, ATMO_RingBuffer_Free_t freeCb)

Initialize ring buffer with pre-allocated storage.

Parameter Direction Type
freeCb N/A ATMO_RingBuffer_Free_t
elementSize N/A uint32_t
capacity N/A uint8_t
bufData N/A uint8_t *
buf N/A ATMO_RingBuffer_t *
Return Type
bool

bool ATMO_RingBuffer_Full(ATMO_RingBuffer_t *buf)

Is the ring buffer full?

Parameter Direction Type
buf N/A ATMO_RingBuffer_t *
Return Type
bool

bool ATMO_RingBuffer_Empty(ATMO_RingBuffer_t *buf)

Is the ring buffer empty?

Parameter Direction Type
buf in ATMO_RingBuffer_t *
Return Type
bool

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
void *

void* ATMO_RingBuffer_Index(ATMO_RingBuffer_t *buf, uint8_t index)

Retrieve pointer to element at specific index of ring buffer.

Parameter Direction Type
index in uint8_t
buf in ATMO_RingBuffer_t *
Return Type
void *

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
void *

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
void *

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
bool