Homework 2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Homework - 2

Implement a C framework for a circular buffer (as discussed in class).


Your submission is due 04/24/2015 11:00pm using blackboard. Please
be ready to demo your code to Brent.

the framework should compile with the C compiler used for the labs
you should be able to set the buffer size via a macro at the beginning of the code
(e.g., #define MY_RCV_BFR_SIZE 100 ). You can assume the buffer size to remain
under 254.
provide two functions, one with which you can insert a character (unsigned char) into
the buffer and one with which you can remove the oldest character that has not been
processed yet from the buffer.
provide one more function that returns the number of characters in the buffer
turn in your code in a single ".c" file together with a short documentation on how it
works and your test description.
remember: in low level embedded programming global variables are your friends.
remember: use variables for pointing to the head (insertion) and tail (removal) of the
buffer; figure out the modulo logic for advancing pointers; provide protection from
overfilling and under-drawing the buffer.
make your code efficient and short.
test your code in a systematic way to ensure its correct operation.
hint: as your code is a bunch of simple C declarations and commands, you could use1
gcc under linux or even visual C for testing.

You might also like