Commit Graph

16 Commits

Author SHA1 Message Date
Darian Leung
cbed197e10 usb_host: Run formatting script 2023-05-29 17:30:41 +08:00
Omar Chebib
cd21058097 C/Cxx: unify static assertions with the macro ESP_STATIC_ASSERT
Closes https://github.com/espressif/esp-idf/issues/9938
2022-11-21 16:18:08 +08:00
Tomas Rezucha
dc705312a3 usb: Allow settings of all signals in usb_phy
Until now, only usb_phy signals for external PHY were defined.
This is now extended with all OTG signals.
2022-10-18 09:18:29 +02:00
Marius Vikhammer
c8617fe965 docs: fix all doxygen warnings
Doxygen warnings would previously not result in a failed pipeline.
Fixed this as well as all current warnings.
2022-05-12 14:50:03 +08:00
Darian Leung
ada1c9c5b8 usb: Add USB Host Library documentation
This commit adds the USB Host Library documentation and fixes some nitpicks
in the Host Stack types.

Closes https://github.com/espressif/esp-idf/issues/6408
2022-01-06 15:15:32 +08:00
Darian Leung
b6dfadb168 usb: Update USB Host Library
This commit updates the USB Host Library as follows:

- usb_helpers.h
    - Removed dependency on USB Host Library API
    - Added function to print string descriptors
- usbh
    - Fixed bug where an interface/endpoint could be claimed/allocated multiple times
    - Removed redundant device ref_count change
- Added unit test for USB Host Library API usage
2022-01-06 15:14:10 +08:00
Darian Leung
1aad12468a 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
2022-01-06 15:11:13 +08:00
Darian Leung
854127a57c usb: USB Host stack uses USB PHY driver
This commit updates the USB Host stack to use the USB PHY driver. The
USB PHY and the OTG Controller should now both be setup/deleted using
usb_new_phy() and usb_del_phy() respectively.

- The hcd_install() now expects the USB PHY and OTG Contorller to be
    already setup before it is called
- usb_host_install() now has an option to skip calling usb_del_phy() if
    the user wants to setup their own USB PHY (e.g., in the case of using
    and external PHY).
- CDC-ACM and MSC examples/test updated to use internal PHY

Closes https://github.com/espressif/esp-idf/issues/8061
2022-01-06 15:09:39 +08:00
Darian Leung
5a2ef15565 usb: HCD multiple fixes
This commit fixes the following bugs in the HCD

- HCD control pipes fill incorrect transfer size

_buffer_fill_ctrl() would fill the transfer descriptors length with
wLength instead of transfer->num_bytes. Therefore, the remaining length
would be incorrect when a control transfer requests more bytes than are
available.

- Fix USB_TRANSFER_FLAG_ZERO_PACK behavior

The previous behavior of USB_TRANSFER_FLAG_ZERO_PACK was incorrect, and did not
support interrupt pipes. A zero length packet can now be added to Bulk/Interrupt
OUT transfers where the length is a multiple of the endpoint's MPS.

- Fixed HCD port suspend and resume test case

Halting a control pipe mid control transfer can lead some test devices to get stuck
2022-01-06 15:07:56 +08:00
Martin Valik
73dce765d5 USB: added MSC Host Driver with VFS support
Closes https://github.com/espressif/esp-idf/issues/6401
2021-12-20 12:39:45 +01:00
Tomas Rezucha
dd1b698075 usb: Add USB host CDC-ACM class driver 2021-12-09 10:28:46 +01:00
Darian Leung
189899180f usb: Change API and refactor tests
This commit updates the USB Host Library API in the following wasy:
- usb_host_client_handle_t and usb_device_handle_t made into struct pointers
  to generate compiler warnings about conflicting handle types
- usb_host_client_config_t changed to future proof API for Synchronous Clients
- Added usb_host_lib_unblock()
- Added usb_host_device_addr_list_fill()
- Return of usb_host_device_free_all() updated to indicate whether there
  are still devices yet to be freed.
- Blockg APIs are now marked explicitly
- Fixed a bug in usb_host_transfer_submit_control() when checking the bEndpointAddress
  of a control transfer.

Tests are also refactored to move some common macros into shared headers

Closes https://github.com/espressif/esp-idf/issues/7786
2021-11-02 14:30:58 +08:00
Darian Leung
0c758c8557 usb: Fix how the HCD handles sudden disconnection
This commit fixes how the USB Host HCD handles sudden disconnections.

Bugs:
- HW channels remain active when the port suddenly disconnects, and
previously the channel would be disabled by setting the disabled bit,
then waiting for a disabled interrupt. However, ISOC channels do not
generate the disabled interrupt when the port is invalid, thus leading
to tasks getting indefinitely blocked in hcd_pipe_command().

Fix:
On a sudden disconnection, forcibly treat all channels as halted even
if their HCCHAR.ChEna bit is still set. We do a soft reset after a port
error anyways, so the channels will eventually be reset.

Closes https://github.com/espressif/esp-idf/issues/7505
2021-11-02 14:30:58 +08:00
songruojing
1fcd639224 usb: Add usb_phy driver to support operations on USB PHY 2021-09-13 12:39:56 +08:00
Darian Leung
963836f491 Add USB Host Library API docs
- This commit adds the API documentation for the USB Host Library.
- Warnings about the beta API are also added.
- usb_host_misc.h renamed to usb_helpers.h
2021-09-02 18:40:24 +08:00
Darian Leung
accbaee57c Add USB Host Library
This commit adds the preliminary version of the USB Host Library. This commit contains:

- USBH (USB Host Driver)
- Hub Driver that only supports a single device and device enumeration
- USB Host Library (asychronous API)
- Test cases for USB Host Library asychronous API

The following changes were made to the existing HCD:
- Removed HCD_PIPE_STATE_INVALID. Pipes are no longer invalidated
- Changed pipe commands to halt, flush, and clear. Pipes need to be manually
  halted, flush, and cleared.
- Halting and flushing a pipe will execute the pipe callback if it causes a
  HCD_PIPE_EVENT_URB_DONE event
2021-08-24 23:28:00 +08:00