49#define CFG_FIFO_MUTEX OSAL_MUTEX_REQUIRED
118#if OSAL_MUTEX_REQUIRED
132#define TU_FIFO_INIT(_buffer, _depth, _type, _overwritable){\
135 .item_size = sizeof(_type), \
136 .overwritable = _overwritable, \
139#define TU_FIFO_DEF(_name, _depth, _type, _overwritable) \
140 uint8_t _name##_buf[_depth*sizeof(_type)]; \
141 tu_fifo_t _name = TU_FIFO_INIT(_name##_buf, _depth, _type, _overwritable)
147#if OSAL_MUTEX_REQUIRED
148TU_ATTR_ALWAYS_INLINE
static inline
154#define tu_fifo_config_mutex(_f, _wr_mutex, _rd_mutex)
159#ifdef TUP_MEM_CONST_ADDR
165#ifdef TUP_MEM_CONST_ADDR
179TU_ATTR_ALWAYS_INLINE
static inline
SemaphoreHandle_t osal_mutex_t
void * ptr_lin
linear part start pointer
uint16_t len_lin
linear length in item size
void * ptr_wrap
wrapped part start pointer
uint16_t len_wrap
wrapped length in item size
bool tu_fifo_overflowed(tu_fifo_t *f)
Check if overflow happened.
uint16_t tu_fifo_count(tu_fifo_t *f)
Get number of items in FIFO.
void tu_fifo_correct_read_pointer(tu_fifo_t *f)
uint16_t tu_fifo_write_n_const_addr_full_words(tu_fifo_t *f, const void *data, uint16_t n)
This function will write n elements into the array index specified by the write pointer and increment...
void tu_fifo_get_write_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info)
Get linear write info.
bool tu_fifo_config(tu_fifo_t *f, void *buffer, uint16_t depth, uint16_t item_size, bool overwritable)
bool tu_fifo_set_overwritable(tu_fifo_t *f, bool overwritable)
Change the fifo mode to overwritable or not overwritable.
uint16_t tu_fifo_peek_n(tu_fifo_t *f, void *p_buffer, uint16_t n)
Read n items without removing it from the FIFO This function checks for an overflow and corrects read...
static TU_ATTR_ALWAYS_INLINE uint16_t tu_fifo_depth(tu_fifo_t *f)
bool tu_fifo_peek(tu_fifo_t *f, void *p_buffer)
Read one item without removing it from the FIFO. This function checks for an overflow and corrects re...
void tu_fifo_advance_write_pointer(tu_fifo_t *f, uint16_t n)
Advance write pointer - intended to be used in combination with DMA. It is possible to fill the FIFO ...
uint16_t tu_fifo_read_n_const_addr_full_words(tu_fifo_t *f, void *buffer, uint16_t n)
This function will read n elements from the array index specified by the read pointer and increment t...
bool tu_fifo_full(tu_fifo_t *f)
Check if FIFO is full.
uint16_t tu_fifo_read_n(tu_fifo_t *f, void *buffer, uint16_t n)
This function will read n elements from the array index specified by the read pointer and increment t...
void tu_fifo_advance_read_pointer(tu_fifo_t *f, uint16_t n)
Advance read pointer - intended to be used in combination with DMA. It is possible to read from the F...
bool tu_fifo_read(tu_fifo_t *f, void *buffer)
Read one element out of the buffer.
bool tu_fifo_empty(tu_fifo_t *f)
Check if FIFO is empty.
bool tu_fifo_write(tu_fifo_t *f, void const *data)
Write one element into the buffer.
uint16_t tu_fifo_write_n(tu_fifo_t *f, void const *data, uint16_t n)
This function will write n elements into the array index specified by the write pointer and increment...
static TU_ATTR_ALWAYS_INLINE void tu_fifo_config_mutex(tu_fifo_t *f, osal_mutex_t wr_mutex, osal_mutex_t rd_mutex)
uint16_t tu_fifo_remaining(tu_fifo_t *f)
Get remaining space in FIFO.
void tu_fifo_get_read_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info)
Get read info.
bool tu_fifo_clear(tu_fifo_t *f)
Clear the fifo read and write pointers.