#ifndef _CIRCULAR_BUFFER_H
#define _CIRCULAR_BUFFER_H

/* Usable buffer size; Actual size is 1 more because we always have 1 empty
   spot in the buffer. */
#define CIRC_BUF_SIZE                   1024

typedef struct
{
  vuint8_t circ_buffer[CIRC_BUF_SIZE+1];
  vuint32_t head_idx;
  vuint32_t tail_idx;
  vuint32_t dma_tail_idx;
} circ_buff_t;

int add_item(circ_buff_t *buffer_ptr, uint8_t new_item);
int add_items(circ_buff_t *buffer_ptr, const uint8_t *pData, uint32_t numItems);
int16_t remove_item(circ_buff_t *buffer_ptr);

uint32_t is_empty(circ_buff_t *buffer_ptr);
uint32_t get_buffer_size(void);
uint32_t get_head_idx(circ_buff_t *buffer_ptr);
uint32_t get_tail_idx(circ_buff_t *buffer_ptr);
uint32_t get_data_start_address(circ_buff_t *buffer_ptr);
uint32_t get_num_items_to_send(circ_buff_t *buffer_ptr);
void update_tail_idx(circ_buff_t *buffer_ptr);

#endif
