Commit Graph

163 Commits

Author SHA1 Message Date
Roman Leonov
dbad0df765 refactor(hcd_dwc): Added mps request from hcd_dwc 2024-04-02 10:23:52 +02:00
gaoxu
40f38bea6f feat(dma): refactor dma calloc function 2024-04-02 14:30:14 +08:00
Armando
f0518b3c16 feat(dma): advanced dma malloc helper 2024-04-02 14:30:14 +08:00
Darian
f66a23a8fb Merge branch 'refactor/usb_host_usbh_hub_interaction' into 'master'
refactor(usb/host): Refactor USBH interaction with Hub

See merge request espressif/esp-idf!29783
2024-03-29 21:16:14 +08:00
Tomas Rezucha
e9daf4912b fix(usb/host): Do not allow unaligned cache access for M2C direction 2024-03-26 16:41:12 +01:00
Darian Leung
64f5d7d983
refactor(usb/host): Simplify USBH and Hub interaction
Previously, on a device disconnection, the USBH and Hub would the require the
following 2-way interaction:

- Hub -> usbh_hub_pass_event() -> USBH to indicate a port error
- USBH -> usbh_hub_req_cb_t -> Hub to request port recovery after the device
has been freed.

The 2-way interaction has been simplified:

- USBH now nofities upper layers of devices being freed via the
USBH_EVENT_DEV_FREE event
- Hub now handles port recovery only after a device has been freed
2024-03-22 18:14:50 +08:00
Roman Leonov
b90c7e585a refactor(usb_host): Renamed hub_driver_state to root_port_state 2024-03-21 13:16:28 +01:00
Darian Leung
6d40e191f8
refactor(hal/usb): Refactor usb_wrap_ll.h
This commit rewrite the 'usb_wrap_ll.h' API as follows:

- All APIs renamed from 'usb_fsls_phy_ll_...()' to 'usb_wrap_ll_...()'
- APIs now match their equivalent counter parts in 'usb_serial_jtag_ll.h'
2024-03-18 19:23:44 +08:00
Darian Leung
a77e5cc718
refactor(hal/usb): Remove usb_fsls_phy_ll.h
For targets that only contain a USJ peripheral (and not a DWC OTG), their
'usb_fsls_phy_ll.h' headers only contain a single function
('usb_fsls_phy_ll_int_jtag_enable()') whose feature is already covered by
functions in 'usb_serial_jtag_ll.h'. Thus, this header is redundant.

This commit does the following:

- Remove 'usb_fsls_phy_ll.h' for targets that only contain a USJ peripheral
- Rename 'usb_fsls_phy_[hal|ll].[h|c]' to `usb_wrap_[hal|ll].[h|c]` for targets
that contain a DWC OTG peripheral. This better reflects the underlying peripheral
that the LL header accesses.
2024-03-18 19:23:43 +08: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
fa2986fdef Merge branch 'feat/usb_host_sync_types' into 'master'
Add synchronization types from USB specs table 9-13

See merge request espressif/esp-idf!29263
2024-03-12 14:48:16 +08:00
Darian Leung
411e5481e7
refactor(usb): Remove USBH control transfer callback
This commit merges the USBH control transfer callback into the USBH event
callback. This simplifies the code as the USBH now uses a single callback.
2024-03-06 23:09:17 +08:00
Darian Leung
ec2f08ace6
refactor(usb): Update USBH event callback arguments
This commit does the following:

- Updates the USBH event callback arguments to now pass a usbh_event_data_t
which can contain different data for each event
- Updated event names
2024-03-06 23:09:16 +08:00
Tomas Rezucha
72f00d7c6d feat(usb/host): Update ISOC scheduler for HS endpoints
USB-OTG uses 'sched_info' field of HCTSIZ register to schedule transactions
in USB microframes.
2024-03-01 18:05:40 +01:00
Peter Marcisovsky
51d6296fde ci: Added esp32p4 usb tests to CI:
- added new test for usb_host_lib example for all targets
    - CI USB host test are run on esp32p4
    - CI USB device tests temporarily disabled until usb_device runner is fixed
    - hcd and usb_host tests which do not require PHY are run on esp32p4
