Go to the documentation of this file.
49 #define TSRB_INIT(BUF) { (BUF), sizeof (BUF), 0, 0 }
62 assert((bufsize != 0) && ((bufsize & (~bufsize + 1)) == bufsize));
unsigned reads
total number of reads
unsigned int size
Size of buffer, must be power of 2.
uint8_t * buf
Buffer to operate on.
#define assert(cond)
abort the program if assertion is false
MAYBE_INLINE unsigned irq_disable(void)
This function sets the IRQ disable bit in the status register.
struct tsrb tsrb_t
thread-safe ringbuffer struct
POSIX.1-2008 compliant version of the assert macro.
static unsigned int tsrb_free(const tsrb_t *rb)
Get free space in ringbuffer.
int tsrb_add(tsrb_t *rb, const uint8_t *src, size_t n)
Add bytes to ringbuffer.
static int tsrb_empty(const tsrb_t *rb)
Test if the tsrb is empty.
unsigned writes
total number of writes
MAYBE_INLINE void irq_restore(unsigned state)
This function restores the IRQ disable bit in the status register to the value contained within passe...
static unsigned int tsrb_avail(const tsrb_t *rb)
Get number of bytes available for reading.
int tsrb_drop(tsrb_t *rb, size_t n)
Drop bytes from ringbuffer.
static void tsrb_init(tsrb_t *rb, uint8_t *buffer, unsigned bufsize)
Initialize a tsrb.
int tsrb_get(tsrb_t *rb, uint8_t *dst, size_t n)
Get bytes from ringbuffer.
int tsrb_get_one(tsrb_t *rb)
Get a byte from ringbuffer.
static int tsrb_full(const tsrb_t *rb)
Test if the tsrb is full.
int tsrb_add_one(tsrb_t *rb, uint8_t c)
Add a byte to ringbuffer.
thread-safe ringbuffer struct