Chapter 2. API Reference
Macros
USB_TRANSFER_FLAG_ZERO_PACK
(For bulk OUT only). Indicates that a bulk OUT transfers should always terminate with a short packet, even if
it means adding an extra zero length packet
Type Definitions
typedef struct usb_device_handle_s *usb_device_handle_t
Handle of a USB Device connected to a USB Host.
typedef struct
usb_transfer_s
USB transfer structure.
This structure is used to represent a transfer from a software client to an endpoint over the USB bus. Some
of the fields are made const on purpose as they are fixed on allocation. Users should call the appropriate USB
Host Library function to allocate a USB transfer structure instead of allocating this structure themselves.
The transfer type is inferred from the endpoint this transfer is sent to. Depending on the transfer type, users
should note the following:
• Bulk: This structure represents a single bulk transfer. If the number of bytes exceeds the endpoint's
MPS, the transfer will be split into multiple MPS sized packets followed by a short packet.
• Control: This structure represents a single control transfer. This first 8 bytes of the data_buffer must be
filled with the setup packet (see usb_setup_packet_t). The num_bytes field should be the total size of the
transfer (i.e., size of setup packet + wLength).
• Interrupt: Represents an interrupt transfer. If num_bytes exceeds the MPS of the endpoint, the transfer
will be split into multiple packets, and each packet is transferred at the endpoint's specified interval.
• Isochronous: Represents a stream of bytes that should be transferred to an endpoint at a fixed rate. The
transfer is split into packets according to the each isoc_packet_desc. A packet is transferred at each
interval of the endpoint. If an entire ISOC URB was transferred without error (skipped packets do not
count as errors), the URB's overall status and the status of each packet descriptor will be updated, and
the actual_num_bytes reflects the total bytes transferred over all packets. If the ISOC URB encounters
an error, the entire URB is considered erroneous so only the overall status will updated.
Note For Bulk/Control/Interrupt IN transfers, the num_bytes must be a integer multiple of the endpoint's
MPS
Note This structure should be allocated via usb_host_transfer_alloc()
Note Once the transfer has be submitted, users should not modify the structure until the transfer has completed
typedef void
(*usb_transfer_cb_t)(usb_transfer_t
USB transfer completion callback.
Enumerations
enum usb_speed_t
USB Standard Speeds.
Values:
USB_SPEED_LOW = 0
USB Low Speed (1.5 Mbit/s)
USB_SPEED_FULL
USB Full Speed (12 Mbit/s)
enum usb_transfer_type_t
The type of USB transfer.
Note The enum values need to match the bmAttributes field of an EP descriptor
Values:
USB_TRANSFER_TYPE_CTRL = 0
USB_TRANSFER_TYPE_ISOCHRONOUS
USB_TRANSFER_TYPE_BULK
Espressif Systems
usb_transfer_t
*transfer)
498
Submit Document Feedback
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?