diff options
| author | hathach <[email protected]> | 2022-04-21 12:05:22 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2022-04-21 12:05:22 +0700 |
| commit | 98bbb0d40251a4fb6af8e20506c5b27a18e8d29e (patch) | |
| tree | d874d9126c1377cec120ba13cd6026ce42475e05 /src/device | |
| parent | 328039058ef1c654246304a3a0acbee724278b85 (diff) | |
| parent | 55a5fd59d7263289f5c26d52ab206ed571cc1e0c (diff) | |
Merge branch 'master' into pio-host
Diffstat (limited to 'src/device')
| -rw-r--r-- | src/device/usbd.c | 12 | ||||
| -rw-r--r-- | src/device/usbd.h | 11 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index 8d5d54b86..12b4071af 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 } } diff --git a/src/device/usbd.h b/src/device/usbd.h index 32c82e75a..964cfb992 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -43,8 +43,17 @@ bool tud_init (uint8_t rhport); // Check if device stack is already initialized bool tud_inited(void); +// Task function should be called in main/rtos loop, extended version of tud_task() +// - timeout_ms: millisecond to wait, zero = no wait, 0xFFFFFFFF = wait forever +// - in_isr: if function is called in ISR +void tud_task_ext(uint32_t timeout_ms, bool in_isr); + // Task function should be called in main/rtos loop -void tud_task (void); +TU_ATTR_ALWAYS_INLINE static inline +void tud_task (void) +{ + tud_task_ext(UINT32_MAX, false); +} // Check if there is pending events need processing by tud_task() bool tud_task_event_ready(void); |
