summaryrefslogtreecommitdiff
path: root/src/host/usbh.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2022-04-20 18:29:41 +0700
committerhathach <[email protected]>2022-04-20 18:29:41 +0700
commitb034c18077ef1350f2678f245ed1b885e9be79fc (patch)
tree34685236202999d467a090fc051d965049373d3f /src/host/usbh.c
parentccafb42c8261d8304fce0af46c0ddc3adf6da56f (diff)
add tud_task_ext(), tuh_task_ext() as exteneded version that take timeout and in_isr
also allow exit tud_task,tuh_task after processing all events for running other background task for user
Diffstat (limited to 'src/host/usbh.c')
-rw-r--r--src/host/usbh.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/host/usbh.c b/src/host/usbh.c
index ad90a1b1b..80d176142 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -392,8 +392,10 @@ bool tuh_init(uint8_t rhport)
}
@endcode
*/
-void tuh_task(void)
+void tuh_task_ext(uint32_t timeout_ms, bool in_isr)
{
+ (void) in_isr; // not implemented yet
+
// Skip if stack is not initialized
if ( !tusb_inited() ) return;
@@ -401,7 +403,7 @@ void tuh_task(void)
while (1)
{
hcd_event_t event;
- if ( !osal_queue_receive(_usbh_q, &event, 1) ) return;
+ if ( !osal_queue_receive(_usbh_q, &event, timeout_ms) ) return;
switch (event.event_id)
{
@@ -497,6 +499,11 @@ void tuh_task(void)
default: break;
}
+
+#if CFG_TUSB_OS != OPT_OS_NONE && CFG_TUSB_OS != OPT_OS_PICO
+ // return if there is no more events, for application to run other background
+ if (osal_queue_empty(_usbh_q)) return;
+#endif
}
}