Commit Graph

27 Commits

Author SHA1 Message Date
Peter Marcisovsky
ddc3c2b78b refactor(usb_host): Update USB Host multiconfig public API
- previous usb_host_get_config_desc_free()
    - updated usb_host_free_config_desc()
2024-07-16 11:32:22 +02:00
Roman Leonov
548b03c69f feat(ext_hub): Added External Hub driver 2024-06-25 11:28:03 +02:00
Peter Marcisovsky
6cabb68d12 feat(usb/host): multiconfiguration support
- usb host reads device's configuration on request
    - a control transfer is sent
    - memory is allocated for a new descriptor
    - user must manually free the memory
2024-06-19 09:40:57 +02:00
Roman Leonov
596672fdcd refactor(usbh): Updated USBH api (enum driver) 2024-05-07 15:07:51 +02:00
Roman Leonov
029c286a21 feat(usb_host): Added KConfig parameter for External HUB support enable 2024-03-14 21:06:34 +01:00
Roman Leonov
8d93d18451 refactor(usb_host): Added chapter11 header, refactor chapter9 header 2024-03-14 21:06:34 +01:00
Tomas Rezucha
5863a27bd2 feat(usb/host): Add missing sync types from USB specification 2024-02-26 10:50:20 +01:00
Tomas Rezucha
f13ae0fc08 feat(esp32p4): Add USB-OTG support for ESP32-P4 2024-01-30 15:07:11 +01:00
Peter Marcisovsky
24adb6ed3c feat(us/host): set device cfg during enumeration
- user callback funciton to set device configuration
      as a part of usb_host_install
    - callback provides device descriptor of a device being enumerated
    - user can set which cfg descriptor the USB device will be set with
    - user can filter device enumeration
    - Kconfig menu to enable callback function
    - usb_host_lib example demonstration
2024-01-04 16:09:13 +01:00
Tomas Rezucha
c2660ce7c6 fix(usb/host): Correctly parse MPS fields in HighSpeed EP descriptors
Bits [11,12] in HighSpeed periodic endpoints specify
the number of additional transaction opportunities per microframe
2023-12-12 21:10:37 +01:00
Tomas Rezucha
69d9e7625b feat(usb/host): Add High Speed enumeration types 2023-11-30 10:17:00 +08:00
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