KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bytefifo.h File Reference

Implements a simple byte-orientated Fifo with a maximum size of 255 bytes. More...

#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  ByteFifo
 

Macros

#define BF_INIT(NAME, CAP)
 Initializes the ByteFifo. More...
 

Functions

static bool bfFull (ByteFifo *const bf)
 Returns whether or not the byte-fifo is full. More...
 
static bool bfEmpty (ByteFifo *const bf)
 Returns whether or not the byte-fifo is empty. More...
 
bool bfWrite (ByteFifo *const bf, uint8_t b)
 Writes a byte to the byte-fifo. More...
 
bool bfRead (ByteFifo *const bf, uint8_t *const b)
 Reads a byte from the byte-fifo. More...
 
static void bfClear (ByteFifo *const bf)
 Clear the fifo. More...
 

Detailed Description

Implements a simple byte-orientated Fifo with a maximum size of 255 bytes.

Definition in file bytefifo.h.

Macro Definition Documentation

#define BF_INIT (   NAME,
  CAP 
)
Value:
static uint8_t NAME ## _buf[CAP]; \
static ByteFifo NAME = { \
.buf = NAME ## _buf, \
.cap = CAP, \
.len = 0, \
.wp = 0, \
.rp = CAP - 1 \
};

Initializes the ByteFifo.

Parameters
NAMEThe name
CAPThe maximum capacity. May not exceed 255.

Definition at line 42 of file bytefifo.h.

Function Documentation

static void bfClear ( ByteFifo *const  bf)
inlinestatic

Clear the fifo.

Parameters
bfPointer to a ByteFifo.

Definition at line 106 of file bytefifo.h.

static bool bfEmpty ( ByteFifo *const  bf)
inlinestatic

Returns whether or not the byte-fifo is empty.

Parameters
bfPointer to a ByteFifo.
Return values
trueIts empty.
falseIts not empty.

Definition at line 72 of file bytefifo.h.

static bool bfFull ( ByteFifo *const  bf)
inlinestatic

Returns whether or not the byte-fifo is full.

Parameters
bfPointer to a ByteFifo.
Return values
trueIts full.
falseIts not full.

Definition at line 60 of file bytefifo.h.

bool bfRead ( ByteFifo *const  bf,
uint8_t *const  b 
)

Reads a byte from the byte-fifo.

Parameters
bfPointer to a ByteFifo.
bPointer to fill.
Return values
trueByte was read from the fifo.
falseByte could not be read, fifo empty.

Definition at line 28 of file bytefifo.c.

bool bfWrite ( ByteFifo *const  bf,
uint8_t  b 
)

Writes a byte to the byte-fifo.

Parameters
bfPointer to a ByteFifo.
bByte to write.
Return values
trueByte was added to the Fifo
falseByte could not be added, fifo is full.

Definition at line 17 of file bytefifo.c.