summaryrefslogtreecommitdiff
path: root/src/tusb.h
diff options
context:
space:
mode:
authorRoman Leonov <[email protected]>2024-12-11 11:35:52 +0100
committerRoman Leonov <[email protected]>2025-01-15 09:45:29 +0100
commitdee6b369235e3440f9237ae0e74f81edca95f6b7 (patch)
tree4912373786bb43caff6d195f85e19ded6b72e19a /src/tusb.h
parent76fe0393edbc1b1ff80e3a333c233c81f1fc5d67 (diff)
feature(tusb): Added teardown API
Diffstat (limited to 'src/tusb.h')
-rw-r--r--src/tusb.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tusb.h b/src/tusb.h
index cb6021b33..2b122c302 100644
--- a/src/tusb.h
+++ b/src/tusb.h
@@ -154,14 +154,24 @@ 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);
+// Internal helper for backward compatibility with tusb_init(void)
+bool tusb_rhport_teardown(uint8_t rhport);
+
+#if defined(TUD_OPT_RHPORT) || defined(TUH_OPT_RHPORT)
+ #define _tusb_teardown_arg0() tusb_rhport_teardown(0)
+#else
+ #define _tusb_teardown_arg0() TU_VERIFY_STATIC(false, "CFG_TUSB_RHPORT0_MODE/CFG_TUSB_RHPORT1_MODE must be defined")
+#endif
+
+#define _tusb_teardown_arg1(_rhport) tusb_rhport_teardown(_rhport)
+#define tusb_teardown(...) TU_FUNC_OPTIONAL_ARG(_tusb_teardown, __VA_ARGS__)
#else
#define tusb_init(...) (false)
#define tusb_int_handler(...) do {}while(0)
#define tusb_inited() (false)
+#define tusb_teardown(...) (false)
#endif