Move decouncing delay before USB reset.

Signed-off-by: HiFiPhile <admin@hifiphile.com>
This commit is contained in:
HiFiPhile 2025-04-18 17:41:41 +02:00 committed by hathach
parent 9f096ac56b
commit 3c4e6a779d
No known key found for this signature in database
GPG Key ID: 26FAB84F615C3C52

View File

@ -1692,6 +1692,15 @@ static bool enum_new_device(hcd_event_t* event) {
_dev0.hub_port = event->connection.hub_port;
if (_dev0.hub_addr == 0) {
// wait until device connection is stable TODO non blocking
tusb_time_delay_ms_api(ENUM_DEBOUNCING_DELAY_MS);
// device unplugged while delaying
if (!hcd_port_connect_status(_dev0.rhport)) {
enum_full_complete();
return true;
}
// connected directly to roothub
hcd_port_reset(_dev0.rhport);
@ -1701,9 +1710,6 @@ static bool enum_new_device(hcd_event_t* event) {
hcd_port_reset_end(_dev0.rhport);
// wait until device connection is stable TODO non blocking
tusb_time_delay_ms_api(ENUM_DEBOUNCING_DELAY_MS);
// device unplugged while delaying
if (!hcd_port_connect_status(_dev0.rhport)) {
enum_full_complete();