1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-03 18:42:23 +01:00

[usb_host][usb_uart] Allow on ESP32-P4 (#10815)

This commit is contained in:
Oliver Kleinecke
2025-09-28 09:15:18 +02:00
committed by GitHub
parent 9dd6be4061
commit 3f03e8c423
9 changed files with 12 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
import esphome.codegen as cg import esphome.codegen as cg
from esphome.components.esp32 import ( from esphome.components.esp32 import (
VARIANT_ESP32P4,
VARIANT_ESP32S2, VARIANT_ESP32S2,
VARIANT_ESP32S3, VARIANT_ESP32S3,
add_idf_sdkconfig_option, add_idf_sdkconfig_option,
@@ -47,7 +48,7 @@ CONFIG_SCHEMA = cv.All(
} }
), ),
cv.only_with_esp_idf, cv.only_with_esp_idf,
only_on_variant(supported=[VARIANT_ESP32S2, VARIANT_ESP32S3]), only_on_variant(supported=[VARIANT_ESP32S2, VARIANT_ESP32S3, VARIANT_ESP32P4]),
) )

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
// Should not be needed, but it's required to pass CI clang-tidy checks // 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) #if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32P4)
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include <vector> #include <vector>
#include "usb/usb_host.h" #include "usb/usb_host.h"

View File

@@ -1,5 +1,5 @@
// Should not be needed, but it's required to pass CI clang-tidy checks // 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) #if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32P4)
#include "usb_host.h" #include "usb_host.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/core/hal.h" #include "esphome/core/hal.h"

View File

@@ -1,5 +1,5 @@
// Should not be needed, but it's required to pass CI clang-tidy checks // 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) #if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32P4)
#include "usb_host.h" #include "usb_host.h"
#include <cinttypes> #include <cinttypes>
#include "esphome/core/log.h" #include "esphome/core/log.h"

View File

@@ -24,7 +24,6 @@ usb_uart_ns = cg.esphome_ns.namespace("usb_uart")
USBUartComponent = usb_uart_ns.class_("USBUartComponent", Component) USBUartComponent = usb_uart_ns.class_("USBUartComponent", Component)
USBUartChannel = usb_uart_ns.class_("USBUartChannel", UARTComponent) USBUartChannel = usb_uart_ns.class_("USBUartChannel", UARTComponent)
UARTParityOptions = usb_uart_ns.enum("UARTParityOptions") UARTParityOptions = usb_uart_ns.enum("UARTParityOptions")
UART_PARITY_OPTIONS = { UART_PARITY_OPTIONS = {
"NONE": UARTParityOptions.UART_CONFIG_PARITY_NONE, "NONE": UARTParityOptions.UART_CONFIG_PARITY_NONE,

View File

@@ -1,4 +1,4 @@
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) #if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32P4)
#include "usb_uart.h" #include "usb_uart.h"
#include "usb/usb_host.h" #include "usb/usb_host.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"

View File

@@ -1,4 +1,4 @@
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) #if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32P4)
#include "usb_uart.h" #include "usb_uart.h"
#include "usb/usb_host.h" #include "usb/usb_host.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"

View File

@@ -1,5 +1,5 @@
// Should not be needed, but it's required to pass CI clang-tidy checks // 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) #if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32P4)
#include "usb_uart.h" #include "usb_uart.h"
#include "esphome/core/log.h" #include "esphome/core/log.h"
#include "esphome/components/uart/uart_debugger.h" #include "esphome/components/uart/uart_debugger.h"
@@ -297,7 +297,8 @@ static void fix_mps(const usb_ep_desc_t *ep) {
if (ep != nullptr) { if (ep != nullptr) {
auto *ep_mutable = const_cast<usb_ep_desc_t *>(ep); auto *ep_mutable = const_cast<usb_ep_desc_t *>(ep);
if (ep->wMaxPacketSize > 64) { if (ep->wMaxPacketSize > 64) {
ESP_LOGW(TAG, "Corrected MPS of EP %u from %u to 64", ep->bEndpointAddress, ep->wMaxPacketSize); ESP_LOGW(TAG, "Corrected MPS of EP 0x%02X from %u to 64", static_cast<uint8_t>(ep->bEndpointAddress & 0xFF),
ep->wMaxPacketSize);
ep_mutable->wMaxPacketSize = 64; ep_mutable->wMaxPacketSize = 64;
} }
} }
@@ -314,7 +315,7 @@ void USBUartTypeCdcAcm::on_connected() {
for (auto *channel : this->channels_) { for (auto *channel : this->channels_) {
if (i == cdc_devs.size()) { if (i == cdc_devs.size()) {
ESP_LOGE(TAG, "No configuration found for channel %d", channel->index_); ESP_LOGE(TAG, "No configuration found for channel %d", channel->index_);
this->status_set_warning(LOG_STR("No configuration found for channel")); this->status_set_warning("No configuration found for channel");
break; break;
} }
channel->cdc_dev_ = cdc_devs[i++]; channel->cdc_dev_ = cdc_devs[i++];

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) #if defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32P4)
#include "esphome/core/component.h" #include "esphome/core/component.h"
#include "esphome/core/helpers.h" #include "esphome/core/helpers.h"
#include "esphome/components/uart/uart_component.h" #include "esphome/components/uart/uart_component.h"