diff options
| author | Reinhard Panhuber <[email protected]> | 2021-02-17 20:44:26 +0100 |
|---|---|---|
| committer | Reinhard Panhuber <[email protected]> | 2021-02-17 20:44:26 +0100 |
| commit | c87357c0257251f2cecfe83a29035648c5a47662 (patch) | |
| tree | 9e9cdd36ffa8550827d8147548b796da1c14c597 /src/common/tusb_fifo.h | |
| parent | a5d7b6266dca8a4f79178f5978401b680ddfa637 (diff) | |
Improve tu_fifo capabilites
Added tu_fifo_get_linear_write_info(), tu_fifo_backward_write_pointer(),
and tu_fifo_backward_read_pointer()
Diffstat (limited to 'src/common/tusb_fifo.h')
| -rw-r--r-- | src/common/tusb_fifo.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/tusb_fifo.h b/src/common/tusb_fifo.h index 7ece30b74..833b3eead 100644 --- a/src/common/tusb_fifo.h +++ b/src/common/tusb_fifo.h @@ -128,13 +128,22 @@ uint16_t tu_fifo_count (tu_fifo_t* f); bool tu_fifo_empty (tu_fifo_t* f); bool tu_fifo_full (tu_fifo_t* f); uint16_t tu_fifo_remaining (tu_fifo_t* f); -bool tu_fifo_overflowed (tu_fifo_t* f); +bool tu_fifo_overflowed (tu_fifo_t* f); void tu_fifo_correct_read_pointer (tu_fifo_t* f); // Pointer modifications intended to be used in combinations with DMAs. // USE WITH CARE - NO SAFTY CHECKS CONDUCTED HERE! NOT MUTEX PROTECTED! void tu_fifo_advance_write_pointer (tu_fifo_t *f, uint16_t n); +void tu_fifo_backward_write_pointer (tu_fifo_t *f, uint16_t n); void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n); +void tu_fifo_backward_read_pointer (tu_fifo_t *f, uint16_t n); + +// If you want to read/write from/to the FIFO by use of a DMA, you may need to conduct two copies to handle a possible wrapping part +// This functions deliver a pointer to start reading/writing from/to and a valid linear length along which no wrap occurs. +// In case not all of your data is available within one read/write, update the read/write pointer by +// tu_fifo_advance_read_pointer()/tu_fifo_advance_write_pointer and conduct a second read/write operation +uint16_t tu_fifo_get_linear_read_info (tu_fifo_t *f, uint16_t offset, void **ptr, uint16_t n); +uint16_t tu_fifo_get_linear_write_info (tu_fifo_t *f, uint16_t offset, void **ptr, uint16_t n); static inline bool tu_fifo_peek(tu_fifo_t* f, void * p_buffer) { |
