mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(usb/hal): Add support for explicit FIFO configuration
Introduce a new HAL API `usb_dwc_hal_set_fifo_config()` that allows advanced users to manually configure RX, Non-Periodic TX, and Periodic TX FIFO sizes. This offers fine-grained control beyond the previous bias-based sizing approach. The HAL function no longer returns `esp_err_t`, and internal validations are enforced via `HAL_ASSERT()`. Responsibility for input validation has been moved to the HCD layer. FIFO configuration must be applied before any USB pipes are created or activated. This feature is intended for use during `usb_host_install()`. If no custom FIFO configuration is provided (i.e., all values are zero), the driver falls back to a bias-based default layout based on Kconfig settings (`CONFIG_USB_HOST_HW_BUFFER_BIAS_*`). Bias resolution is done inside `hcd_port_init()`. The `port_obj_t` structure has been extended with a `fifo_config` field, which stores the configuration to allow re-application after a USB port reset. Obsolete FIFO bias enums (`usb_hal_fifo_bias_t`, `hcd_port_fifo_bias_t`) and related APIs (`hcd_port_set_fifo_bias()`) have been removed in favor of the new structure-based mechanism. The HCD initialization and port reset flow has been updated to use the explicit FIFO configuration. USB Host maintainer documentation (`maintainers.md`) has been updated accordingly. Test cases were updated to remove the usage of removed bias API and now rely on default or custom FIFO configuration.
This commit is contained in:
@@ -487,9 +487,26 @@ esp_err_t usb_host_install(const usb_host_config_t *config)
|
||||
}
|
||||
|
||||
// Install HCD
|
||||
// Prepare HCD configuration
|
||||
hcd_fifo_settings_t user_fifo_config;
|
||||
hcd_config_t hcd_config = {
|
||||
.intr_flags = config->intr_flags
|
||||
.intr_flags = config->intr_flags,
|
||||
.fifo_config = NULL, // Default: use bias strategy from Kconfig
|
||||
};
|
||||
|
||||
// Check if user has provided a custom FIFO configuration
|
||||
if (config->fifo_settings_custom.rx_fifo_lines != 0 ||
|
||||
config->fifo_settings_custom.nptx_fifo_lines != 0 ||
|
||||
config->fifo_settings_custom.ptx_fifo_lines != 0) {
|
||||
|
||||
// Populate user FIFO configuration with provided values
|
||||
user_fifo_config.rx_fifo_lines = config->fifo_settings_custom.rx_fifo_lines;
|
||||
user_fifo_config.nptx_fifo_lines = config->fifo_settings_custom.nptx_fifo_lines;
|
||||
user_fifo_config.ptx_fifo_lines = config->fifo_settings_custom.ptx_fifo_lines;
|
||||
|
||||
// Pass custom configuration to HCD
|
||||
hcd_config.fifo_config = &user_fifo_config;
|
||||
}
|
||||
ret = hcd_install(&hcd_config);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(USB_HOST_TAG, "HCD install error: %s", esp_err_to_name(ret));
|
||||
|
||||
Reference in New Issue
Block a user