summaryrefslogtreecommitdiff
path: root/src/common/tusb_fifo.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-11-12 10:41:58 +0700
committerhathach <[email protected]>2025-11-12 17:46:38 +0700
commitfc661abc18beefb57f5d1352219ed72678b59e0b (patch)
tree6c850325fc08f87f6af116b01dbca5013f5ed39c /src/common/tusb_fifo.c
parent8a094e807b34bcc018c971d59acb660b1a9ddf9f (diff)
migrate midi_device to use edpt stream API
also add tud_midi_n_packet_write/read_n()
Diffstat (limited to 'src/common/tusb_fifo.c')
-rw-r--r--src/common/tusb_fifo.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c
index 419046b8b..5c9e586fb 100644
--- a/src/common/tusb_fifo.c
+++ b/src/common/tusb_fifo.c
@@ -551,29 +551,12 @@ static uint16_t _tu_fifo_read_n(tu_fifo_t *f, void *buffer, uint16_t n, tu_fifo_
@returns Number of items in FIFO
*/
/******************************************************************************/
-uint16_t tu_fifo_count(tu_fifo_t *f) {
+uint16_t tu_fifo_count(const tu_fifo_t *f) {
return tu_min16(_ff_count(f->depth, f->wr_idx, f->rd_idx), f->depth);
}
/******************************************************************************/
/*!
- @brief 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.
-
- @param[in] f
- Pointer to the FIFO buffer to manipulate
-
- @returns Number of items in FIFO
- */
-/******************************************************************************/
-bool tu_fifo_empty(tu_fifo_t *f) {
- return f->wr_idx == f->rd_idx;
-}
-
-/******************************************************************************/
-/*!
@brief Check if FIFO is full.
As this function only reads the read and write pointers once, this function is
@@ -585,7 +568,7 @@ bool tu_fifo_empty(tu_fifo_t *f) {
@returns Number of items in FIFO
*/
/******************************************************************************/
-bool tu_fifo_full(tu_fifo_t *f) {
+bool tu_fifo_full(const tu_fifo_t *f) {
return _ff_count(f->depth, f->wr_idx, f->rd_idx) >= f->depth;
}
@@ -602,7 +585,7 @@ bool tu_fifo_full(tu_fifo_t *f) {
@returns Number of items in FIFO
*/
/******************************************************************************/
-uint16_t tu_fifo_remaining(tu_fifo_t *f) {
+uint16_t tu_fifo_remaining(const tu_fifo_t *f) {
return _ff_remaining(f->depth, f->wr_idx, f->rd_idx);
}
@@ -627,7 +610,7 @@ uint16_t tu_fifo_remaining(tu_fifo_t *f) {
@returns True if overflow happened
*/
/******************************************************************************/
-bool tu_fifo_overflowed(tu_fifo_t *f) {
+bool tu_fifo_overflowed(const tu_fifo_t *f) {
return _ff_count(f->depth, f->wr_idx, f->rd_idx) > f->depth;
}