ESPHome
2025.6.0
Loading...
Searching...
No Matches
esphome
components
usb_host
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_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
3
#include "
usb_host.h
"
4
#include <cinttypes>
5
#include "
esphome/core/log.h
"
6
7
namespace
esphome
{
8
namespace
usb_host {
9
10
void
USBHost::setup
() {
11
ESP_LOGCONFIG(TAG,
"Setup starts"
);
12
usb_host_config_t config{};
13
14
if
(usb_host_install(&config) != ESP_OK) {
15
this->
status_set_error
(
"usb_host_install failed"
);
16
this->
mark_failed
();
17
return
;
18
}
19
}
20
void
USBHost::loop
() {
21
int
err;
22
uint32_t event_flags;
23
err = usb_host_lib_handle_events(0, &event_flags);
24
if
(err != ESP_OK && err != ESP_ERR_TIMEOUT) {
25
ESP_LOGD(TAG,
"lib_handle_events failed failed: %s"
, esp_err_to_name(err));
26
}
27
if
(event_flags != 0) {
28
ESP_LOGD(TAG,
"Event flags %"
PRIu32
"X"
, event_flags);
29
}
30
}
31
32
}
// namespace usb_host
33
}
// namespace esphome
34
35
#endif
// USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
esphome::Component::mark_failed
virtual void mark_failed()
Mark this component as failed.
Definition
component.cpp:137
esphome::Component::status_set_error
void status_set_error(const char *message="unspecified")
Definition
component.cpp:190
esphome::usb_host::USBHost::setup
void setup() override
Definition
usb_host_component.cpp:10
esphome::usb_host::USBHost::loop
void loop() override
Definition
usb_host_component.cpp:20
log.h
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
usb_host.h
Generated by
1.12.0