64 if(((r->put_ptr - r->get_ptr) & r->mask) == r->mask) {
75 CC_ACCESS_NOW(uint8_t, r->put_ptr) = (r->put_ptr + 1) & r->mask;
94 if(((r->put_ptr - r->get_ptr) & r->mask) > 0) {
105 CC_ACCESS_NOW(uint8_t, r->get_ptr) = (r->get_ptr + 1) & r->mask;
121 return (r->put_ptr - r->get_ptr) & r->mask;
int ringbuf_elements(struct ringbuf *r)
Get the number of elements currently in the ring buffer.
int ringbuf_get(struct ringbuf *r)
Get a byte from the ring buffer.
Header file for the ring buffer library
#define CC_ACCESS_NOW(type, variable)
This macro ensures that the access to a non-volatile variable can not be reordered or optimized by th...
int ringbuf_size(struct ringbuf *r)
Get the size of a ring buffer.
Structure that holds the state of a ring buffer.
Default definitions of C compiler quirk work-arounds.
int ringbuf_put(struct ringbuf *r, uint8_t c)
Insert a byte into the ring buffer.
void ringbuf_init(struct ringbuf *r, uint8_t *dataptr, uint8_t size)
Initialize a ring buffer.