summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/host/usbh.c22
-rw-r--r--src/host/usbh.h10
2 files changed, 25 insertions, 7 deletions
diff --git a/src/host/usbh.c b/src/host/usbh.c
index dc347c458..3eff0830a 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -360,6 +360,14 @@ bool tuh_init(uint8_t controller_id)
return true;
}
+bool tuh_task_event_ready(void)
+{
+ // Skip if stack is not initialized
+ if ( !tuh_inited() ) return false;
+
+ return !osal_queue_empty(_usbh_q);
+}
+
/* USB Host Driver task
* This top level thread manages all host controller event and delegates events to class-specific drivers.
* 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)
(void) in_isr; // not implemented yet
// Skip if stack is not initialized
- if ( !tusb_inited() ) return;
+ if ( !tuh_inited() ) return;
// Loop until there is no more events in the queue
while (1)
@@ -565,12 +573,12 @@ bool tuh_control_xfer (tuh_xfer_t* xfer)
while (result == XFER_RESULT_INVALID)
{
- // only need to call task if not preempted RTOS
- #if CFG_TUSB_OS == OPT_OS_NONE || CFG_TUSB_OS == OPT_OS_PICO
- tuh_task();
- #else
- osal_task_delay(1); // TODO maybe yield()
- #endif
+ // Note: this can be called within an callback ie. part of tuh_task()
+ // therefore event with RTOS tuh_task() still need to be invoked
+ if (tuh_task_event_ready())
+ {
+ tuh_task();
+ }
// TODO probably some timeout to prevent hanged
}
diff --git a/src/host/usbh.h b/src/host/usbh.h
index 125d8f4c9..0f969a46a 100644
--- a/src/host/usbh.h
+++ b/src/host/usbh.h
@@ -69,6 +69,13 @@ struct tuh_xfer_s
// uint32_t timeout_ms; // place holder, not supported yet
};
+// Subject to change
+typedef struct
+{
+ uint8_t daddr;
+ tusb_desc_interface_t desc;
+} tuh_itf_info_t;
+
// ConfigID for tuh_config()
enum
{
@@ -118,6 +125,9 @@ void tuh_task(void)
tuh_task_ext(UINT32_MAX, false);
}
+// Check if there is pending events need processing by tuh_task()
+bool tuh_task_event_ready(void);
+
#ifndef _TUSB_HCD_H_
extern void hcd_int_handler(uint8_t rhport);
#endif