File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,29 @@ void tusb_int_handler(uint8_t rhport, bool in_isr) {
136136 #endif
137137}
138138
139+ bool tusb_deinit (uint8_t rhport ) {
140+ TU_VERIFY (rhport < TUP_USBIP_CONTROLLER_NUM );
141+ bool ret = false;
142+
143+ #if CFG_TUD_ENABLED
144+ if (_tusb_rhport_role [rhport ] == TUSB_ROLE_DEVICE ) {
145+ TU_ASSERT (tud_deinit (rhport ));
146+ _tusb_rhport_role [rhport ] = TUSB_ROLE_INVALID ;
147+ ret = true;
148+ }
149+ #endif
150+
151+ #if CFG_TUH_ENABLED
152+ if (_tusb_rhport_role [rhport ] == TUSB_ROLE_HOST ) {
153+ TU_ASSERT (tuh_deinit (rhport ));
154+ _tusb_rhport_role [rhport ] = TUSB_ROLE_INVALID ;
155+ ret = true;
156+ }
157+ #endif
158+
159+ return ret ;
160+ }
161+
139162//--------------------------------------------------------------------+
140163// Descriptor helper
141164//--------------------------------------------------------------------+
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ bool tusb_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
140140
141141// Initialize roothub port with device/host role
142142// Note: when using with RTOS, this should be called after scheduler/kernel is started.
143- // Otherwise, it could cause kernel issue since USB IRQ handler does use RTOS queue API.
143+ // Since USB IRQ handler does use RTOS queue API.
144144// Note2: defined as macro for backward compatible with tusb_init(void), can be changed to function in the future.
145145#if defined(TUD_OPT_RHPORT ) || defined(TUH_OPT_RHPORT )
146146 #define _tusb_init_arg0 () tusb_rhport_init(0, NULL)
@@ -158,14 +158,15 @@ bool tusb_inited(void);
158158// Called to handle usb interrupt/event. tusb_init(rhport, role) must be called before
159159void tusb_int_handler (uint8_t rhport , bool in_isr );
160160
161- // TODO
162- // bool tusb_teardown(void );
161+ // Deinit usb stack on roothub port
162+ bool tusb_deinit ( uint8_t rhport );
163163
164164#else
165165
166166#define tusb_init (...) (false)
167167#define tusb_int_handler (...) do {}while(0)
168168#define tusb_inited () (false)
169+ #define tusb_deinit (...) (false)
169170
170171#endif
171172
You can’t perform that action at this time.
0 commit comments