@@ -341,7 +341,7 @@ void USBClass::setupUSBDescriptor() {
341341
342342#ifdef ENABLE_PICOTOOL_USB
343343 uint8_t picotool_desc[] = { TUD_RPI_RESET_DESCRIPTOR (1 , USB.registerString (" Reset" )) };
344- USB.registerInterface (1 , picotool_desc, sizeof (picotool_desc), 100 , 0 );
344+ _picotool_itf_num = USB.registerInterface (1 , picotool_desc, sizeof (picotool_desc), 100 , 0 );
345345#endif
346346
347347 usbd_desc_cfg_len = TUD_CONFIG_DESC_LEN; // Always have a config descriptor
@@ -470,6 +470,9 @@ void USBClass::disconnect() {
470470 free (_hid_report);
471471 _hid_report = nullptr ;
472472 _hid_report_len = 0 ;
473+ #ifdef ENABLE_PICOTOOL_USB
474+ unregisterInterface (_picotool_itf_num);
475+ #endif
473476}
474477
475478void USBClass::connect () {
@@ -608,12 +611,14 @@ extern "C" void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t pr
608611
609612#ifdef ENABLE_PICOTOOL_USB
610613
614+ static uint32_t _itf_num = 0 ;
615+
611616static void resetd_init () {
612617}
613618
614619static void resetd_reset (uint8_t rhport) {
615620 (void ) rhport;
616- _picotool_itf_num = 0 ;
621+ _itf_num = 0 ;
617622}
618623
619624static uint16_t resetd_open (uint8_t rhport,
@@ -626,7 +631,7 @@ static uint16_t resetd_open(uint8_t rhport,
626631 uint16_t const drv_len = sizeof (tusb_desc_interface_t );
627632 TU_VERIFY (max_len >= drv_len, 0 );
628633
629- _picotool_itf_num = itf_desc->bInterfaceNumber ;
634+ _itf_num = itf_desc->bInterfaceNumber ;
630635 return drv_len;
631636}
632637
@@ -639,7 +644,7 @@ static bool resetd_control_xfer_cb(uint8_t rhport, uint8_t stage,
639644 return true ;
640645 }
641646
642- if (request->wIndex == _picotool_itf_num ) {
647+ if (request->wIndex == _itf_num ) {
643648 if (request->bRequest == RESET_REQUEST_BOOTSEL) {
644649 reset_usb_boot (0 , (request->wValue & 0x7f ));
645650 // does not return, otherwise we'd return true
0 commit comments