2024-02-29 10:35:09 +01:00
Darian Leung
3887441b37
fix(usb): Fix bug where usbh_process() misses an event
This commit fixes a bug where if multiple concurrent USBH API calls trigger
multiple events on the same device, some events will be lost. As a result,
those lost events don't get processed by the subsequent usbh_process() call.
2024-02-27 18:22:48 +08:00
Tomas Rezucha
5863a27bd2 feat(usb/host): Add missing sync types from USB specification 2024-02-26 10:50:20 +01:00
Erhan Kurubas
f4acf0b378 refactor(espcoredump): format coredump component with astyle 2024-02-19 21:57:28 +01:00
Tomas Rezucha
f13ae0fc08 feat(esp32p4): Add USB-OTG support for ESP32-P4 2024-01-30 15:07:11 +01:00
Tomas Rezucha
ed1f20a972 feat(hal/usb): Add HS PHY configuration 2024-01-22 12:14:11 +01:00
Darian Leung
6a43b623dc refactor(soc): Rename usb_otg_periph to usb_dwc_periph
- Renamed usb_otg_periph.h/c to usb_dwc_periph.h/c to match naming convention
of other DWC OTG related files
- Added compatibility header for usb_otg_periph.h
2024-01-17 21:28:25 +08:00
Fu Hanxi
37a4c2ea01 Merge branch 'ci/nested_dynamic_pipeline' into 'master'
CI: Dynamic Pipeline!!!

Closes IDFCI-1211, IDFCI-1729, IDF-8500, IDF-8456, IDFCI-1828, RDT-610, and RDT-615

See merge request espressif/esp-idf!26662
2024-01-11 13:08:28 +08:00
Fu Hanxi
d44f236f7b
ci(usb): migrate from .gitlab/ci/rules.yml to .build-test-rules.yml 2024-01-10 15:29:44 +01:00
Tomas Rezucha
ec004c788b fix(usb/host): Sync cache for memory shared by CPU and USB-OTG
Transfer descriptor list, frame list and transfer data buffers
are accessed by both CPU and USB-OTG. Sync CPU cache between the accesses.
2024-01-10 15:23:24 +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
Darian Leung
2bb30e6493 refactor(usb): Deprecate CONFIG_USB_OTG_SUPPORTED, use SOC_USB_OTG_SUPPORTED instead
Previously, USB build dependencies used the CONFIG_USB_OTG_SUPPORTED. However,
they could depend on `soc_caps.h` instead.
2024-01-01 21:37:34 +08:00
Darian Leung
d74b4f6730 refactor(hal/usb): Rename usb_fsls_phy API to match header/source names
Note: Also fixed some formatting issues in usb_wrap_struct.h
2023-12-28 11:48:54 +08:00
Darian Leung
b26472af29 refactor(hal/usb): Rename usb_phy files to usb_fsls_phy
This commit renames USB PHY related HAL files from "usb_phy_xxx" to
"usb_fsls_phy_xxx" since they are only designed to support Full-Speed/Low-Speed
Serial USB PHYs. This renmaing is done to accommodate future USB PHYs that use
other PHY interfaces (e.g., UTMI, ULPI etc).
2023-12-28 11:48:34 +08:00
Darian Leung
d7b83bfd3b refactor(usb/host): reformat code with astyle_py 2023-12-15 04:44:02 +08:00
Tomas Rezucha
e32b7b060c fix(usb/host): Correctly parse bInterval field in HighSpeed EP descriptors
For LS and FS interrupt endpoint: interval = bInterval
For isochronous and HS interrupt endpoint: interval = 2^(bInterval-1)
2023-12-12 21:10:43 +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
39d57f1cfd refactor(usb/host): Move FIFO size configuration to HAL layer
The logic of calculating FIFO sizes is DWC OTG specific.
We move it to the HAL layer to provide better abstraction in the HDC layer.
2023-11-30 12:04:30 +08:00
Tomas Rezucha
b258bbf068 refactor(usb/host): Make private hal types USB_DWC specific 2023-11-30 10:24:53 +08:00
Tomas Rezucha
69d9e7625b feat(usb/host): Add High Speed enumeration types 2023-11-30 10:17:00 +08:00
Darian Leung
095b541125 change(usb/host): Remove some handler function event flags
This commit removes internal event flags in the USB Host Library event handling
functions (i.e., usb_host_lib_handle_events() and usb_host_client_handle_events()).

