From 8dcb10493330513b5b017306634a936413f1ecd5 Mon Sep 17 00:00:00 2001 From: Reinhard Panhuber Date: Sat, 26 Sep 2020 11:00:31 +0200 Subject: [PATCH] Change modulo substitute to while ( idx >= depth) idx -= depth; --- src/common/tusb_fifo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c index 1e0c6b5e..f41cf9f6 100644 --- a/src/common/tusb_fifo.c +++ b/src/common/tusb_fifo.c @@ -81,9 +81,8 @@ bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_si static inline uint16_t _ff_mod(uint16_t idx, uint16_t depth) { -// return idx % depth; - idx -= depth & -(idx >= depth); - return idx -= depth & -(idx >= depth); + while ( idx >= depth) idx -= depth; + return idx; } // send one item to FIFO WITHOUT updating write pointer