[usb_uart] Implement USB Host mode UART (#8334)
This commit is contained in:
1 parent
d1e55252d0
commit
1ec57a74b5
13 files changed
+1464
No files matched your search
@@ -0,0 +1,35 @@
|
||||
// Should not be needed, but it's required to pass CI clang-tidy checks
|
||||
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3)
|
||||
#include "usb_host.h"
|
||||
#include <cinttypes>
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace usb_host {
|
||||
|
||||
void USBHost::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setup starts");
|
||||
usb_host_config_t config{};
|
||||
|
||||
if (usb_host_install(&config) != ESP_OK) {
|
||||
this->status_set_error("usb_host_install failed");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
}
|
||||
void USBHost::loop() {
|
||||
int err;
|
||||
uint32_t event_flags;
|
||||
err = usb_host_lib_handle_events(0, &event_flags);
|
||||
if (err != ESP_OK && err != ESP_ERR_TIMEOUT) {
|
||||
ESP_LOGD(TAG, "lib_handle_events failed failed: %s", esp_err_to_name(err));
|
||||
}
|
||||
if (event_flags != 0) {
|
||||
ESP_LOGD(TAG, "Event flags %" PRIu32 "X", event_flags);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace usb_host
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3
|
||||
Reference in new issue
Block a user