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.
Implements a simple byte-orientated Fifo with a maximum size of 255 bytes.
Definition in file bytefifo.h.
#define BF_INIT |
( |
|
NAME, |
|
|
|
CAP |
|
) |
| |
Value:static uint8_t NAME ## _buf[CAP]; \
.buf = NAME ## _buf, \
.cap = CAP, \
.len = 0, \
.wp = 0, \
.rp = CAP - 1 \
};
Initializes the ByteFifo.
- Parameters
-
NAME | The name |
CAP | The maximum capacity. May not exceed 255. |
Definition at line 42 of file bytefifo.h.
static void bfClear |
( |
ByteFifo *const |
bf | ) |
|
|
inlinestatic |
Clear the fifo.
- Parameters
-
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
-
- Return values
-
true | Its empty. |
false | Its 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
-
- Return values
-
true | Its full. |
false | Its 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
-
bf | Pointer to a ByteFifo. |
b | Pointer to fill. |
- Return values
-
true | Byte was read from the fifo. |
false | Byte 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
-
bf | Pointer to a ByteFifo. |
b | Byte to write. |
- Return values
-
true | Byte was added to the Fifo |
false | Byte could not be added, fifo is full. |
Definition at line 17 of file bytefifo.c.