usb: Hub Driver Update and Refactor

Hub Driver is refactored as follows:

This commit update and refactors the Hub Driver as follows:

- Refactored enumeration state machine and stage functions
    - Enumeration stage is now incremented
    - Combined transfer stages of enumeration into common functions
- Comments updated
- Fixed usbh_hal_disable_debounce_lock() that would cause root_port_handle_events()
    to fail the HCD_PORT_CMD_RESET call because the previous port connection interrupt
    was not cleared.

The following features were added to the Hub Driver

- Enumeration config descriptor is now fetched in two separate stages
    - Header is fetched first to determine the wTotalLength of the descriptor
    - Fetching the full descriptor will request exactly wTotalLength bytes
    - This works around some non-compliant devices that will babble/return zero
        when requesting a length > wTotalLength
    - Closes https://github.com/espressif/esp-idf/issues/7799
- Enumeration now stores string descriptors
    - The Manufacturer, Product, and Serial Number string descriptors are
        now read and stored during enumeration
    - String descriptors are now part of usb_device_info_t
- Added unit test to test enumeration
This commit is contained in:
Darian Leung
2021-12-08 19:46:46 +08:00
parent 7f09fe1b23
commit ea6de613bf
14 changed files with 1020 additions and 380 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -432,7 +432,7 @@ static esp_err_t msc_read_string_desc(msc_device_t *dev, uint8_t index, wchar_t
}
usb_transfer_t *xfer = dev->xfer;
USB_SETUP_PACKET_INIT_GET_STR_DESC((usb_setup_packet_t *)xfer->data_buffer, index, 64);
USB_SETUP_PACKET_INIT_GET_STR_DESC((usb_setup_packet_t *)xfer->data_buffer, index, 0x409, 64);
MSC_RETURN_ON_ERROR( msc_control_transfer(dev, xfer, USB_SETUP_PACKET_SIZE + 64) );
usb_standard_desc_t *desc = (usb_standard_desc_t *)(xfer->data_buffer + USB_SETUP_PACKET_SIZE);