Get number of items in FIFO. As this function only reads the read and write pointers once, this function is reentrant and thus thread and ISR save without any mutexes. In case an overflow occurred, this function return f.depth at maximum. Overflows are checked and corrected for in the read functions!
Clear the fifo read and write pointers
Get remaining space in FIFO. As this function only reads the read and write pointers once, this function is reentrant and thus thread and ISR save without any mutexes.
This function will write n elements into the array index specified by the write pointer and increment the write index.
This function will read n elements from the array index specified by the read pointer and increment the read index. This function checks for an overflow and corrects read pointer if required.
Read one item without removing it from the FIFO. This function checks for an overflow and corrects read pointer if required.
Check if FIFO is empty. As this function only reads the read and write pointers once, this function is reentrant and thus thread and ISR save without any mutexes.
Change the fifo mode to overwritable or not overwritable
Write one element into the buffer. This function will write one element into the array index specified by the write pointer and increment the write index.
Read one element out of the buffer. This function will return the element located at the array index of the read pointer, and then increment the read pointer index. This function checks for an overflow and corrects read pointer if required.
Check if FIFO is full. As this function only reads the read and write pointers once, this function is reentrant and thus thread and ISR save without any mutexes.
Advance write pointer - intended to be used in combination with DMA. It is possible to fill the FIFO by use of a DMA in circular mode. Within DMA ISRs you may update the write pointer to be able to read from the FIFO. As long as the DMA is the only process writing into the FIFO this is safe to use. USE WITH CARE - WE DO NOT CONDUCT SAFETY CHECKS HERE!
Advance read pointer - intended to be used in combination with DMA. It is possible to read from the FIFO by use of a DMA in linear mode. Within DMA ISRs you may update the read pointer to be able to again write into the FIFO. As long as the DMA is the only process reading from the FIFO this is safe to use. USE WITH CARE - WE DO NOT CONDUCT SAFETY CHECKS HERE!
Get read info Returns the length and pointer from which bytes can be read in a linear manner. This is of major interest for DMA transmissions. If returned length is zero the corresponding pointer is invalid. The read pointer does NOT get advanced, use tu_fifo_advance_read_pointer() to do so!
Get linear write info Returns the length and pointer to which bytes can be written into FIFO in a linear manner. This is of major interest for DMA transmissions not using circular mode. If a returned length is zero the corresponding pointer is invalid. The returned lengths summed up are the currently free space in the FIFO. The write pointer does NOT get advanced, use tu_fifo_advance_write_pointer() to do so! TAKE CARE TO NOT OVERFLOW THE BUFFER MORE THAN TWO TIMES THE FIFO DEPTH - IT CAN NOT RECOVERE OTHERWISE!
Read n items without removing it from the FIFO This function checks for an overflow and corrects read pointer if required.
Check if overflow happened. BE AWARE - THIS FUNCTION MIGHT NOT GIVE A CORRECT ANSWERE IN CASE WRITE POINTER "OVERFLOWS" Only one overflow is allowed for this function to work e.g. if depth = 100, you must not write more than 2*depth-1 items in one rush without updating write pointer. Otherwise write pointer wraps and your pointer states are messed up. This can only happen if you use DMAs, write functions do not allow such an error. Avoid such nasty things! All reading functions (read, peek) check for overflows and correct read pointer on their own such that latest items are read. If required (e.g. for DMA use) you can also correct the read pointer by tu_fifo_correct_read_pointer().