A Generic Circular Buffer for Embedded Applications

Circular buffers are very commonly used by embedded programmers for communicating or coordinating activities between two ISR’s or functions, and it works on the principle of FIFO.

Software Implementation in C

1. Queue.h

[codesyntax lang=”c”]

[/codesyntax]

2. Queue.c

[codesyntax lang=”c”]

[/codesyntax]

If a proper rate of writing and reading from the buffer is not maintained, it will lead to something interesting known as a “producer and consumer problem (also known as the bounded-buffer problem)”. For more details about this problem, please view here.

You can also download the source files from my Github repo here.

Leave a Reply

Your email address will not be published. Required fields are marked *