summaryrefslogtreecommitdiff
path: root/src/tusb.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tusb.h')
-rw-r--r--src/tusb.h46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/tusb.h b/src/tusb.h
index 4f69a1414..dfba21ddf 100644
--- a/src/tusb.h
+++ b/src/tusb.h
@@ -59,6 +59,10 @@
#include "class/cdc/cdc_host.h"
#endif
+ #if CFG_TUH_MIDI
+ #include "class/midi/midi_host.h"
+ #endif
+
#if CFG_TUH_VENDOR
#include "class/vendor/vendor_host.h"
#endif
@@ -127,20 +131,54 @@
//--------------------------------------------------------------------+
-// APPLICATION API
+// User API
//--------------------------------------------------------------------+
+#if CFG_TUH_ENABLED || CFG_TUD_ENABLED
+
+// Internal helper for backward compatible with tusb_init(void)
+bool tusb_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
-// Initialize device/host stack
+// Initialize roothub port with device/host role
// Note: when using with RTOS, this should be called after scheduler/kernel is started.
-// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
-bool tusb_init(void);
+// Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
+// Note2: defined as macro for backward compatible with tusb_init(void), can be changed to function in the future.
+#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
+ #define _tusb_init_arg0() tusb_rhport_init(0, NULL)
+#else
+ #define _tusb_init_arg0() TU_VERIFY_STATIC(false, "CFG_TUSB_RHPORT0_MODE/CFG_TUSB_RHPORT1_MODE must be defined")
+#endif
+
+#define _tusb_init_arg1(_rhport) _tusb_init_arg0()
+#define _tusb_init_arg2(_rhport, _rh_init) tusb_rhport_init(_rhport, _rh_init)
+#define tusb_init(...) TU_FUNC_OPTIONAL_ARG(_tusb_init, __VA_ARGS__)
// Check if stack is initialized
bool tusb_inited(void);
+// Called to handle usb interrupt/event. tusb_init(rhport, role) must be called before
+void tusb_int_handler(uint8_t rhport, bool in_isr);
+
// TODO
// bool tusb_teardown(void);
+#else
+
+#define tusb_init(...) (false)
+#define tusb_int_handler(...) do {}while(0)
+#define tusb_inited() (false)
+
+#endif
+
+//--------------------------------------------------------------------+
+// API Implemented by user
+//--------------------------------------------------------------------+
+
+// Get current milliseconds, required by some port/configuration without RTOS
+uint32_t tusb_time_millis_api(void);
+
+// Delay in milliseconds, use tusb_time_millis_api() by default. required by some port/configuration with no RTOS
+void tusb_time_delay_ms_api(uint32_t ms);
+
#ifdef __cplusplus
}
#endif