Previously, these flags were added to reduce the number of times semaphores
were given. However, these flags were removed as the performance gain is
negligible and made the logic more complicated.

For usb_host_client_handle_events(), the following flags were removed:

- Remove 'events_pending' flag. The semaphore is now always given
- Remove 'blocked' flag. The 'handling_events' flag is already sufficient
- Critical sections are now shortened due to simplication of semaphore usage.

For usb_host_lib_handle_events(), the following flags were removed:

- Remove 'process_pending' flag. The semaphore is now always given
- Renamed 'blocked' flag to 'handling_events'
2023-11-24 22:08:57 +08:00
Darian Leung
16c37f9db1 change(usb/host): Remove data buffer headers from URBs
This commit removes the ability to reserve a header in the data buffer of an
allocated URB. The header was required for a now defunct implementation of a
synchronous USB Host library API. Thus, headers are no longer required in
URB data buffers.
2023-11-24 20:57:03 +08:00
Tomas Rezucha
f48f433d5b fix(usb/host): Do not abort on string descriptor overflow
Some devices return full LANGID table, even if short LANGID table was requested.
No memory overflow occurs, because we have allocated enough memory for transfers to the
default pipe. So we can ignore the error and continue with string desc fetching.
2023-11-20 09:12:54 +01:00
Roman Leonov
bd51768340 fix(usb/host): remove bInterval verification during pipe opening for INTR and ISOC EPs 2023-11-16 14:11:01 +01:00
Darian
ce6519672f Merge branch 'feature/usb_dwc_otg_caps' into 'master'
change(usb): Add soc caps for DWC_OTG options

See merge request espressif/esp-idf!26961
2023-11-15 17:48:49 +08:00
Darian Leung
c0de14d0b9 refactor(hal/usb_dwc): Add DWC OTG configuration values
This commit adds a subset of the DWC OTG configuration values to the
'usb_dwc_ll.h' file. Only relevant configuration values have been added.

Some DWC OTG releated constants have also been moved from 'usb_dwc_hal.h'
to 'usb_dwc_ll.h' and renamed.
2023-11-14 20:49:51 +08:00
wuzhenghui
0ab0d2182e fix(esp_hw_support): fix lightsleep current leakage on usb-phy controlled pad 2023-11-11 13:00:55 +08:00
Song Ruo Jing
9461993ec5 refactor(gpio): make gpio driver as component, and fix astyle 2023-11-03 15:42:23 +08:00
Jakob Hasse
548022fbe6 refactor(linux): excluded all non-Linux components from build
* All components which won't build (yet) on Linux are excluded.
  This enables switching to Linux in an application without
  explicitly setting COMPONENTS to main in the main
  CMakeLists.txt.
* ESP Timer provides headers for Linux now
* automatically disabling LWIP in Kconfig if it is not available

doc(linux): brought section
  "Component Linux/Mock Support Overview" up to date
2023-10-16 17:06:54 +08:00
Chen Yudong
2e11919f70 fix(ci): change build-test-rules files folder 2023-09-20 19:17:06 +08:00
Darian Leung
287bdc5e61 fix(test_apps): Trim builds of component test apps
Some component test apps do not use the "set(COMPONENTS main)" command in their
project level "CMakeLists.txt", thus leading to their builds pulling in all
ESP-IDF components.

