PatchworkOS  3984a1d
A non-POSIX operating system.
Loading...
Searching...
No Matches
FIFO Buffer

First-in first-out buffer. More...

Collaboration diagram for FIFO Buffer:

Detailed Description

First-in first-out buffer.

Data Structures

struct  fifo_t
 FIFO Buffer. More...
 

Macros

#define FIFO_CREATE(_buf, _size)   {.buffer = (uint8_t*)(_buf), .size = (_size), .head = 0, .tail = 0}
 Create a fifo buffer initializer.
 
#define FIFO_DEFINE(_name, _size)
 Define and initialize a fifo buffer.
 

Functions

void fifo_init (fifo_t *fifo, uint8_t *buffer, size_t size)
 Initialize a fifo buffer.
 
void fifo_reset (fifo_t *fifo)
 Reset a fifo buffer.
 
size_t fifo_bytes_readable (const fifo_t *fifo)
 Return the number of bytes available for reading in a fifo buffer.
 
size_t fifo_bytes_writeable (const fifo_t *fifo)
 Return the number of bytes available for writing in a fifo buffer.
 
size_t fifo_read (fifo_t *fifo, void *buffer, size_t count)
 Read data from a fifo buffer at a specific offset.
 
size_t fifo_write (fifo_t *fifo, const void *buffer, size_t count)
 Write data to the fifo buffer.
 
void fifo_advance_head (fifo_t *fifo, size_t count)
 Advance the head of the fifo buffer.
 
void fifo_advance_tail (fifo_t *fifo, size_t count)
 Advance the tail of the fifo buffer.
 

Macro Definition Documentation

◆ FIFO_CREATE

#define FIFO_CREATE (   _buf,
  _size 
)    {.buffer = (uint8_t*)(_buf), .size = (_size), .head = 0, .tail = 0}

Create a fifo buffer initializer.

Parameters
_bufPointer to the buffer memory.
_sizeThe size of the buffer in bytes.

Definition at line 33 of file fifo.h.

◆ FIFO_DEFINE

#define FIFO_DEFINE (   _name,
  _size 
)
Value:
int64_t y
Definition main.c:153
#define FIFO_CREATE(_buf, _size)
Create a fifo buffer initializer.
Definition fifo.h:33
__UINT8_TYPE__ uint8_t
Definition stdint.h:11
FIFO Buffer.
Definition fifo.h:20

Define and initialize a fifo buffer.

Helps define a fifo buffer with a backing buffer.

Parameters
_nameThe name of the fifo buffer.
_sizeThe size of the fifo buffer in bytes.

Definition at line 43 of file fifo.h.

Function Documentation

◆ fifo_init()

void fifo_init ( fifo_t fifo,
uint8_t buffer,
size_t  size 
)

Initialize a fifo buffer.

Parameters
fifoPointer to the fifo buffer structure.
bufferPointer to the buffer memory.
sizeThe size of the buffer in bytes.

Definition at line 7 of file fifo.c.

Here is the caller graph for this function:

◆ fifo_reset()

void fifo_reset ( fifo_t fifo)

Reset a fifo buffer.

Parameters
fifoPointer to the fifo buffer structure.

Definition at line 15 of file fifo.c.

◆ fifo_bytes_readable()

size_t fifo_bytes_readable ( const fifo_t fifo)

Return the number of bytes available for reading in a fifo buffer.

Parameters
fifoPointer to the fifo buffer structure.
Returns
The number of bytes used.

Definition at line 21 of file fifo.c.

Here is the caller graph for this function:

◆ fifo_bytes_writeable()

size_t fifo_bytes_writeable ( const fifo_t fifo)

Return the number of bytes available for writing in a fifo buffer.

Parameters
fifoPointer to the fifo buffer structure.
Returns
The number of bytes available for writing.

Definition at line 31 of file fifo.c.

Here is the caller graph for this function:

◆ fifo_read()

size_t fifo_read ( fifo_t fifo,
void buffer,
size_t  count 
)

Read data from a fifo buffer at a specific offset.

Parameters
fifoThe fifo buffer structure.
bufferThe destination buffer.
countThe number of bytes to read.
Returns
The number of bytes read.

Definition at line 41 of file fifo.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fifo_write()

size_t fifo_write ( fifo_t fifo,
const void buffer,
size_t  count 
)

Write data to the fifo buffer.

Will write up to the available space.

Parameters
fifoPointer to the fifo buffer structure.
bufferThe source buffer.
countThe number of bytes to write.
Returns
The number of bytes written.

Definition at line 73 of file fifo.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fifo_advance_head()

void fifo_advance_head ( fifo_t fifo,
size_t  count 
)

Advance the head of the fifo buffer.

Parameters
fifoPointer to the fifo buffer structure.
countThe number of bytes to advance the head by.

Definition at line 100 of file fifo.c.

◆ fifo_advance_tail()

void fifo_advance_tail ( fifo_t fifo,
size_t  count 
)

Advance the tail of the fifo buffer.

Parameters
fifoPointer to the fifo buffer structure.
countThe number of bytes to advance the tail by.

Definition at line 105 of file fifo.c.