Exposed some useful functions in FIFO library. Updated Ringbuffer library to my latest.

This commit is contained in:
skarg
2010-03-22 21:36:27 +00:00
parent d3207bf5e5
commit 35f0a52d51
4 changed files with 155 additions and 108 deletions
+6
View File
@@ -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);
+15 -10
View File
@@ -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 */