ESPHome 2026.11's tuya component calls uart.new_uart_component(), which the 2026.10.2 copy didn't have, so the build failed. Copy the UART component from 2026.11.0, reapply the PA13/PA14 patch, regenerate the patch file and point the refs at v1.0.6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.6 KiB
C++
40 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include "esphome/core/helpers.h"
|
|
|
|
namespace esphome::uart {
|
|
|
|
/// One software serial TX byte as line levels, one bit per slot.
|
|
struct SoftwareSerialTxFrame {
|
|
/// The start bit at slot 0, then the frame, then a stop bit that ends the last run
|
|
uint32_t line;
|
|
/// Slot of the last 0; from the edge after it the line stays high through the stop bits
|
|
uint32_t high_from;
|
|
/// Slots right after an edge into a run of equal bits lasting at least `min_run_cycles`, where a pending
|
|
/// interrupt only delays bits that repeat the level
|
|
uint32_t unlock_at;
|
|
};
|
|
|
|
/// `frame` holds `num_bits` data and parity bits, LSB first. `unlock_at` stays 0 unless `find_unlocks`.
|
|
ESPHOME_ALWAYS_INLINE inline SoftwareSerialTxFrame software_serial_tx_frame(uint32_t frame, uint32_t num_bits,
|
|
uint32_t bit_time, uint32_t min_run_cycles,
|
|
bool find_unlocks) {
|
|
SoftwareSerialTxFrame tx;
|
|
tx.line = frame << 1 | (1u << (num_bits + 1));
|
|
// Slot 0 is the start bit, always 0, so the argument is never 0
|
|
tx.high_from = 31 - __builtin_clz(~tx.line & ((2u << num_bits) - 1));
|
|
tx.unlock_at = 0;
|
|
if (find_unlocks) {
|
|
const uint32_t edges = tx.line ^ (tx.line << 1 | 1); // the idle line before the start bit is high
|
|
for (uint32_t pos = 0; pos <= tx.high_from; pos++) {
|
|
if (((edges >> pos) & 1) && (__builtin_ctz(edges >> (pos + 1)) + 1) * bit_time >= min_run_cycles)
|
|
tx.unlock_at |= 1u << pos;
|
|
}
|
|
}
|
|
return tx;
|
|
}
|
|
|
|
} // namespace esphome::uart
|