Merge branch 'dev' into esp32-log-v2-idf61

This commit is contained in:
J. Nick Koston
2026-07-01 21:42:02 -05:00
committed by GitHub
5 changed files with 61 additions and 6 deletions
@@ -21,7 +21,11 @@ void PowerSupply::dump_config() {
LOG_PIN(" Pin: ", this->pin_);
}
float PowerSupply::get_setup_priority() const { return setup_priority::IO; }
float PowerSupply::get_setup_priority() const {
if (this->pin_->is_internal() && this->enable_on_boot_)
return setup_priority::POWER;
return setup_priority::IO;
}
bool PowerSupply::is_enabled() const { return this->active_requests_ != 0; }
+4 -3
View File
@@ -6,6 +6,7 @@
#include "esphome/components/uart/uart_debugger.h"
#include "esphome/components/bytebuffer/bytebuffer.h"
#include <cinttypes>
namespace esphome::usb_uart {
@@ -288,16 +289,16 @@ int USBUartTypeFT23XX::set_baudrate_(USBUartChannel *channel, uint32_t baudrate)
ESP_LOGE(TAG, "Set baudrate failed, status=%s", esp_err_to_name(status.error_code));
channel->initialised_.store(false);
} else {
ESP_LOGD(TAG, "Baudrate %d set, setting line properties...", channel->baud_rate_);
ESP_LOGD(TAG, "Baudrate %" PRIu32 " set, setting line properties...", channel->baud_rate_);
this->set_line_properties_(channel);
}
};
if (baudrate == 0) {
baudrate = channel->baud_rate_;
}
uint16_t value, ftdi_index;
uint16_t value = 0, ftdi_index = 0;
ftdi_convert_baudrate(baudrate, this->chip_type_, channel->index_, &value, &ftdi_index);
ESP_LOGD(TAG, "Baudrate: %d, value=0x%04X, ftdi_index=0x%04X", baudrate, value, ftdi_index);
ESP_LOGD(TAG, "Baudrate: %" PRIu32 ", value=0x%04X, ftdi_index=0x%04X", baudrate, value, ftdi_index);
uint16_t usb_index = (ftdi_index & 0xFF00) | (channel->cdc_dev_.bulk_interface_number + 1);
bool ok = this->control_transfer(USB_VENDOR_DEV | usb_host::USB_DIR_OUT, 0x03, value, usb_index, callback);
if (!ok) {
+3 -2
View File
@@ -3,6 +3,7 @@
#include "usb_uart.h"
#include "usb/usb_host.h"
#include "esphome/core/log.h"
#include <cinttypes>
namespace esphome::usb_uart {
@@ -282,8 +283,8 @@ void USBUartTypePL2303::enable_channels() {
// Data bits
line_coding[6] = channel->get_data_bits();
ESP_LOGD(TAG, "PL2303: SET_LINE_REQUEST baud=%u stop=%u parity=%u data=%u", baud, line_coding[4], line_coding[5],
line_coding[6]);
ESP_LOGD(TAG, "PL2303: SET_LINE_REQUEST baud=%" PRIu32 " stop=%u parity=%u data=%u", baud, line_coding[4],
line_coding[5], line_coding[6]);
std::vector<uint8_t> lc_vec(line_coding, line_coding + 7);
uint16_t iface = channel->cdc_dev_.bulk_interface_number;
+2
View File
@@ -33,6 +33,8 @@ class RuntimeStatsCollector;
*/
namespace setup_priority {
/// For power supply components that must be on before buses like i2c can work.
inline constexpr float POWER = 1200.0f;
/// For communication buses like i2c/spi
inline constexpr float BUS = 1000.0f;
/// For components that represent GPIO pins like PCF8573
@@ -0,0 +1,47 @@
#include <gtest/gtest.h>
#include "esphome/components/power_supply/power_supply.h"
#include "esphome/core/gpio.h"
#include "esphome/core/component.h"
namespace esphome::power_supply::testing {
// Minimal dummy internal GPIO pin implementation for testing
class DummyInternalPin : public InternalGPIOPin {
public:
DummyInternalPin() = default;
void setup() override {}
void pin_mode(esphome::gpio::Flags) override {}
esphome::gpio::Flags get_flags() const override { return esphome::gpio::FLAG_NONE; }
bool digital_read() override { return false; }
void digital_write(bool) override {}
void detach_interrupt() const override {}
ISRInternalGPIOPin to_isr() const override { return ISRInternalGPIOPin(); }
uint8_t get_pin() const override { return 0; }
bool is_inverted() const override { return false; }
protected:
// Implement protected attach_interrupt required by InternalGPIOPin
void attach_interrupt(void (*func)(void *), void *arg, esphome::gpio::InterruptType type) const override {}
};
TEST(PowerSupply, HasHigherPriorityThanBusWhenInternalAndEnableOnBoot) {
power_supply::PowerSupply ps;
DummyInternalPin pin;
ps.set_pin(&pin);
ps.set_enable_on_boot(true);
// POWER priority should be greater than BUS priority
EXPECT_GT(ps.get_setup_priority(), setup_priority::BUS);
}
TEST(PowerSupply, FallsBackToIOWhenNotEnableOnBoot) {
power_supply::PowerSupply ps;
DummyInternalPin pin;
ps.set_pin(&pin);
ps.set_enable_on_boot(false);
EXPECT_EQ(ps.get_setup_priority(), setup_priority::IO);
}
} // namespace esphome::power_supply::testing