Created
February 7, 2020 10:49
-
-
Save rajivr/2c15302993eceefbfc3104358ffa1a9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add `tud_task_is_queue_empty()` function | |
From: Rajiv Ranganath <rajiv.ranganath@atihita.com> | |
Signed-off-by: Rajiv Ranganath <rajiv.ranganath@atihita.com> | |
--- | |
src/device/usbd.c | 6 ++++++ | |
src/osal/osal_none.h | 10 ++++++++++ | |
2 files changed, 16 insertions(+) | |
diff --git a/src/device/usbd.c b/src/device/usbd.c | |
index 16670b94..b846ea5d 100644 | |
--- a/src/device/usbd.c | |
+++ b/src/device/usbd.c | |
@@ -330,6 +330,12 @@ static void usbd_reset(uint8_t rhport) | |
} | |
} | |
+extern bool osal_queue_is_empty(osal_queue_t const qhdl); | |
+ | |
+bool tud_task_is_queue_empty(void) { | |
+ return osal_queue_is_empty(_usbd_q); | |
+} | |
+ | |
/* USB Device Driver task | |
* This top level thread manages all device controller event and delegates events to class-specific drivers. | |
* This should be called periodically within the mainloop or rtos thread. | |
diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h | |
index b27e628a..de266a1c 100644 | |
--- a/src/osal/osal_none.h | |
+++ b/src/osal/osal_none.h | |
@@ -203,6 +203,16 @@ static inline bool osal_queue_send(osal_queue_t const qhdl, void const * data, b | |
return success; | |
} | |
+// non blocking | |
+static inline bool osal_queue_is_empty(osal_queue_t const qhdl) | |
+{ | |
+ _osal_q_lock(qhdl); | |
+ bool is_empty = tu_fifo_empty(&qhdl->ff); | |
+ _osal_q_unlock(qhdl); | |
+ | |
+ return is_empty; | |
+} | |
+ | |
#ifdef __cplusplus | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment