diff --git a/CircularBuffer/Makefile b/CircularBuffer/Makefile index 51f0d99..e83eba7 100644 --- a/CircularBuffer/Makefile +++ b/CircularBuffer/Makefile @@ -1,9 +1,7 @@ CC=gcc -CFLAGS=-std=c99 -Wall -Wextra +CFLAGS=-std=c99 -Wall -Wextra + -#-Werror -Wshadow -Wdouble-promotion \ - -Wformat=2 -Wformat-truncation -fno-common -fstack-usage -Wconversion -Os \ - -Werror=unused-function BIN=./bin SRC=./src diff --git a/CircularBuffer/bin/PCircularBuffer.o b/CircularBuffer/bin/PCircularBuffer.o index bf5d5ae..0bba0a5 100644 Binary files a/CircularBuffer/bin/PCircularBuffer.o and b/CircularBuffer/bin/PCircularBuffer.o differ diff --git a/CircularBuffer/bin/tester.exe b/CircularBuffer/bin/tester.exe index 4dd108e..24bb072 100644 Binary files a/CircularBuffer/bin/tester.exe and b/CircularBuffer/bin/tester.exe differ diff --git a/CircularBuffer/example/simple_circular_buffer_example.c b/CircularBuffer/example/simple_circular_buffer_example.c index 6f431b8..5a602ff 100644 --- a/CircularBuffer/example/simple_circular_buffer_example.c +++ b/CircularBuffer/example/simple_circular_buffer_example.c @@ -34,6 +34,7 @@ */ +#include int main() { diff --git a/CircularBuffer/inc/PCircularBuffer.h b/CircularBuffer/inc/PCircularBuffer.h index 8eab357..5031d9a 100644 --- a/CircularBuffer/inc/PCircularBuffer.h +++ b/CircularBuffer/inc/PCircularBuffer.h @@ -4,7 +4,7 @@ Penguin's Circular Buffer -- a simple floating queue designed for low memory usage (mainly for embedded) This is a ring buffer with limited capabilities. It is meant as a container for moving data. - Normally included features such checks to see if the buffer is full or empty have been omitted + Normally included features such as checks to see if the buffer is full or empty have been omitted because this type of buffer is being implemented mainly for sensor data usage. Data is almost never read individually, and even if it is, it isn't meant to be cleared on read. It is a simple moving buffer that automatically writes over old data for the purpose of keeping track of the most up to date data. @@ -29,10 +29,11 @@ #ifndef _PCIRCULARBUFFER_H_ #define _PCIRCULARBUFFER_H_ -#include +#include #include + // comment this out for release builds -#define PB_CB_DEBUG +//#define PB_CB_DEBUG // Making these PB_EN/DIS rather than just ENABLE/DISABLE because // some enable/disable definition might already exist that is @@ -54,12 +55,12 @@ // Disable or Enable types needed here // We can save code size this way // While there are better ways to do this, this is the most accessible for anyone imo -#define PB_CB_FLOAT PB_ENABLE +#define PB_CB_FLOAT PB_DISABLE #define PB_CB_DOUBLE PB_ENABLE -#define PB_CB_U8 PB_ENABLE -#define PB_CB_U16 PB_ENABLE -#define PB_CB_U32 PB_ENABLE -#define PB_CB_U64 PB_ENABLE +#define PB_CB_U8 PB_DISABLE +#define PB_CB_U16 PB_DISABLE +#define PB_CB_U32 PB_DISABLE +#define PB_CB_U64 PB_DISABLE #define PB_CB_I8 PB_DISABLE #define PB_CB_I16 PB_DISABLE #define PB_CB_I32 PB_DISABLE @@ -73,7 +74,7 @@ typedef enum PB_CB_STATUS PB_CB_NULL_BUFFER = 3, PB_CB_NULL_CBUFFER = 4 }PB_CB_STATUS; - + #if PB_CB_U8 typedef struct p_cb_u8 diff --git a/CircularBuffer/src/PCircularBuffer.c b/CircularBuffer/src/PCircularBuffer.c index f34e2e1..b535ffd 100644 --- a/CircularBuffer/src/PCircularBuffer.c +++ b/CircularBuffer/src/PCircularBuffer.c @@ -16,80 +16,60 @@ static void handle_status(const char* func, PB_CB_STATUS status_code) #if PB_CB_U8 static PB_CB_STATUS p_cb_u8_push(p_cb_double* cbuffer, uint8_t value); static PB_CB_STATUS p_cb_u8_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_u8_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_u8_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Prototypes -- uint16_t #if PB_CB_U16 static PB_CB_STATUS p_cb_u16_push(p_cb_double* cbuffer, uint16_t value); static PB_CB_STATUS p_cb_u16_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_u16_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_u16_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Prototypes -- uint32_t #if PB_CB_U32 static PB_CB_STATUS p_cb_u32_push(p_cb_double* cbuffer, uint32_t value); static PB_CB_STATUS p_cb_u32_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_u32_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_u32_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Prototypes -- uint64_t #if PB_CB_U64 static PB_CB_STATUS p_cb_u64_push(p_cb_double* cbuffer, uint64_t value); static PB_CB_STATUS p_cb_u64_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_u64_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_u64_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Prototypes -- int8_t #if PB_CB_I8 static PB_CB_STATUS p_cb_i8_push(p_cb_double* cbuffer, int8_t value); static PB_CB_STATUS p_cb_i8_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_i8_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_i8_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Prototypes -- int16_t #if PB_CB_I16 static PB_CB_STATUS p_cb_i16_push(p_cb_double* cbuffer, int16_t value); static PB_CB_STATUS p_cb_i16_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_i16_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_i16_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Prototypes -- int32_t #if PB_CB_I32 static PB_CB_STATUS p_cb_i32_push(p_cb_double* cbuffer, int32_t value); static PB_CB_STATUS p_cb_i32_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_i32_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_i32_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Prototypes -- int64_t #if PB_CB_I64 static PB_CB_STATUS p_cb_i64_push(p_cb_double* cbuffer, int64_t value); static PB_CB_STATUS p_cb_i64_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_i64_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_i64_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Prototypes -- Float #if PB_CB_FLOAT static PB_CB_STATUS p_cb_float_push(p_cb_double* cbuffer, float value); static PB_CB_STATUS p_cb_float_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_float_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_float_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Prototypes -- Double #if PB_CB_DOUBLE static PB_CB_STATUS p_cb_double_push(p_cb_double* cbuffer, double value); static PB_CB_STATUS p_cb_double_empty(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_double_is_full(p_cb_double* cbuffer); -static PB_CB_STATUS p_cb_double_is_empty(p_cb_double* cbuffer); #endif // Circular Buffer Definitions -- uint8_t @@ -354,7 +334,6 @@ PB_CB_STATUS p_cb_double_init(p_cb_double* circ_buffer, double* buff, uint32_t m ret = PB_CB_BAD_BUFFER_SIZE; break; } - printf("init\r\n"); circ_buffer->buffer = buff; circ_buffer->max_len = (uint16_t)max_length; circ_buffer->head = 0; diff --git a/CircularBuffer/test/test.c b/CircularBuffer/test/test.c index 173d51a..7029975 100644 --- a/CircularBuffer/test/test.c +++ b/CircularBuffer/test/test.c @@ -1,5 +1,4 @@ #include -#include #include int main() {