Loading...
Searching...
No Matches
tsrb.h File Reference

Thread-safe ringbuffer interface definition. More...

Detailed Description

Thread-safe ringbuffer interface definition.

Author
Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e

Definition in file tsrb.h.

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include "irq.h"
+ Include dependency graph for tsrb.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tsrb
 thread-safe ringbuffer struct More...
 

Macros

#define TSRB_INIT(BUF)   { (BUF), sizeof (BUF), 0, 0 }
 Static initializer.
 

Typedefs

typedef struct tsrb tsrb_t
 thread-safe ringbuffer struct
 

Functions

static void tsrb_init (tsrb_t *rb, uint8_t *buffer, unsigned bufsize)
 Initialize a tsrb.
 
static void tsrb_clear (tsrb_t *rb)
 Clear a tsrb.
 
static int tsrb_empty (const tsrb_t *rb)
 Test if the tsrb is empty.
 
static unsigned int tsrb_avail (const tsrb_t *rb)
 Get number of bytes available for reading.
 
static int tsrb_full (const tsrb_t *rb)
 Test if the tsrb is full.
 
static unsigned int tsrb_free (const tsrb_t *rb)
 Get free space in ringbuffer.
 
int tsrb_get_one (tsrb_t *rb)
 Get a byte from ringbuffer.
 
int tsrb_peek_one (tsrb_t *rb)
 Get a byte from ringbuffer, without removing it.
 
int tsrb_get (tsrb_t *rb, uint8_t *dst, size_t n)
 Get bytes from ringbuffer.
 
int tsrb_peek (tsrb_t *rb, uint8_t *dst, size_t n)
 Get bytes from ringbuffer, without removing them.
 
int tsrb_drop (tsrb_t *rb, size_t n)
 Drop bytes from ringbuffer.
 
int tsrb_add_one (tsrb_t *rb, uint8_t c)
 Add a byte to ringbuffer.
 
int tsrb_add (tsrb_t *rb, const uint8_t *src, size_t n)
 Add bytes to ringbuffer.