35 #ifndef _RING_BUFFER_H_ 36 #define _RING_BUFFER_H_ 50 volatile uint8_t *
buf;
92 return (uint16_t)
size;
102 return (t + 1 == h || (t == rb->
size && h == 0) );
120 rb->
buf[t] = element;
121 rb->
tail = (t == rb->
size) ? 0 : t + 1;
130 uint8_t ch = rb->
buf[h];
131 rb->
head = (h == rb->
size) ? 0 : h + 1;
static void rb_insert(ring_buffer *rb, uint8_t element)
static int rb_is_empty(ring_buffer *rb)
Returns true if and only if the ring buffer is empty.
static uint16_t rb_full_count(ring_buffer *rb)
Return the number of elements stored in the ring buffer.
static uint8_t rb_remove(ring_buffer *rb)
Remove and return the first item from a ring buffer.
static int16_t rb_safe_remove(ring_buffer *rb)
Attempt to remove the first item from a ring buffer.
static int rb_is_full(ring_buffer *rb)
Returns true if and only if the ring buffer is full.
struct ring_buffer ring_buffer
static void rb_init(ring_buffer *rb, uint16_t size, uint8_t *buf)
static int rb_safe_insert(ring_buffer *rb, uint8_t element)
Attempt to insert an element into a ring buffer.
static void rb_reset(ring_buffer *rb)
Discard all items from a ring buffer.
static int rb_push_insert(ring_buffer *rb, uint8_t element)
Append an item onto the end of a non-full ring buffer.