This commit trims the build of multiple component test apps:

- Add "set(COMPONENTS main ...)" to project level "CMakeLists.txt"
- Add missing "PRIV_REQUIRES" in some "main" component "CMakeLists.txt"

Also removed repeated configuraiton options in legacy_i2c_driver/sdkconfig.ci.defaults
as they are already specified in legacy_i2c_driver/sdkconfig.defaults
2023-09-18 17:16:37 +08:00
Roman Leonov
c29db70510 bugfix(usb/host): Fix transfer direction determination during argument checking for regular EP transfer 2023-09-13 21:55:34 +02:00
Roman Leonov
e297470e62 Merge branch 'bugfix/usb/host/urb_compliance_verification_add' into 'master'
feature(usb/host) added URB check args and transfer check compliance for regular EP transfer submit

See merge request espressif/esp-idf!24106
2023-08-03 16:20:49 +08:00
Darian Leung
a1ed398481 usb_host: Fix coverity issues with hcd_install()
- Use single "err_ret" variable for returning errors
- Simplify bail out procedure by using more labels
2023-06-21 17:50:20 +08:00
morris
8885d20482 usbh: fix invalid assert on desc_status 2023-06-19 10:59:46 +08:00
Roman Leonov
093bb5cab6 usb_host: added URB check args and transfer check compliance for regular EP transfer submit 2023-06-07 12:08:51 +02:00
Darian Leung
cbed197e10 usb_host: Run formatting script 2023-05-29 17:30:41 +08:00
Darian Leung
1ffbbf5aef usb_host: Fix spelling errors 2023-05-29 17:30:41 +08:00
Darian Leung
bab1c61a4c usb_host: Refactor USBH and USB Host Library calls to HCD
This commit refactors the USBH and the USB Host Library in the following ways:

- USBH now presents an abstraction of an endpoint (via usbh_ep_handle_t)
    - Added separate functions to enqueue/dequeue URBs to a particular endpoint
    - USB Host Library no longer calls HCD API directly. Calls USBH endpoint API
      instead.
- Renamed "notif_cb" to "proc_req_cb" (Processing Request Callback)
    - This is to avoid confusion with FreerTOS task notifications and Host
      Library client event notifications.
    - The processing functions of each layer (i.e., "xxx_process()") request
      calls via the "proc_req_cb"
    - The main handling function (i.e., usb_host_lib_handle_events()) is
      responsible for calling the required "xxx_process()" of each layer
2023-05-29 17:30:41 +08:00
Roman Leonov
1be6977a9d usb_host: better debugging information during hcd_pipe_alloc() when usb_host_interface_claim() is being fulfiled. 2023-04-24 08:37:57 +02:00
Tomas Rezucha
f2f6278ba6 usb_host: Use up-to-date syntax in pytest 2023-04-19 11:06:25 +02:00
Darian Leung
525de5bd21 usb_host: Update docs and comments regarding first configuration enumeration
This commit updates some comments and documentation regarding changes made in
PR https://github.com/espressif/esp-idf/pull/11113.
2023-04-17 17:06:54 +08:00
Jason
9d1c8f4f18 Fix usb enumeration stage error for some device 2023-04-03 21:03:07 +08:00
Roman Leonov
be899f6653 usb_host: add recovering interval after SetAddress(). Possibility to change constant delay value via menuconfig.
Closes https://github.com/espressif/esp-idf/issues/10444
Closes https://github.com/espressif/esp-idf/issues/10718
2023-03-09 08:11:05 +01:00
Tomas Rezucha
31ff3bc0c2 usb_host: Fix interface descriptor parsing
Previously the USB host driver did not accept interface number greater or equal bNumInterfaces, even though these are valid interface numbers
2023-02-10 15:49:11 +01:00
Saurabh Kumar Bansal
7010349a9a usb_host: Hub driver skips fetching string descriptors if their index is 0
When a USB does not support a particular string dsecriptor (e.g.,
manufacturer, product, and serial number), the string descriptors corresponding
index will be set to 0 in the device descriptor (e.g., iManufacturer, iProduct,
iString).

