File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -360,6 +360,14 @@ bool tuh_init(uint8_t controller_id)
360
360
return true;
361
361
}
362
362
363
+ bool tuh_task_event_ready (void )
364
+ {
365
+ // Skip if stack is not initialized
366
+ if ( !tuh_inited () ) return false;
367
+
368
+ return !osal_queue_empty (_usbh_q );
369
+ }
370
+
363
371
/* USB Host Driver task
364
372
* This top level thread manages all host controller event and delegates events to class-specific drivers.
365
373
* This should be called periodically within the mainloop or rtos thread.
@@ -383,7 +391,7 @@ void tuh_task_ext(uint32_t timeout_ms, bool in_isr)
383
391
(void ) in_isr ; // not implemented yet
384
392
385
393
// Skip if stack is not initialized
386
- if ( !tusb_inited () ) return ;
394
+ if ( !tuh_inited () ) return ;
387
395
388
396
// Loop until there is no more events in the queue
389
397
while (1 )
@@ -565,12 +573,12 @@ bool tuh_control_xfer (tuh_xfer_t* xfer)
565
573
566
574
while (result == XFER_RESULT_INVALID )
567
575
{
568
- // only need to call task if not preempted RTOS
569
- #if CFG_TUSB_OS == OPT_OS_NONE || CFG_TUSB_OS == OPT_OS_PICO
570
- tuh_task ();
571
- #else
572
- osal_task_delay ( 1 ); // TODO maybe yield()
573
- #endif
576
+ // Note: this can be called within an callback ie. part of tuh_task()
577
+ // therefore event with RTOS tuh_task() still need to be invoked
578
+ if ( tuh_task_event_ready ())
579
+ {
580
+ tuh_task ();
581
+ }
574
582
575
583
// TODO probably some timeout to prevent hanged
576
584
}
Original file line number Diff line number Diff line change @@ -69,6 +69,13 @@ struct tuh_xfer_s
69
69
// uint32_t timeout_ms; // place holder, not supported yet
70
70
};
71
71
72
+ // Subject to change
73
+ typedef struct
74
+ {
75
+ uint8_t daddr ;
76
+ tusb_desc_interface_t desc ;
77
+ } tuh_itf_info_t ;
78
+
72
79
// ConfigID for tuh_config()
73
80
enum
74
81
{
@@ -118,6 +125,9 @@ void tuh_task(void)
118
125
tuh_task_ext (UINT32_MAX , false);
119
126
}
120
127
128
+ // Check if there is pending events need processing by tuh_task()
129
+ bool tuh_task_event_ready (void );
130
+
121
131
#ifndef _TUSB_HCD_H_
122
132
extern void hcd_int_handler (uint8_t rhport );
123
133
#endif
You can’t perform that action at this time.
0 commit comments