tinyusb  0.4
Click here to lend your support to tinyusb donation and make a donation at pledgie.com
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages

Data Structures

struct  fifo_t
 Simple Circular FIFO. More...
 

Macros

#define FIFO_DEF(name, ff_depth, type, is_overwritable)
 

Functions

bool fifo_write (fifo_t *f, void const *p_data)
 Write one byte into the RX buffer. More...
 
bool fifo_read (fifo_t *f, void *p_buffer)
 Read one byte out of the RX buffer. More...
 
void fifo_clear (fifo_t *f)
 Clear the fifo read and write pointers and set length to zero. More...
 
static bool fifo_is_empty (fifo_t *f) ATTR_PURE ATTR_ALWAYS_INLINE
 
static bool fifo_is_full (fifo_t *f) ATTR_PURE ATTR_ALWAYS_INLINE
 
static uint16_t fifo_get_length (fifo_t *f) ATTR_PURE ATTR_ALWAYS_INLINE
 

Variables

uint8_t *const buffer
 buffer pointer
 
uint16_t const depth
 max items
 
uint16_t const item_size
 size of each item
 
volatile uint16_t count
 number of items in queue
 
volatile uint16_t wr_idx
 write pointer
 
volatile uint16_t rd_idx
 read pointer
 
bool overwritable
 

Detailed Description

Macro Definition Documentation

#define FIFO_DEF (   name,
  ff_depth,
  type,
  is_overwritable 
)
Value:
/*, irq_mutex)*/ \
uint8_t name##_buffer[ff_depth*sizeof(type)];\
fifo_t name = {\
.buffer = name##_buffer,\
.depth = ff_depth,\
.item_size = sizeof(type),\
.overwritable = is_overwritable,\
/*.irq = irq_mutex*/\
}

Definition at line 67 of file fifo.h.

Function Documentation

void fifo_clear ( fifo_t f)

Clear the fifo read and write pointers and set length to zero.

Parameters
[in]fPointer to the FIFO buffer to manipulate

Definition at line 138 of file fifo.c.

bool fifo_read ( fifo_t f,
void *  p_buffer 
)

Read one byte out of the RX buffer.

This function will return the byte located at the array index of the read pointer, and then increment the read pointer index. If the read pointer exceeds the maximum buffer size, it will roll over to zero.

Parameters
[in]fPointer to the FIFO buffer to manipulate
[in]dataPointer to the place holder for data read from the buffer
Returns
TRUE if the queue is not empty

Definition at line 65 of file fifo.c.

bool fifo_write ( fifo_t f,
void const *  p_data 
)

Write one byte into the RX buffer.

This function will write one byte into the array index specified by the write pointer and increment the write index. If the write index exceeds the max buffer size, then it will roll over to zero.

Parameters
[in]fPointer to the FIFO buffer to manipulate
[in]dataThe byte to add to the FIFO
Returns
TRUE if the data was written to the FIFO (overwrittable FIFO will always return TRUE)

Definition at line 102 of file fifo.c.