Previously, the Hub driver would always attempt to fetch the all three string
descriptors, thus leading an error in CHECK_SHORT_SER_STR_DESC if the device
did not support the descriptor.

This commit fixes the Hub drvier by skipping the enumeration stages of a
particular descriptor if its index is 0 (i.e., not supported by the device).
2023-02-08 23:12:54 +05:30
Darian Leung
6ae151db8c usb_host: Fix error when fetching LANGID table
USB devices may support string descriptors in multiple languages. The supported
languages are stored in a LANGID table, which itself is a string descriptor at
index 0.

When fetching the LANGID table itself, the USB 2.0 specification does not
specify what LANGID to use, thus the Hub driver would use the default LANGID
"ENUM_LANGID". However, this would cause some devices to stall.

This commit fixes the issue by always requesting the LANGID table itself using
a LANGID of 0.
2023-02-08 22:36:01 +08:00
Darian Leung
c2bc34ee84 usb: Fix incorrect bmRequestType direction flag in USB Host Library
usb_host_transfer_submit_control() uses the incorrect bmRequestType direction
flag. Therefore, when doing a transfer check, all transfers were mistakenly
treated as OUT transfers (only affects transfer check and not actual transfer).
2022-12-06 18:10:45 +08:00
Tomas Rezucha
7ae5705977 Merge branch 'feature/usb_v5_update' into 'master'
usb: Run usb_host tests in CI

See merge request espressif/esp-idf!19468
2022-12-01 15:29:01 +08:00
Tomas Rezucha
a0dacf826f usb: Don't access uninit pointer if usbh_install fails 2022-11-30 18:48:31 +00:00
Tomas Rezucha
645592e157 usb: Refactor USB Host tests
* USB tests migrated to pytest
* Error messages improved
* Configurable for different mock devices
2022-11-30 18:12:54 +01: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
Darian Leung
4e84212077 usb_host: Test host library inflight transfer resubmission check
This commit updates the USB Host Library unit tests to test that resubmitting
an inflight transfer will return an error.
2022-10-31 13:56:59 +08:00
Darian Leung
e17e066828 usb_host: Add check to prevent submitting already inflight transfers
This commit adds a simple flag/check in the USB Host Library that prevents
users from submitting a transfer that is already inflight.

- A transfer is considered inflight as soon as it is submitted by calling
usb_host_transfer_submit() or usb_host_transfer_submit_control()
- An inflight transfer remains inflight up until right before its callback
is called by one of the USB Host Library handler functions.

Closes https://github.com/espressif/esp-idf/issues/8748
2022-10-31 13:56:59 +08:00
Tomas Rezucha
27078ac34c usb_host: Fixed incorrect opening devices from multiple clients
1. During USBH device open both queues (idle and pending) must be checked.
2. Don't overwrite already allocated endpoints
2022-10-31 13:56:44 +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
Darian Leung
d333833f59 usb_host: Rename struct/ll/hal symbols to use "usb_dwc" prefix
Following the file renaming to use the "usb_dwc" prefix, this commit
updates the symbol names of those files to use the "usb_dwc" as well.

Some LL functions were also renamed so that the register name is
mentioned.
2022-09-16 16:45:26 +08:00
Darian Leung
d8d4e3acb0 usb_host: Rename struct/ll/hal files to use "usb_dwc" prefix
This commit updates the DWC_OTG based struct/ll/hal file names to
use the prefix "usb_dwc". This naming scheme reduces ambiguity if
another USB controller implementation is added.

As a result, "hcd.c" has been renamed to "hcd_dwc.c"
2022-09-16 16:45:26 +08:00
Darian Leung
89f828ee02 usb_host: Fix incorrect memset() usage in HCD
This commit fixes incorrect usage of memset() in the HCD's various
_buffer_parse_...() functions. The memset was not clearing the qtd lists, and
were simply setting the first qtd to a non zero value (i.e., the length of
the QTD list).

