Chapter 2. API Reference
API Reference
The API of the USB Host Library is separated into the following header files. However, it is sufficient for applications
to only #include "usb/usb_host.h" and all of USB Host Library headers will also be included.
•
usb/include/usb/usb_host.h
•
usb/include/usb/usb_helpers.h
descriptor parsing.
•
usb/include/usb/usb_types_stack.h
stack.
•
usb/include/usb/usb_types_ch9.h
(i.e., descriptors and standard requests).
Header File
•
components/usb/include/usb/usb_host.h
Functions
esp_err_t
usb_host_install(const
Install the USB Host Library.
• This function should only once to install the USB Host Library
• This function should be called before any other USB Host Library functions are called
Return esp_err_t
Parameters
• [in] config: USB Host Library configuration
esp_err_t
usb_host_uninstall(void)
Uninstall the USB Host Library.
• This function should be called to uninstall the USB Host Library, thereby freeing its resources
• All clients must have been deregistered before calling this function
• All devices must have been freed by calling usb_host_device_free_all() and receiving the
USB_HOST_LIB_EVENT_FLAGS_ALL_FREE event flag
Return esp_err_t
esp_err_t
usb_host_lib_handle_events(TickType_t timeout_ticks, uint32_t *event_flags_ret)
Handle USB Host Library events.
• This function handles all of the USB Host Library' s processing and should be called repeatedly in a loop
• Check event_flags_ret to see if an flags are set indicating particular USB Host Library events
Note This function can block
Return esp_err_t
Parameters
• [in] timeout_ticks: Timeout in ticks to wait for an event to occur
• [out] event_flags_ret: Event flags that indicate what USB Host Library event occurred
esp_err_t
usb_host_lib_unblock(void)
Unblock the USB Host Library handler.
• This
function
(usb_host_lib_handle_events())
Return esp_err_t
esp_err_t
usb_host_client_register(const
Register a client of the USB Host Library.
• This function registers a client of the USB Host Library
• Once a client is registered, its processing function usb_host_client_handle_events() should be called re-
peatedly
Espressif Systems
contains the functions and types of the USB Host Library
contains various helper functions that are related to the USB protocol such as
contains types that are are used across multiple layers of the USB Host
contains types and macros related to Chapter 9 of the USB2.0 specification
usb_host_config_t
simply
unblocks
the
usb_host_client_handle_t
488
Submit Document Feedback
*config)
USB
Host
Library
usb_host_client_config_t
*client_hdl_ret)
event
handling
function
*client_config,
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?