So I need to write a circular buffer, there is my logic, I think they are correct. But I just need someone to take a look for me, to see if they are actually correct.
Thanks guys!!
Thanks guys!!
Code:
typedef struct{
uint8_t *data;
uint8_t head;
uint8_t tail;
uint8_t size; // size of the *data
uint8_t data_count; // number of un-used data
}circular_buffer_t;
uint8_t isEmpty(circular_buffer_t *cb){
// if (data_count == 0), then return true
// or else return false
}
uint8_t isFull(circular_buffer_t *cb){
// if (data_count == buffer size), then return true
// or else return false
}
void put(circular_buffer_t *cb){
// add data
// head++
// check head for overflow
// buffer data_counter++
}
uint8_t get(circular_buffer_t *cb){
// read data
// tail++
// check tail for overflow
// buffer data_counter--
}