summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/device/usbd.c3
-rw-r--r--src/host/usbh.c3
-rw-r--r--src/tusb.c5
-rw-r--r--src/tusb.h3
4 files changed, 14 insertions, 0 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 9c08a7932..d4eccf0c4 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -240,6 +240,9 @@ static void usbd_reset(uint8_t rhport)
*/
void tud_task (void)
{
+ // Skip if stack is not initialized
+ if ( !tusb_inited() ) return;
+
// Loop until there is no more events in the queue
while (1)
{
diff --git a/src/host/usbh.c b/src/host/usbh.c
index 4334729e9..a7e7c2acd 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -620,6 +620,9 @@ bool enum_task(hcd_event_t* event)
*/
void tuh_task(void)
{
+ // Skip if stack is not initialized
+ if ( !tusb_inited() ) return;
+
// Loop until there is no more events in the queue
while (1)
{
diff --git a/src/tusb.c b/src/tusb.c
index ad2dcbfd3..566d74df7 100644
--- a/src/tusb.c
+++ b/src/tusb.c
@@ -68,6 +68,11 @@ bool tusb_init(void)
return TUSB_ERROR_NONE;
}
+bool tusb_inited(void)
+{
+ return _initialized;
+}
+
/*------------------------------------------------------------------*/
/* Debug
*------------------------------------------------------------------*/
diff --git a/src/tusb.h b/src/tusb.h
index fb20c5ff7..69c4d16d2 100644
--- a/src/tusb.h
+++ b/src/tusb.h
@@ -108,6 +108,9 @@
// Initialize device/host stack
bool tusb_init(void);
+// Check if stack is initialized
+bool tusb_inited(void);
+
// TODO
// bool tusb_teardown(void);