diff --git a/esphome/components/usb_host/usb_host.h b/esphome/components/usb_host/usb_host.h index a6a97d0bd71..ca644de8bea 100644 --- a/esphome/components/usb_host/usb_host.h +++ b/esphome/components/usb_host/usb_host.h @@ -175,6 +175,7 @@ class USBClient : public Component { // Lock-free pool management using atomic bitmask (no dynamic allocation) // Bit i = 1: requests_[i] is in use, Bit i = 0: requests_[i] is available // Supports multiple concurrent consumers and producers (both threads can allocate/deallocate) + // 2-byte members packed together; trq_in_use_ is uint16_t when MAX_REQUESTS <= 16 std::atomic trq_in_use_; uint16_t vid_{}; uint16_t pid_{}; diff --git a/esphome/components/usb_host/usb_host_client.cpp b/esphome/components/usb_host/usb_host_client.cpp index a9be38fb03f..5a1e3b9cb81 100644 --- a/esphome/components/usb_host/usb_host_client.cpp +++ b/esphome/components/usb_host/usb_host_client.cpp @@ -233,7 +233,11 @@ void USBClient::setup() { if (this->usb_task_handle_ == nullptr) { ESP_LOGE(TAG, "Failed to create USB task"); this->mark_failed(); + return; } + + // Start with loop disabled - it will be enabled by client_event_cb when events arrive + this->disable_loop(); } void USBClient::usb_task_fn(void *arg) {