tinyusb icon indicating copy to clipboard operation
tinyusb copied to clipboard

un-roll recursive call when unplug an hub device

Open hathach opened this issue 2 years ago • 0 comments

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

hathach avatar Jun 16 '22 09:06 hathach