diff --git a/CircularBuffer/bin/PCircularBuffer.o b/CircularBuffer/bin/PCircularBuffer.o index 182cbea..bf5d5ae 100644 Binary files a/CircularBuffer/bin/PCircularBuffer.o and b/CircularBuffer/bin/PCircularBuffer.o differ diff --git a/CircularBuffer/bin/test.o b/CircularBuffer/bin/test.o index f9b2165..0c5dec4 100644 Binary files a/CircularBuffer/bin/test.o and b/CircularBuffer/bin/test.o differ diff --git a/CircularBuffer/bin/tester.exe b/CircularBuffer/bin/tester.exe index 9c0c97c..4dd108e 100644 Binary files a/CircularBuffer/bin/tester.exe and b/CircularBuffer/bin/tester.exe differ diff --git a/CircularBuffer/src/PCircularBuffer.c b/CircularBuffer/src/PCircularBuffer.c index 9303571..f34e2e1 100644 --- a/CircularBuffer/src/PCircularBuffer.c +++ b/CircularBuffer/src/PCircularBuffer.c @@ -354,7 +354,10 @@ PB_CB_STATUS p_cb_double_init(p_cb_double* circ_buffer, double* buff, uint32_t m ret = PB_CB_BAD_BUFFER_SIZE; break; } - circ_buffer->max_len = max_length; + printf("init\r\n"); + circ_buffer->buffer = buff; + circ_buffer->max_len = (uint16_t)max_length; + circ_buffer->head = 0; circ_buffer->push = p_cb_double_push; circ_buffer->empty = p_cb_double_empty; circ_buffer->empty(circ_buffer); @@ -381,7 +384,6 @@ PB_CB_STATUS p_cb_double_push(p_cb_double* cbuffer, double value) { cbuffer->buffer[cbuffer->head] = value; cbuffer->head = (cbuffer->head + 1) % cbuffer->max_len; - printf("head: %d\r\n", cbuffer->max_len); } // Debugging diff --git a/CircularBuffer/test/test.c b/CircularBuffer/test/test.c index e2ab91e..173d51a 100644 --- a/CircularBuffer/test/test.c +++ b/CircularBuffer/test/test.c @@ -1,21 +1,27 @@ #include +#include #include int main() { const uint16_t maxlength = 16; double my_buffer[maxlength]; p_cb_double data; - for(int ind = 0; ind < 2; ind++) + p_cb_double_init(&data, my_buffer, 16); + + for(int x = 0; x < 32; x++) { - for(int x = 0; x < 16; x++) + if( x < 16) { printf("[%02d] Before: %02lf\t", x, data.buffer[x]); data.push(&data, (double)x); printf("[%02d] After: %02lf\r\n", x, data.buffer[x]); } + else + { + printf("[%02d] Before: %02lf\t", x - 16, data.buffer[x - 16]); + data.push(&data, (double)x); + printf("[%02d] After: %02lf\r\n", x - 16, data.buffer[x - 16]); + } } - - int x = 5; - printf("%d\r\n", x); return 0; } \ No newline at end of file