summaryrefslogtreecommitdiff
path: root/src/tusb.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-05-11 17:32:52 +0700
committerhathach <[email protected]>2021-05-18 12:58:24 +0700
commit3a7f8b3ac3988eeb653ada6e3efdd7acb68fbe0f (patch)
tree74f7e9e7327e5206fc5ec98d6151a91f6d627f25 /src/tusb.c
parent2666e1efec20d78f8f74c23cdbb7977737b8d956 (diff)
separte tusb_init/inited() to tud/tuh init/inited
add rhport to tud_init()
Diffstat (limited to 'src/tusb.c')
-rw-r--r--src/tusb.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/tusb.c b/src/tusb.c
index 31452e897..0350fa1de 100644
--- a/src/tusb.c
+++ b/src/tusb.c
@@ -30,8 +30,6 @@
#include "tusb.h"
-static bool _initialized = false;
-
// TODO clean up
#if TUSB_OPT_DEVICE_ENABLED
#include "device/usbd_pvt.h"
@@ -39,25 +37,30 @@ static bool _initialized = false;
bool tusb_init(void)
{
- // skip if already initialized
- if (_initialized) return true;
-
-#if TUSB_OPT_HOST_ENABLED
- TU_ASSERT( tuh_init() ); // init host stack
-#endif
-
#if TUSB_OPT_DEVICE_ENABLED
- TU_ASSERT ( tud_init() ); // init device stack
+ TU_ASSERT ( tud_init(TUD_OPT_RHPORT) ); // init device stack
#endif
- _initialized = true;
+#if TUSB_OPT_HOST_ENABLED
+ TU_ASSERT( tuh_init(TUH_OPT_RHPORT) ); // init host stack
+#endif
return true;
}
bool tusb_inited(void)
{
- return _initialized;
+ bool ret = false;
+
+#if TUSB_OPT_DEVICE_ENABLED
+ ret = ret || tud_inited();
+#endif
+
+#if TUSB_OPT_HOST_ENABLED
+ ret = ret || tuh_inited();
+#endif
+
+ return ret;
}
/*------------------------------------------------------------------*/