mirror of
https://github.com/hathach/tinyusb.git
synced 2026-02-06 16:15:22 +00:00
add back tu_fifo_discard_n() since it may be useful in the future.
This commit is contained in:
@ -448,6 +448,15 @@ uint16_t tu_fifo_write_n_access_mode(tu_fifo_t *f, const void *data, uint16_t n,
|
||||
return n;
|
||||
}
|
||||
|
||||
uint16_t tu_fifo_discard_n(tu_fifo_t *f, uint16_t n) {
|
||||
const uint16_t count = tu_min16(n, tu_fifo_count(f)); // limit to available count
|
||||
ff_lock(f->mutex_rd);
|
||||
f->rd_idx = advance_index(f->depth, f->rd_idx, count);
|
||||
ff_unlock(f->mutex_rd);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// One API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@ -205,6 +205,10 @@ TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_read_n(tu_fifo_t *f, void *
|
||||
return tu_fifo_read_n_access_mode(f, buffer, n, TU_FIFO_INC_ADDR_RW8);
|
||||
}
|
||||
|
||||
// discard first n items from fifo i.e advance read pointer by n with mutex
|
||||
// return number of discarded items
|
||||
uint16_t tu_fifo_discard_n(tu_fifo_t *f, uint16_t n);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Write API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user