ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
usb_host_component.cpp
Go to the documentation of this file.
1// Should not be needed, but it's required to pass CI clang-tidy checks
2#if defined(USE_ESP32_VARIANT_ESP32P4) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || \
3 defined(USE_ESP32_VARIANT_ESP32S31) || defined(USE_ESP32_VARIANT_ESP32H4)
4#include "usb_host.h"
5#include <cinttypes>
6#include "esphome/core/log.h"
7
8namespace esphome::usb_host {
9
11 usb_host_config_t config{};
12#ifdef USE_USB_HOST_FIFO_CONFIG
13 // Sized in Python from component requests
14 config.fifo_settings_custom.rx_fifo_lines = USB_HOST_FIFO_RX_LINES;
15 config.fifo_settings_custom.nptx_fifo_lines = USB_HOST_FIFO_NPTX_LINES;
16 config.fifo_settings_custom.ptx_fifo_lines = USB_HOST_FIFO_PTX_LINES;
17#endif
18
19 if (usb_host_install(&config) != ESP_OK) {
20 this->status_set_error(LOG_STR("usb_host_install failed"));
21 this->mark_failed();
22 return;
23 }
24}
26 int err;
27 uint32_t event_flags;
28 err = usb_host_lib_handle_events(0, &event_flags);
29 if (err != ESP_OK && err != ESP_ERR_TIMEOUT) {
30 ESP_LOGD(TAG, "lib_handle_events failed failed: %s", esp_err_to_name(err));
31 }
32 if (event_flags != 0) {
33 ESP_LOGD(TAG, "Event flags %" PRIu32 "X", event_flags);
34 }
35}
36
37} // namespace esphome::usb_host
38
39#endif // USE_ESP32_VARIANT_ESP32P4 || USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 ||
40 // USE_ESP32_VARIANT_ESP32S31 || USE_ESP32_VARIANT_ESP32H4
void mark_failed()
Mark this component as failed.
static void uint32_t