diff options
| author | Ha Thach <[email protected]> | 2022-04-20 23:32:50 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-20 23:32:50 +0700 |
| commit | 55a5fd59d7263289f5c26d52ab206ed571cc1e0c (patch) | |
| tree | 17f0c6d038ea9a73fdc78d94f15e50f2b3233b5c /src/device/usbd.c | |
| parent | 9c8c5c1c53214b8954bb28c33a496b5b423d5ecc (diff) | |
| parent | 87572871d586856242c1fa44b1532a09e624162d (diff) | |
Merge pull request #1440 from hathach/osal-queue-timeout
Osal queue timeout
Diffstat (limited to 'src/device/usbd.c')
| -rw-r--r-- | src/device/usbd.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index 7ab2660f4..167a053e2 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -466,8 +466,10 @@ bool tud_task_event_ready(void) } @endcode */ -void tud_task (void) +void tud_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; @@ -475,8 +477,7 @@ void tud_task (void) while (1) { dcd_event_t event; - - if ( !osal_queue_receive(_usbd_q, &event) ) return; + if ( !osal_queue_receive(_usbd_q, &event, timeout_ms) ) return; #if CFG_TUSB_DEBUG >= 2 if (event.event_id == DCD_EVENT_SETUP_RECEIVED) TU_LOG2("\r\n"); // extra line for setup @@ -593,6 +594,11 @@ void tud_task (void) TU_BREAKPOINT(); 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(_usbd_q)) return; +#endif } } |
