forked from espressif/esp-idf
fix(ext_port): Moved reset recovery delay in correct place, removed delay while polling port which in reset state
This commit is contained in:
@@ -262,9 +262,17 @@ static esp_err_t port_set_feature(ext_port_t *ext_port, const usb_hub_port_featu
|
|||||||
}
|
}
|
||||||
// Every set feature requires status update
|
// Every set feature requires status update
|
||||||
ext_port->flags.status_outdated = 1;
|
ext_port->flags.status_outdated = 1;
|
||||||
|
switch (feature) {
|
||||||
|
case USB_FEATURE_PORT_POWER:
|
||||||
// PowerOn to PowerGood delay for port
|
// PowerOn to PowerGood delay for port
|
||||||
if (feature == USB_FEATURE_PORT_POWER) {
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(ext_port->constant.power_on_delay_ms));
|
vTaskDelay(pdMS_TO_TICKS(ext_port->constant.power_on_delay_ms));
|
||||||
|
break;
|
||||||
|
case USB_FEATURE_PORT_RESET:
|
||||||
|
// Port has reset, give the port some time to recover
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(EXT_PORT_RESET_RECOVERY_DELAY_MS));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -552,12 +560,9 @@ static bool handle_port_status(ext_port_t *ext_port)
|
|||||||
{
|
{
|
||||||
bool need_processing = false;
|
bool need_processing = false;
|
||||||
if (port_is_in_reset(ext_port)) {
|
if (port_is_in_reset(ext_port)) {
|
||||||
ESP_LOGD(EXT_PORT_TAG, "[%d:%d] Port still in reset, wait and repeat get status...",
|
ESP_LOGW(EXT_PORT_TAG, "[%d:%d] Port still in reset, wait and repeat get status...",
|
||||||
ext_port->constant.parent_dev_addr,
|
ext_port->constant.parent_dev_addr,
|
||||||
ext_port->constant.port_num);
|
ext_port->constant.port_num);
|
||||||
// Rare case, but possible to happen
|
|
||||||
// Add a small delay to give port some time and request status again
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(30));
|
|
||||||
port_request_status(ext_port);
|
port_request_status(ext_port);
|
||||||
need_processing = true;
|
need_processing = true;
|
||||||
}
|
}
|
||||||
@@ -657,8 +662,6 @@ static bool handle_port_changes(ext_port_t *ext_port)
|
|||||||
} else if (port_has_finished_reset(ext_port)) {
|
} else if (port_has_finished_reset(ext_port)) {
|
||||||
if (port_has_connection(ext_port)) {
|
if (port_has_connection(ext_port)) {
|
||||||
ext_port->state = USB_PORT_STATE_ENABLED;
|
ext_port->state = USB_PORT_STATE_ENABLED;
|
||||||
// Port has a device connected and finished the reset, give the port some time to recover
|
|
||||||
vTaskDelay(pdMS_TO_TICKS(EXT_PORT_RESET_RECOVERY_DELAY_MS));
|
|
||||||
}
|
}
|
||||||
port_clear_feature(ext_port, USB_FEATURE_C_PORT_RESET);
|
port_clear_feature(ext_port, USB_FEATURE_C_PORT_RESET);
|
||||||
need_processing = true;
|
need_processing = true;
|
||||||
|
Reference in New Issue
Block a user