FastLED 3.10.6
Loading...
Searching...
No Matches

◆ uartWireTiming()

ChipsetTiming fl::uartWireTiming ( const ChipsetTimingConfig & timing,
u32 max_baud_rate )

The wire timing the UART encoder actually produces for a chipset.

The encoder quantises T0H/T1H onto a grid of period / pulses_per_bit, so what appears on the wire is not the chipset's nominal timing. A receiver decoding a UART-encoded frame has to classify against the quantised values, not the datasheet ones – otherwise it is matching a waveform nobody sent.

Derived through the same fitUartWave() rules that built the LUT, so the decode windows cannot drift from the encoding.

Parameters
timingChipset timing configuration
max_baud_rateBackend baud ceiling (selects the frame geometry)
Returns
Quantised wire timing, or a zeroed ChipsetTiming if infeasible

Definition at line 196 of file uart_wave_encoder.cpp.hpp.

197 {
198 const Wave10Lut lut = buildWave10LutForMaxBaud(timing, max_baud_rate);
199 if (lut.pulses_per_bit == 0) {
200 return ChipsetTiming{0, 0, 0, timing.reset_us, "uart_infeasible"};
201 }
202 // Re-run the fit at the geometry the LUT settled on. With P fixed the
203 // result is independent of max_baud_rate (that argument only gates
204 // feasibility), so this reproduces exactly the pulse counts encoded.
205 const UartWaveFit fit = fitUartWave(timing, lut.pulses_per_bit, max_baud_rate);
206 if (!fit.ok) {
207 return ChipsetTiming{0, 0, 0, timing.reset_us, "uart_infeasible"};
208 }
209 const u32 period_ns = timing.total_period_ns();
210 const u32 pulse_width_ns = period_ns / lut.pulses_per_bit;
211 const u32 t0h = fit.pulses_0 * pulse_width_ns;
212 const u32 t1h = fit.pulses_1 * pulse_width_ns;
213 return ChipsetTiming{t0h, t1h - t0h, period_ns - t1h, timing.reset_us,
214 "uart_wire"};
215}
UartWaveFit fitUartWave(const ChipsetTimingConfig &timing, u8 pulses_per_bit, u32 max_baud_rate) FL_NO_EXCEPT
Evaluate whether P pulses/LED-bit can represent the timing.
Wave10Lut buildWave10LutForMaxBaud(const ChipsetTimingConfig &timing, u32 max_baud_rate) FL_NO_EXCEPT
Build a UART waveform LUT with a backend-specific baud ceiling.
Generic chipset timing entry Provides T1, T2, T3 timing parameters in nanoseconds for any LED protoco...
Definition led_timing.h:86
constexpr u32 total_period_ns() const FL_NO_EXCEPT
Get total bit period (T1 + T2 + T3)
u32 reset_us
Reset/latch time (microseconds)
u8 pulses_per_bit
Frame geometry: 5 (wave10) or 4 (wave8-frame); 0 = infeasible.
Wave lookup table for UART LED encoding (waveN family)

References buildWave10LutForMaxBaud(), FL_NO_EXCEPT, and fl::Wave10Lut::pulses_per_bit.

+ Here is the call graph for this function: