turb.h File Reference

Thread Unsafe access to Thread-safe ringbuffer. More...

Detailed Description

Thread Unsafe access to Thread-safe ringbuffer.

Attention
use only if you ensurred thread safety otherwise e.g.: by an irq guard

Thread-unsafe ringbuffer interface definition

Author
Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e
Karl Fessel karl..nosp@m.fess.nosp@m.el@ml.nosp@m.-pa..nosp@m.com

Definition in file turb.h.

#include "tsrb.h"
+ Include dependency graph for turb.h:

Go to the source code of this file.

static void turb_clear (tsrb_t *rb)
 Clear a tsrb. More...
 
static int turb_empty (const tsrb_t *rb)
 Test if the tsrb is empty. More...
 
static unsigned int turb_avail (const tsrb_t *rb)
 Get number of bytes available for reading. More...
 
static int turb_full (const tsrb_t *rb)
 Test if the tsrb is full. More...
 
static unsigned int turb_free (const tsrb_t *rb)
 Get free space in ringbuffer. More...
 
static int turb_get_one (tsrb_t *rb)
 Get a byte from ringbuffer. More...
 
static int turb_peek_one (tsrb_t *rb)
 Get a byte from ringbuffer, without removing it. More...
 
static int turb_get (tsrb_t *rb, uint8_t *dst, size_t n)
 Get bytes from ringbuffer. More...
 
static int turb_peek (tsrb_t *rb, uint8_t *dst, size_t n)
 Get bytes from ringbuffer, without removing them. More...
 
static int turb_drop (tsrb_t *rb, size_t n)
 Drop bytes from ringbuffer. More...
 
static int turb_add_one (tsrb_t *rb, uint8_t c)
 Add a byte to ringbuffer. More...
 
static int turb_add (tsrb_t *rb, const uint8_t *src, size_t n)
 Add bytes to ringbuffer. More...
 

Function Documentation

◆ turb_add()

static int turb_add ( tsrb_t rb,
const uint8_t *  src,
size_t  n 
)
inlinestatic

Add bytes to ringbuffer.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
[in]srcbuffer to read from
[in]nmax number of bytes to read from src
Returns
nr of bytes read from src

Definition at line 218 of file turb.h.

◆ turb_add_one()

static int turb_add_one ( tsrb_t rb,
uint8_t  c 
)
inlinestatic

Add a byte to ringbuffer.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
[in]cCharacter to add to ringbuffer
Returns
0 on success
-1 if no space available

Definition at line 200 of file turb.h.

◆ turb_avail()

static unsigned int turb_avail ( const tsrb_t rb)
inlinestatic

Get number of bytes available for reading.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
Returns
nr of available bytes

Definition at line 58 of file turb.h.

◆ turb_clear()

static void turb_clear ( tsrb_t rb)
inlinestatic

Clear a tsrb.

Attention
use only if you ensurred thread safety otherwise
Parameters
[out]rbRingbuffer to operate on

Definition at line 34 of file turb.h.

◆ turb_drop()

static int turb_drop ( tsrb_t rb,
size_t  n 
)
inlinestatic

Drop bytes from ringbuffer.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
[in]nmax number of bytes to drop
Returns
nr of bytes dropped

Definition at line 182 of file turb.h.

◆ turb_empty()

static int turb_empty ( const tsrb_t rb)
inlinestatic

Test if the tsrb is empty.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
Returns
0 if not empty
1 otherwise

Definition at line 46 of file turb.h.

◆ turb_free()

static unsigned int turb_free ( const tsrb_t rb)
inlinestatic

Get free space in ringbuffer.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
Returns
nr of available bytes

Definition at line 83 of file turb.h.

◆ turb_full()

static int turb_full ( const tsrb_t rb)
inlinestatic

Test if the tsrb is full.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
Returns
0 if not full
1 otherwise

Definition at line 71 of file turb.h.

◆ turb_get()

static int turb_get ( tsrb_t rb,
uint8_t *  dst,
size_t  n 
)
inlinestatic

Get bytes from ringbuffer.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
[out]dstbuffer to write to
[in]nmax number of bytes to write to dst
Returns
nr of bytes written to dst

Definition at line 147 of file turb.h.

◆ turb_get_one()

static int turb_get_one ( tsrb_t rb)
inlinestatic

Get a byte from ringbuffer.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
Returns
>=0 byte that has been read
-1 if no byte available

Definition at line 114 of file turb.h.

◆ turb_peek()

static int turb_peek ( tsrb_t rb,
uint8_t *  dst,
size_t  n 
)
inlinestatic

Get bytes from ringbuffer, without removing them.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
[out]dstbuffer to write to
[in]nmax number of bytes to write to dst
Returns
nr of bytes written to dst

Definition at line 165 of file turb.h.

◆ turb_peek_one()

static int turb_peek_one ( tsrb_t rb)
inlinestatic

Get a byte from ringbuffer, without removing it.

Attention
use only if you ensurred thread safety otherwise
Parameters
[in]rbRingbuffer to operate on
Returns
>=0 byte that has been read
-1 if no byte available

Definition at line 130 of file turb.h.