Page 1 of 1

[SP32 P4] tiny_usb handler never called when device is dettached

Posted: Fri Oct 31, 2025 3:09 pm
by jared_s
Hi,

I configured my USB OTG port to CDC+MIDI, registered handler in:

Code: Select all

 tinyusb_config_t tusb_cfg = TINYUSB_DEFAULT_CONFIG(device_event_handler, this);
handler:

Code: Select all

void device_event_handler(tinyusb_event_t *event, void *arg)
{}
device_event_handler is called when device is attached only (when I plug USB cable from host to the OTG USB on ESP board)
but it is never called when I unplug the cable.

I tried als check the status uf the tiny_usb in loop using:

Code: Select all

bool isConnected = tud_connected() && tud_mounted();
but tud_connected() or tud_mounted() are always TRUE even the cable is unplugged.

Is this a bug or I missed something?

Thanks,

J.

Code: Select all

## IDF Component Manager Manifest File
dependencies:
  idf: ">=5.2.0"   

  # TinyUSB wrapper and core:
  espressif/esp_tinyusb: "~2.0.1"
  espressif/tinyusb: ">=0.17.0"