1#if defined(USE_ESP32_VARIANT_ESP32P4) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || \
2 defined(USE_ESP32_VARIANT_ESP32S31) || defined(USE_ESP32_VARIANT_ESP32H4)
6#include "tinyusb_default_config.h"
10static const char *
const TAG =
"tinyusb";
14static void tinyusb_event_cb(tinyusb_event_t *event,
void *arg) {
15 if (event->id == TINYUSB_EVENT_ATTACHED || event->id == TINYUSB_EVENT_DETACHED) {
16 static_cast<TinyUSB *
>(arg)->enable_loop_soon_any_context();
23 static char mac_addr_buf[MAC_ADDRESS_BUFFER_SIZE];
29 this->
tusb_cfg_ = TINYUSB_DEFAULT_CONFIG();
30 this->
tusb_cfg_.port = TINYUSB_PORT_FULL_SPEED_0;
51#if !(CFG_TUD_CDC > 0 || CFG_TUD_MSC > 0 || CFG_TUD_NCM > 0)
52 if (this->
tusb_cfg_.descriptor.full_speed_config ==
nullptr) {
53 ESP_LOGE(TAG,
"No USB class configured");
59 this->
tusb_cfg_.event_cb = tinyusb_event_cb;
61 esp_err_t result = tinyusb_driver_install(&this->
tusb_cfg_);
62 if (result != ESP_OK) {
63 ESP_LOGE(TAG,
"tinyusb_driver_install failed: %s", esp_err_to_name(result));
72 const bool mounted = tud_mounted();
75 ESP_LOGD(TAG,
"USB host %s", mounted ? LOG_STR_LITERAL(
"mounted") : LOG_STR_LITERAL(
"unmounted"));
84 " Product ID: 0x%04X\n"
85 " Vendor ID: 0x%04X\n"
86 " Manufacturer: '%s'\n"
void mark_failed()
Mark this component as failed.
void disable_loop()
Disable this component's loop.
tinyusb_config_t tusb_cfg_
const char * string_descriptor_[SIZE]
tusb_desc_device_t usb_descriptor_
LazyCallbackManager< void(bool)> mount_state_callback_
void dump_config() override
bool last_reported_mounted_
void get_mac_address_into_buffer(std::span< char, MAC_ADDRESS_BUFFER_SIZE > buf)
Get the device MAC address into the given buffer, in lowercase hex notation.