Exposed some useful functions in FIFO library. Updated Ringbuffer library to my latest.
This commit is contained in:
@@ -57,6 +57,12 @@ typedef struct fifo_buffer_t FIFO_BUFFER;
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
unsigned FIFO_Count(
|
||||
FIFO_BUFFER const *b);
|
||||
|
||||
bool FIFO_Full(
|
||||
FIFO_BUFFER const *b);
|
||||
|
||||
bool FIFO_Empty(
|
||||
FIFO_BUFFER const *b);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
-------------------------------------------
|
||||
####COPYRIGHTEND####*/
|
||||
|
||||
/* Functional Description: Generic ring buffer library for deeply
|
||||
/* Functional Description: Generic ring buffer library for deeply
|
||||
embedded system. See the unit tests for usage examples. */
|
||||
|
||||
#ifndef RINGBUF_H
|
||||
@@ -43,11 +43,11 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
struct ring_buffer_t {
|
||||
char *data; /* block of memory or array of data */
|
||||
uint8_t *data; /* block of memory or array of data */
|
||||
unsigned element_size; /* how many bytes for each chunk */
|
||||
unsigned element_count; /* number of chunks of data */
|
||||
unsigned head; /* first chunk of data */
|
||||
unsigned count; /* number of chunks in use */
|
||||
unsigned head; /* where the writes go */
|
||||
unsigned tail; /* where the reads come from */
|
||||
};
|
||||
typedef struct ring_buffer_t RING_BUFFER;
|
||||
|
||||
@@ -55,20 +55,25 @@ typedef struct ring_buffer_t RING_BUFFER;
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
unsigned Ringbuf_Count (
|
||||
RING_BUFFER const *b);
|
||||
bool Ringbuf_Full (
|
||||
RING_BUFFER const *b);
|
||||
bool Ringbuf_Empty(
|
||||
RING_BUFFER const *b);
|
||||
char *Ringbuf_Get_Front(
|
||||
uint8_t *Ringbuf_Get_Front(
|
||||
RING_BUFFER const *b);
|
||||
char *Ringbuf_Pop_Front(
|
||||
uint8_t *Ringbuf_Pop_Front(
|
||||
RING_BUFFER * b);
|
||||
bool Ringbuf_Put(
|
||||
RING_BUFFER * b, /* ring buffer structure */
|
||||
char *data_element); /* one element to add to the ring */
|
||||
char * Ringbuf_Alloc(
|
||||
RING_BUFFER * b);
|
||||
uint8_t *data_element); /* one element to add to the ring */
|
||||
uint8_t *Ringbuf_Alloc(
|
||||
RING_BUFFER *b);
|
||||
/* Note: element_count must be a power of two */
|
||||
void Ringbuf_Init(
|
||||
RING_BUFFER * b, /* ring buffer structure */
|
||||
char *data, /* data block or array of data */
|
||||
uint8_t *data, /* data block or array of data */
|
||||
unsigned element_size, /* size of one element in the data block */
|
||||
unsigned element_count); /* number of elements in the data block */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user