tinyusb
tinyusb copied to clipboard
un-roll recursive call when unplug an hub device
Is your feature request related to a problem? Please describe. PR #1480 add support for multiple-level hub using recursive call of process_device_unplugged()
However in limited MCU, recursive call chain can cause stack overflow. We should find an way to un-roll the recursive chain. After all, the device loop is rather small (4-10) only.
Describe the solution you'd like It is always possible to un-roll an recursive chain to a loop with/without an queue. We could use a status (disconnected/connected) and/or usbh event queue to achieve this.
https://github.com/hathach/tinyusb/blob/d7b579a9785a7be62174a912ddb4e34aea8a1156/src/host/usbh.c#L1110-L1152