flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
fifo.h File Reference
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  Fifo
 FIFO object. More...
 

Macros

#define FIFO_POOL(name, len, esize)   uint8_t (name)[(len) * (esize)];
 

Typedefs

typedef void() FifoLockFn(bool lock)
 FIFO lock function.
 

Functions

void fifo_init (Fifo *f, uint32_t len, uint32_t esize, uint8_t *data, FifoLockFn lockFn)
 
bool fifo_push (Fifo *f, void const *item)
 
uint32_t fifo_get_level (const Fifo *f)
 
bool fifo_pop (Fifo *f, void *item)
 
void fifo_clear (Fifo *f)
 

Macro Definition Documentation

◆ FIFO_POOL

#define FIFO_POOL (   name,
  len,
  esize 
)    uint8_t (name)[(len) * (esize)];

Definition at line 31 of file fifo.h.

Typedef Documentation

◆ FifoLockFn

typedef void() FifoLockFn(bool lock)

FIFO lock function.

Parameters
locklock or unlock the system

Definition at line 16 of file fifo.h.

Function Documentation

◆ fifo_clear()

void fifo_clear ( Fifo f)

Clear the FIFO. (Thread-safe)

Parameters
fpointer to a FIFO object

Definition at line 75 of file fifo.c.

◆ fifo_get_level()

uint32_t fifo_get_level ( const Fifo f)

Get the FIFO utilization level.

Parameters
pointerto a FIFO object
Returns
utilization level

Definition at line 44 of file fifo.c.

◆ fifo_init()

void fifo_init ( Fifo f,
uint32_t  len,
uint32_t  esize,
uint8_t *  data,
FifoLockFn  lockFn 
)

Initialize the FIFO.

Parameters
fpointer to an uninitialized FIFO object
lennumber of slots
esizesize of an element
datapointer to the data pool
lockFnpointer to the locking function

Definition at line 4 of file fifo.c.

◆ fifo_pop()

bool fifo_pop ( Fifo f,
void *  item 
)

Pop the front item from the FIFO. (Thread-safe)

Parameters
fpointer to a FIFO object
itempointer to a block where the item is going to be pushed
Returns
pop successful

Definition at line 48 of file fifo.c.

◆ fifo_push()

bool fifo_push ( Fifo f,
void const *  item 
)

Push a new item into the FIFO. (Thread-safe)

Parameters
fpointer to a FIFO object
itempointer to an item to push
Returns
push successful

Definition at line 17 of file fifo.c.