However, no bug occurred as the subsequent _buffer_fill_...() functions would
overwrite the QTD list anyways.
2022-09-05 20:15:03 +02:00
Tomas Rezucha
dfdb814644 usb: Remove -Wno-format compile option 2022-09-05 20:14:56 +02:00
Ivan Grokhotkov
401c10ecfb build system: re-add -Wno-format as private flag for some components 2022-08-03 16:42:47 +04:00
Nicholas Palmer
0f645e59b6 usbh_print_intf_desc prints wrong value for tbInterfaceClass (IDFGH-9000) 2022-05-21 15:54:21 -07: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
Ivan Grokhotkov
708e99497b
global: add dependency on esp_timer component and include esp_timer.h
Some components were including esp_timer.h without declaring a
dependency on esp_timer component. This used to work due to a
transitive public dependency on esp_timer from freertos component.
Add explicit dependencies where needed.
Also some source files were using esp_timer functions without
including the header file. This used to work because esp_timer.h was
included from freertos port header file. This commit adds esp_timer.h
includes where needed.
2022-04-25 18:39:23 +02:00
morris
29e9b5b46a hw_support: move periph_ctrl from driver to hw_support 2022-03-29 11:53:31 +08:00
Tomas Rezucha
e3ba980d11 usb_host: Use USB_Host library calls for desc printing 2022-03-21 18:34:25 +01:00
Omar Chebib
2571aaf3c9 G0: target component (components/esp32*) doesn't depend on driver anymore 2022-03-02 04:21:00 +00:00
Ivan Grokhotkov
9a7d9b59c1 usb: mark global variable declared in header 'extern' 2022-01-27 11:00:09 +07:00
Martin Valik
022fc12ed1 Bugfix: make wTotalLength uint16_t to avoid truncation 2022-01-17 13:43:37 +01: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
22c152c388 usb: Hub Driver and USBH recover port automatically after disconnection
This commit updates the Hub Driver and USBH as follows:
- Updated communication mechanism between Hub Driver and USBH
    - USBH notifies the Hub Driver via Hub request callback (usbh_hub_req_cb_t)
    - Hub Driver notifies the USBH via usbh_hub_pass_event()
- Hub Driver now defers all event handling to hub_process.
- Hub Driver and USBH will now automatically recover the port after a disconnected
    device has been closed.
- Fixed incorrect assert in usbh_dev_close()
2022-01-06 15:12:16 +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
Darian Leung
bb29b199ad usb: Tidy up usbh
- Remove enum_todo_flags from usbh
- USBH move config_desc to constant fields
2022-01-06 15:06:44 +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
Roland Dobai
766aa57084 Build & config: Remove leftover files from the unsupported "make" build system 2021-11-11 15:32:36 +01:00
morris
16677b0d3c global: make periph enable/disable APIs private
peripheral enable/disable usually should be managed by driver itself,
so make it as espressif private APIs, not recommended for user to use it
in application code.
However, if user want to re-write the driver or ports to other platform,
this is still possible by including the header in this way:
"esp_private/peripheral_ctrl.h"
2021-11-08 10:37:47 +08: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
54b6c902d3 usb: Add USB Host Library sudden disconnect tests 2021-11-02 14:30:58 +08:00
Darian Leung
6a12e28333 usb: Fix USBH handling of disconnections
This commit fixes how the USBH handling of a sudden device disconnection,
more specifically handling of device gone.
- Previously the USBH would only halt, flush, and dequeue the device's
default EP, then send a device gone event to the Host Library layer.
- Now the USBH will also halt and flush all non-default EPs, allowing
all of the URBs to be dequeud.
- Some internal object members are now protected by a mutex instead of
a spinlock.

Closes https://github.com/espressif/esp-idf/issues/7505
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