Skip to content

feat(lpuart): WS2812 driver via LPUART4 inverted-TX + eDMA for Teensy 4.x - #3421

Merged
zackees merged 11 commits into
masterfrom
feat/lpuart-ws2812-driver
Jun 27, 2026
Merged

zackees merged 11 commits into
masterfrom
feat/lpuart-ws2812-driver

Conversation

@zackees

@zackees zackees commented Jun 27, 2026 •

Copy link
Copy Markdown
Member

Summary

Third clockless WS2812 driver path for Teensy 4.x, alongside FlexIO (#3415) and ObjectFLED (#3416). Uses LPUART4 in inverted-TX mode at 4 Mbps with eDMA, where each UART byte's 10 wire bits encode exactly 2 WS2812 bits via the wave8 framing trick.

Architecture

        TX path                                                      RX (test loopback)
┌──────────────────────────────────────────┐                  ┌─────────────────────┐
│ ChannelEngineLPUART                      │                  │ FlexPwmRxChannel    │
│   → ILPUARTPeripheral::createInstance()  │                  │   (pin 22 FlexPWM4) │
│   → encode raw bytes → wave8 UART bytes  │                  └─────────────────────┘
│ LPUARTPeripheralReal (or mock for tests) │
│   → lpuart_init(): CCM PLL3_80M, BAUD,   │
│      CTRL TXINV+TE, FIFO+TDMAE, mux ALT2 │
│      + IOMUXC SELECT_INPUT daisy         │      ┌─────────┐
│   → lpuart_show_encoded(): eDMA stream   │ ───→ │ pin 8   │ ──→ jumper ──→ pin 22
│      to LPUARTn_DATA, wait DMA + TC      │      └─────────┘
└──────────────────────────────────────────┘

Wave8 encoding (4 Mbps, TXINV=1)

WS2812 bit pair (MSB-first) UART byte Wire pattern
(0, 0) 0xEF H L L L L H L L L L
(0, 1) 0x8F H L L L L H H H L L
(1, 0) 0xEC H H H L L H L L L L
(1, 1) 0x8C H H H L L H H H L L

Each wire bit = 250 ns. Each WS2812 bit = 5 wire bits = 1250 ns. One WS2812 byte = 4 UART bytes. 100 LEDs (300 RGB bytes) = 1200 UART bytes = 3 ms TX.

What this PR contains

  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_encoder.h -- header-only wave8 encoder (host-testable, no Teensy deps)
  • src/.../drivers/lpuart/lpuart_driver.{h,cpp.hpp} -- Teensy 4.x real driver: CCM, mux, IOMUXC SELECT_INPUT daisy, BAUD config, eDMA TX
  • src/.../drivers/lpuart/lpuart_peripheral_real.cpp.hpp -- ILPUARTPeripheral::create() factory for Teensy 4.x
  • src/.../drivers/lpuart/channel_engine_lpuart.{h,cpp.hpp} -- High-level engine mirroring ChannelEngineFlexIO (member-owned mInstance/mCurrentPin/mCurrentRawBytes)
  • src/.../drivers/lpuart/bus_traits.h -- BusTraits<Bus::LPUART> specialisation
  • tests/.../drivers/lpuart/lpuart_encoder.cpp -- 8 host-side encoder tests (all 4 pair values, MSB-first ordering, wire-format invariant)
  • ci/autoresearch/{args.py,phases.py} -- enable --lpuart flag in the autoresearch harness
  • examples/AutoResearch/AutoResearchTest.cpp -- LPUART driver name matches is_uart_driver path

Per-pin map (Teensy 4.0, audited against Teensyduino HardwareSerial[1-7].cpp):

pin LPUARTn pad mux_offset SELECT_INPUT
1 LPUART6 GPIO_AD_B0_12 0x0EC 1
8 LPUART4 GPIO_B1_00 0x17C 2
14 LPUART2 GPIO_AD_B1_02 0x104 1
17 LPUART3 GPIO_AD_B1_06 0x114 0
20 LPUART8 GPIO_AD_B1_10 0x124 1
24 LPUART1 GPIO_AD_B0_13 0x0F0 (fixed-route)
29 LPUART7 GPIO_EMC_31 0x090 1

Verification

  • bash test lpuart_encoder -- 8/8 host unit tests pass (wave8 math, wire-format invariant)
  • bash test ilpuart_peripheral -- mock interface tests pass
  • bash compile teensy40 --examples AutoResearch -- builds clean
  • bash compile teensy41 --examples Blink -- builds clean
  • bash compile esp32dev --examples Blink -- builds clean (LPUART code guarded behind FL_IS_TEENSY_4X)
  • bash lint -- exit 0
  • Hardware loopback (Teensy 4.0, pin 8 TX → pin 22 RX): when the test framework completes, byte corruption ~1.0% matching FlexIO/ObjectFLED noise floor. Raw sample H753 L499 ... H253 L999 ... matches the 4 Mbps wave8 timing exactly.

Known limitation

The bash autoresearch teensy40 --lpuart test harness is intermittently flaky -- some runs complete with results (~1% byte corruption), others time out 25-60 s into the per-pattern loop downstream of the engine's show() (verified via diagnostic snapshots: my engine's show() always returns cleanly with DMA major-loop ISR fired and LPUART STAT.TC set). The flakiness appears specific to LPUART's interaction with the FlexPwm RX setup-and-decode handoff and not the LPUART driver itself; it does not affect actual WS2812 strip drive correctness. Tracking as a follow-up.

Test plan

  • CI build green across all platforms
  • Manual hardware test on Teensy 4.0 with pin 8 → real WS2812 strip
  • Hardware test on Teensy 4.1 with pin 8 (LPUART3 on T4.1) -- pin-map auto-switches by board

Refs #3023

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added Teensy 4.x LPUART clockless LED output support, including driver enablement, channel handling, and inverted-TX Wave8 encoding.
  • Bug Fixes
    • The --lpuart option is no longer blocked and now runs with LPUART selection.
    • LPUART is treated as a UART-style driver for capture/timeout handling.
  • Tests
    • Added unit tests covering LPUART byte encoding and wire-format invariants.
  • Documentation
    • Improved --lpuart help text to clarify board-dependent pin mapping.

zackees added 7 commits June 26, 2026 16:15
Adds Bus::LPUART workstream A from #3023:

- src/.../drivers/lpuart/lpuart_encoder.h: header-only WS2812 -> UART
  byte encoder. 2 WS2812 bits per UART byte using TXINV semantics.
  Wire pattern per bit at 4 Mbps:
    '0' -> H L L L L  (250 ns + 1000 ns)
    '1' -> H H H L L  (750 ns + 500 ns)
  Pair-to-byte table: (0,0)->0xEF, (0,1)->0x8F, (1,0)->0xEC, (1,1)->0x8C.
- src/.../drivers/lpuart/lpuart_driver.{h,cpp.hpp}: Teensy 4.x real
  driver. Configures LPUARTn for 4 Mbps with TXINV + TDMAE, programs
  the IOMUXC pad to ALT2 + SION, allocates a 4 KB DMAMEM buffer, and
  drives eDMA from the encoded byte stream to LPUARTn_DATA.
- src/.../drivers/lpuart/lpuart_peripheral_real.cpp.hpp: ILPUARTPeripheral
  factory for Teensy 4.x. Wraps the procedural driver in the existing
  ILPUARTInstance interface that the mock in
  src/platforms/shared/mock/arm/teensy4/drivers/lpuart/ already targets.
- tests/.../drivers/lpuart/lpuart_encoder.cpp: 8 host-side unit tests
  covering all-zeros, all-ones, MSB-first ordering, palindromic
  patterns, the pair-byte table, and the wire-format invariant.

Verified:
- bash test ilpuart_peripheral: existing mock interface tests pass
- bash test lpuart_encoder: 8/8 encoder tests pass on host
- bash compile teensy40 --examples Blink: clean build on T4.0 with
  the new driver in the unity build path

Pin map (T4.0): pin 1/8/14/17/20/24/29 map to LPUART6/4/2/3/8/1/7
TX respectively. Bench-rig pin 8 reuses the existing FlexIO/ObjectFLED
loopback jumper to FlexPWM-RX pin 22.

Refs #3023
Add the high-level ChannelEngineLPUART (mirrors ChannelEngineFlexIO)
plus a BusTraits<Bus::LPUART> specialisation so Bus::LPUART routes
through the real Teensy 4.x driver.

- channel_engine_lpuart.{h,cpp.hpp}: engine creates one ILPUARTInstance
  per (pin, strip-length) combination, encodes raw WS2812 bytes into
  the instance buffer using lpuart_encode_byte(), and calls
  instance->show().
- bus_traits.h: standard registerWithManager() pattern.
- lpuart_driver: add lpuart_show_encoded() for callers (the engine)
  that pre-encode externally; refactor common TCD arming into
  lpuart_arm_dma().
- bus_priorities.h: Bus::LPUART defaults to priority 1 (same as FlexIO
  and ObjectFLED).

Teensy 4.0 AutoResearch builds clean. Hardware test next.
Hardware bring-up progress on Teensy 4.0:
- Init sequence runs cleanly: clock gate, BAUD config, FIFO+CTRL,
  pin mux + IOMUXC SELECT_INPUT daisy.
- LPUART4 STAT = 0xC00000 after configure -> TC+TDRE both set,
  transmitter is alive.
- Polled writes successfully push 1200 wave8 UART bytes in 10 ms
  (= ~120 kbps actual due to per-byte STAT-polling overhead, well
  short of the 4 Mbps the BAUD divisor targets but proves the
  hardware path works).
- DMA arming sequence currently never sees the major-loop ISR fire;
  next iteration adds DMA_ES + CITER snapshots to diagnose whether
  TDMAE is being honored.

Also wires --lpuart through the autoresearch driver dispatcher and
enables Bus::LPUART in the Teensy 4.x enableAllChannelDrivers list.

Hardware test reproducible: bash autoresearch teensy40 --lpuart
--tx-pin 8 --rx-pin 22 reaches LPUART firmware and emits bytes on
pin 8 (polled path). Full WS2812-rate DMA path is the remaining
work.
Working LPUART driver path bring-up:
- Force CCM_CSCDR1 UART_CLK_SEL=PLL3_80M / UART_CLK_PODF=1 so the
  LPUART clock is 80 MHz regardless of what the Teensyduino boot
  state left CSCDR1 at. Empirical: post-boot the LPUART clock was
  24 MHz, making OSR=4/SBR=4 produce ~1.2 Mbps instead of 4 Mbps.
- Move triggerAtHardwareEvent() + attachInterrupt() out of the
  per-show arm path into lpuart_dma_init() (set once at init).
- Add LPUART transmit-complete (STAT.TC) wait after the DMA major-
  loop ISR fires, so the final byte fully drains through the FIFO
  + shift register before show_encoded() returns.

Hardware verification (bench loopback, Teensy 4.0 pin 8 -> pin 22
via FlexPWM4_SM0_A RX):

  raw_sample: H753 L499 H746 L499 H753 L499 ... H253 L999 H246 L999
  -> exactly matches wave8 4-Mbps encoding:
       '1' bit = ~750 ns HIGH + ~500 ns LOW
       '0' bit = ~250 ns HIGH + ~1000 ns LOW
  -> Byte corruption: 1.4% (17/1200) on the first 4-pattern frame
     -- matches the FlexIO/ObjectFLED noise floor on the same rig.

DMA progression confirmed via CITER snapshots (in earlier diagnostic
revs): CITER decrements smoothly from BITER=1200 to 0 within ~3 ms
at 4 Mbps, then the major-loop ISR fires and resets CITER back to
BITER and sets sLpDmaComplete = true.

Still TODO: the autoresearch RPC sometimes times out after 2 TX
frames before the test framework collects results. The TX driver
itself completes cleanly each time -- the hang is in the test
harness's between-pattern handoff, not in the LPUART path.
- Replace function-local static CachedInstance with proper member
  state (mInstance, mCurrentPin, mCurrentRawBytes, mCurrentTiming)
  mirroring ChannelEngineFlexIO's per-engine cache pattern.
- Add yield() after each show() so the USB-CDC RPC stack can flush
  responses; without it the autoresearch test pipeline stalls.
- Per user note: ws2812b-v5 datasheet specifies 150 us reset/latch,
  not the 280 us we had hard-coded. Update TIMING_WS2812B_MINI_V3
  (which TIMING_WS2812B_V5 aliases). The longer 280 us was a
  conservative carry-over from older WS2812 variants.
Audited every entry in kLpuartPins[] against the matching
UARTn_Hardware struct in Teensyduino's HardwareSerial[1-7].cpp and
the IOMUXC_SW_MUX_CTL_PAD_GPIO_* offsets in imxrt.h. Found 6 of 7
entries had wrong mux_offset/pad_offset/select_input_value -- only
pin 8 was correct, which is why the bench rig works there but other
pins would have silently driven the wrong pad.

Corrected (all entries verified for Teensy 4.0):
  pin  1 -> LPUART6 TX, GPIO_AD_B0_12 (mux 0x0EC),  SELECT_INPUT=1
  pin  8 -> LPUART4 TX, GPIO_B1_00    (mux 0x17C),  SELECT_INPUT=2
  pin 14 -> LPUART2 TX, GPIO_AD_B1_02 (mux 0x104),  SELECT_INPUT=1
  pin 17 -> LPUART3 TX, GPIO_AD_B1_06 (mux 0x114),  SELECT_INPUT=0
  pin 20 -> LPUART8 TX, GPIO_AD_B1_10 (mux 0x124),  SELECT_INPUT=1
  pin 24 -> LPUART1 TX, GPIO_AD_B0_13 (mux 0x0F0),  no SELECT_INPUT
  pin 29 -> LPUART7 TX, GPIO_EMC_31   (mux 0x090),  SELECT_INPUT=1

Also revert WS2812B_V5 RESET back to 280 us per user follow-up.

Strip debug Serial.printf from engine + driver. Engine kept member-
state refactor (mInstance/mCurrentPin/mCurrentRawBytes) + yield()
after show.

Hardware status: bench rig with pin 8 LPUART loopback to pin 22
FlexPWM RX intermittently completes the 4-pattern test at the
~1% byte corruption noise floor matching FlexIO/ObjectFLED. Some
runs RPC-timeout downstream of the engine show() -- the LPUART TX
itself completes cleanly each time per the diagnostic snapshots.
In examples/AutoResearch/AutoResearchTest.cpp `is_uart_driver` was
narrowly checking `driver_name == "UART"`. The LPUART driver
emits a wave8-encoded 4 Mbps signal whose wire shape is functionally
identical to the existing UART path -- T0H=250 ns, T1H=750 ns,
T1L=500 ns -- so it should take the same decode branch (UART-specific
timing thresholds, 500 ms RX wait, gap_tolerance_ns=100us). Expand
the check to also match LPUART.
@coderabbitai

coderabbitai Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Teensy 4.x LPUART clockless support across public APIs, hardware driver code, peripheral/channel integration, build wiring, AutoResearch routing, and encoder tests.

Changes

Teensy 4.x LPUART support

Layer / File(s) Summary
Public contracts and encoding primitives
src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_driver.h, src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_encoder.h, src/platforms/arm/teensy/teensy4_common/drivers/lpuart/bus_traits.h, src/fl/channels/bus_priorities.h
Public headers add LPUART pin metadata, driver lifecycle and diagnostics APIs, WS2812-to-UART encoding helpers, Teensy 4.x bus traits, and LPUART bus priority wiring.
LPUART hardware and DMA driver
src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_driver.cpp.hpp
The Teensy 4.x driver maps pins, configures registers and DMA, transmits encoded buffers, and exposes completion and diagnostics state.
Peripheral wrapper and channel engine
src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_peripheral_real.cpp.hpp, src/platforms/arm/teensy/teensy4_common/drivers/lpuart/channel_engine_lpuart.h, src/platforms/arm/teensy/teensy4_common/drivers/lpuart/channel_engine_lpuart.cpp.hpp
The concrete peripheral owns the encoded TX buffer and forwards show calls, while ChannelEngineLPUART accepts, queues, encodes, and transmits clockless data.
Platform wiring and validation
src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp, src/platforms/arm/teensy/teensy4_common/drivers/_build.cpp.hpp, src/platforms/arm/teensy/teensy4_common/drivers/lpuart/_build.cpp.hpp, ci/autoresearch/args.py, ci/autoresearch/phases.py, examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp, examples/AutoResearch/AutoResearchTest.cpp, tests/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_encoder.cpp, src/platforms/arm/teensy/teensy4_common/drivers/lpuart/ilpuart_peripheral.h
Teensy build and driver enablement include LPUART, AutoResearch accepts and classifies the flag, pin-capable mappings are updated, and encoder tests cover byte and wire-format mappings.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2400: Both PRs modify the AutoResearch test capture path in examples/AutoResearch/AutoResearchTest.cpp, including UART/LPUART classification.
  • FastLED/FastLED#2429: This PR extends the same Bus/BusTraits registration path with Teensy 4.x LPUART trait specializations.
  • FastLED/FastLED#2437: This PR adds Bus::LPUART priority wiring on top of the per-bus priority plumbing introduced there.

Poem

A rabbit hopped through byte and beam,
And stitched LPUART into the stream.
One hop for pins, one hop for bits,
One hop for DMA as timing fits,
And LEDs blinked in a bright green gleam. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.31% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a Teensy 4.x WS2812 driver using LPUART4 inverted-TX and eDMA.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/lpuart-ws2812-driver

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/autoresearch/args.py`:
- Around line 262-264: The "--lpuart" help text in args.py is too broad because
the pin mapping differs by Teensy board. Update the argparse help string in the
LPUART option to make the mapping board-specific (for example, distinguish
Teensy 4.0 from Teensy 4.1) or describe it as dependent on the board’s pin
table, so it no longer states that pin 8 universally maps to LPUART4 on all
Teensy 4.x boards.

In `@src/platforms/arm/teensy/teensy4_common/drivers/lpuart/bus_traits.h`:
- Around line 27-29: The singleton storage in instancePtr() is a non-trivial
function-local static inside a header, which violates the repo rule for
src/**/*.h. Move the gHolder storage/initialization out of bus_traits.h into a
translation-unit-owned definition or .cpp.hpp-backed implementation, and keep
instancePtr() as a thin forwarder that only returns the already-owned instance.
Use the instancePtr() and gHolder symbols to locate and refactor the singleton
setup without leaving function-static initialization in the header.

In
`@src/platforms/arm/teensy/teensy4_common/drivers/lpuart/channel_engine_lpuart.cpp.hpp`:
- Around line 93-104: Clear the cached hardware binding state in
ChannelEngineLPUART before retrying instance creation: when `mInstance.reset()`
is followed by a failed `mPeripheral->createInstance(...)`, also invalidate
`mHwInitialized` and the cached pin/timing/raw-byte fields so a later pass in
`channel_engine_lpuart.cpp.hpp` cannot skip reinitialization and use a null
`mInstance`. Update the reinit logic around `mInstance`, `mHwInitialized`,
`mCurrentPin`, `mCurrentTiming`, and `mCurrentRawBytes` together so the cache
always reflects whether a valid instance exists.
- Around line 68-78: The wait logic in the LPUART transmit path is busy-spinning
until poll() returns DriverState::READY, which can monopolize the CPU during the
100ms timeout window. Update the bounded wait in channel_engine_lpuart.cpp.hpp
to yield inside the loop by calling fl::task::run(250,
fl::task::ExecFlags::SYSTEM) while preserving the existing timeout fallback and
force-clear behavior for mTransmittingChannels.

In
`@src/platforms/arm/teensy/teensy4_common/drivers/lpuart/channel_engine_lpuart.h`:
- Around line 37-42: The channel engine header currently defines methods inline,
which violates the src/**/*.h rule. Move the bodies of
ChannelEngineLPUART::getName and ChannelEngineLPUART::getCapabilities out of
channel_engine_lpuart.h into channel_engine_lpuart.cpp.hpp, and leave only the
declarations in the header while keeping the same signatures and
override/FL_NO_EXCEPT qualifiers.

In
`@src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_driver.cpp.hpp`:
- Around line 269-270: The lpuart_init() implementation is ignoring reset_us,
which means the inter-frame latch gap is not being enforced before the next
WS2812 frame starts. Update lpuart_init() and any related transmit/setup logic
in the Lpuart driver to honor reset_us as the minimum low/reset delay between
frames, using the existing lpuart_init and show() flow so back-to-back show()
calls cannot begin too early.
- Around line 77-87: The LPUART pin table in kLpuartPins does not match the
public contract exposed by kLPUARTTxPins, so valid pins can be rejected or
mapped to the wrong LPUART instance. Update the static mapping used by
lpuart_lookup_pin in lpuart_driver.cpp.hpp to include the missing pins 35, 47,
and 48 and reconcile any mismatched LPUARTn entries so the lookup table and
advertised pin contract are consistent.
- Around line 343-347: The oversized raw-transfer path in the LPUART driver
currently warns and truncates in place, which lets the caller think the update
succeeded while only a partial frame is sent. Update the num_pixel_bytes
handling in the lpuart_driver.cpp.hpp logic so the kMaxRawBytes check fails the
transfer instead of capping it, and propagate an error/false return from the
same send path that currently logs “strip truncated.” Keep the existing symbols
around the transfer flow (num_pixel_bytes, kMaxRawBytes, and the LPUART raw
write/send method) so the caller can detect the failure and retry with a smaller
frame.

In `@src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_driver.h`:
- Around line 56-59: `lpuart_init()` currently advertises `reset_us` as part of
its public behavior, but the implementation in `lpuart_init` ignores it by
casting it away. Update the `lpuart_init` path in the LPUART driver to actually
use `reset_us` when configuring the inter-frame gap/reset-latch timing, wiring
it through the wait/reset logic in the implementation symbols that handle TX
timing. If that timing cannot be honored, remove `reset_us` from the
`lpuart_init` API and its documentation so the contract matches behavior.

In `@src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_encoder.h`:
- Around line 38-49: The fixed 4-byte output size in lpuart_encode_byte is
currently hidden behind a raw pointer, so make the buffer extent part of the API
by changing the out4 parameter to fl::span<u8, 4> or a u8 (&out4)[4] reference.
If these helpers must remain defined, move the implementations out of
lpuart_encoder.h into a .cpp.hpp/.impl.hpp and keep only declarations in the
header, while preserving the existing lpuart_pair_to_byte and lpuart_encode_byte
symbols.

In
`@src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_peripheral_real.cpp.hpp`:
- Around line 31-35: LPUARTInstanceReal::createInstance currently returns a
non-null object even when buffer allocation or lpuart_init fails, leaving
mInitialized false and allowing callers to use a broken instance. Update
createInstance and the LPUARTInstanceReal initialization path so failures in new
u8[mEncodedBytes]() or lpuart_lookup_pin/lpuart_init cause instance creation to
fail and return null/empty, and ensure the caller checks that result before
encoding or calling show().
- Around line 31-40: The TX buffer in LPUARTInstanceReal is still manually
managed with new[]/delete[], so switch mTxBuffer to the RAII type already
available here, fl::unique_ptr<u8[]>, and update the constructor and destructor
to rely on ownership cleanup instead of delete[]. If the buffer needs resizing
later, use fl::vector<u8> instead; otherwise keep the existing allocation flow
in LPUARTInstanceReal and lpuart_init unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 79783444-cdce-4289-b15d-b0c58ddb8f15

📥 Commits

Reviewing files that changed from the base of the PR and between 0df51bb and d9f9205.

📒 Files selected for processing (16)
  • ci/autoresearch/args.py
  • ci/autoresearch/phases.py
  • examples/AutoResearch/AutoResearchTest.cpp
  • src/fl/channels/bus_priorities.h
  • src/fl/chipsets/led_timing.h
  • src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/_build.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/_build.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/bus_traits.h
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/channel_engine_lpuart.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/channel_engine_lpuart.h
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_driver.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_driver.h
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_encoder.h
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_peripheral_real.cpp.hpp
  • tests/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_encoder.cpp
💤 Files with no reviewable changes (1)
  • ci/autoresearch/phases.py

Comment thread ci/autoresearch/args.py Resolved
zackees and others added 4 commits June 26, 2026 19:24
5 actionable findings:

- bus_traits.h: move BusTraits<Bus::LPUART>::instancePtr() function-
  local static `gHolder` out of the header into the .cpp.hpp TU
  (per repo's no-static-in-headers rule).
- channel_engine_lpuart.h: move getName() / getCapabilities() bodies
  out of the header into the .cpp.hpp.
- channel_engine_lpuart.cpp.hpp: clear mHwInitialized/mCurrentPin/
  mCurrentRawBytes BEFORE attempting createInstance() so a failed
  create leaves the engine in a clean re-init-required state instead
  of a half-torn-down state that the next channel could inherit.
- lpuart_driver.cpp.hpp: honour reset_us. Record the previous
  frame's end-of-TC micros and stall the next show until reset_us
  has elapsed -- contractual fix per the public docstring.
- ci/autoresearch/args.py: pin-to-LPUART mapping is board-dependent
  (T4.0 vs T4.1), don't hard-code "pin 8 -> LPUART4" in help text.

Remaining CodeRabbit MAJOR finding (pin map missing pins 35/47/48
per kLPUARTTxPins contract) is T4.1-only / SD-bottom-pad coverage,
deferred to follow-up.

Verified: teensy40 AutoResearch builds clean, lpuart_encoder host
tests still 1/1 pass.
Per user feedback:
- BusTraits<Bus::UART> specialised for Teensy 4.x to route through
  ChannelEngineLPUART. This matches the ESP32 pattern where Bus::UART
  binds to that platform's UART hardware; sketches that name
  Bus::UART work portably across both platforms.
- Bus::LPUART kept as an alias resolving to the same singleton
  instance so code that names the hardware directly still works.

CodeRabbit-flagged fixes:
- lpuart_encoder.h: replace `u8*` with `fl::span<u8, 4>` (static-
  extent span) so the 4-byte-output contract is checked at the type
  level. Call sites use `fl::span<u8, 4>{&buf[i*4], 4}`.
- lpuart_driver.cpp.hpp: reject oversize transfers instead of
  silently truncating them (was logging + truncating + returning
  success, leaving tail LEDs stale).
- lpuart_peripheral_real.cpp.hpp: return nullptr from createInstance
  if hardware init failed inside the constructor, instead of handing
  back a non-functional instance that would silently drop frames.
  Switch mTxBuffer from raw `new[]`/`delete[]` to
  `fl::unique_ptr<u8[]>` RAII.

Verified: bash test lpuart_encoder 8/8 pass; bash compile teensy40
AutoResearch clean.
- channel_drivers_teensy.impl.hpp: register only Bus::UART (not both
  Bus::UART and Bus::LPUART). Both resolve to the same singleton via
  the trait alias in bus_traits.h, so registering both was triggering
  the ChannelManager replace-driver path on every boot.

- lpuart_encoder.h: add IWYU pragma: private + FL_NO_EXCEPT on the
  two inline encode helpers.

- lpuart_driver.cpp.hpp: suppress BareAllocationChecker on the
  DMAChannel new/delete pair (Teensyduino DMAChannel has no
  fl smart-pointer factory).

- _build.cpp.hpp: alphabetize unity build includes (channel_engine
  before lpuart_*).

- flexio_driver.cpp.hpp: use FL_STATIC_ASSERT instead of raw
  static_assert per BannedMacrosChecker.

- third_party/object_fled/src/_build.cpp.hpp: alphabetize (ObjectFLED
  before ObjectFLEDDmaManager).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Pin map audit (per user's "Audit pin map against every Teensyduino
HardwareSerial*.cpp" blocker):
- Cross-referenced every kLpuartPins entry against the corresponding
  HardwareSerial[1-8].cpp UARTn_Hardware struct's {pin, mux_val,
  select_input_reg, select_input_value} 4-tuple.
- Added per-entry mux_alt field so the T4.1 LPUART5_TX (pin 35,
  ALT 1, not 2) doesn't get force-driven through the wrong alt.
- Added T4.1-only entries (pins 35, 47, 53) gated on
  ARDUINO_TEENSY41. Verified IOMUXC offsets against imxrt.h.
- Corrected the kLPUARTTxPins public contract: the original list
  included pin 48 (which is actually LPUART5_RX_ALT on T4.1, not
  a TX pin) and was missing pin 53 (the real T4.1 LPUART6_TX_ALT).
  Fixed list is {1, 8, 14, 17, 20, 24, 29, 35, 47, 53}.

JSON-RPC minimization (per user "json-rpc should be kept to the
minimal possible without excessive spam"):
- runSingleTestImpl: skip flexPwmRxDiagnostics and flexIoDiagnostics
  emit for LPUART tests. Both are FlexIO/FlexPWM register snapshots
  that surface nothing LPUART-relevant; LPUART status already lives
  in lpuart_read_diagnostics. Trims ~660 bytes of JSON per response.
- ScopedLogDisable scope: kept enabled for all drivers including
  LPUART (per-driver carve-out empirically worsened hangs to 0/3
  due to USB-CDC saturation from FL_WARN spam during the 4-pattern
  loop).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp (1)

1006-1049: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: merge the two adjacent emit_flex_diagnostics blocks.

Lines 1012 and 1016 guard back-to-back blocks with the same emit_flex_diagnostics condition, so they can be collapsed into a single if to reduce duplication. Logic is otherwise correct — LPUART runs correctly skip both FlexPWM RX and FlexIO diagnostics.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp` around lines 1006
- 1049, The code has two adjacent blocks in AutoResearchRemoteRunSingleTest
gated by the same emit_flex_diagnostics condition, so they should be merged into
one. Update the diagnostics handling around emit_flex_diagnostics to combine the
FlexPwmRxChannel::diagnosticsToJson(pin_rx) response and the
FlexIODiagnostics/flexio_read_diagnostics JSON population into a single
conditional block, keeping the LPUART skip behavior unchanged and removing the
duplicate if.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp`:
- Around line 1006-1049: The code has two adjacent blocks in
AutoResearchRemoteRunSingleTest gated by the same emit_flex_diagnostics
condition, so they should be merged into one. Update the diagnostics handling
around emit_flex_diagnostics to combine the
FlexPwmRxChannel::diagnosticsToJson(pin_rx) response and the
FlexIODiagnostics/flexio_read_diagnostics JSON population into a single
conditional block, keeping the LPUART skip behavior unchanged and removing the
duplicate if.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 79cca420-fc93-4c8b-9d1a-740946bbf36a

📥 Commits

Reviewing files that changed from the base of the PR and between 86e498e and 7d79576.

📒 Files selected for processing (8)
  • examples/AutoResearch/AutoResearchRemoteRunSingleTest.cpp
  • src/platforms/arm/teensy/channel_drivers_teensy.impl.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/_build.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/ilpuart_peripheral.h
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_driver.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_encoder.h
  • src/third_party/object_fled/src/_build.cpp.hpp
✅ Files skipped from review due to trivial changes (3)
  • src/third_party/object_fled/src/_build.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/_build.cpp.hpp
  • src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_encoder.h
  • src/platforms/arm/teensy/teensy4_common/drivers/lpuart/lpuart_driver.cpp.hpp

@zackees
zackees merged commit 1b75a33 into master Jun 27, 2026
6 of 10 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 27, 2026
zackees added a commit that referenced this pull request Jun 27, 2026
… + LPUART polish (#3423)

* feat(lpuart): wave8 encoder + Teensy 4.x real driver + host unit tests

Adds Bus::LPUART workstream A from #3023:

- src/.../drivers/lpuart/lpuart_encoder.h: header-only WS2812 -> UART
  byte encoder. 2 WS2812 bits per UART byte using TXINV semantics.
  Wire pattern per bit at 4 Mbps:
    '0' -> H L L L L  (250 ns + 1000 ns)
    '1' -> H H H L L  (750 ns + 500 ns)
  Pair-to-byte table: (0,0)->0xEF, (0,1)->0x8F, (1,0)->0xEC, (1,1)->0x8C.
- src/.../drivers/lpuart/lpuart_driver.{h,cpp.hpp}: Teensy 4.x real
  driver. Configures LPUARTn for 4 Mbps with TXINV + TDMAE, programs
  the IOMUXC pad to ALT2 + SION, allocates a 4 KB DMAMEM buffer, and
  drives eDMA from the encoded byte stream to LPUARTn_DATA.
- src/.../drivers/lpuart/lpuart_peripheral_real.cpp.hpp: ILPUARTPeripheral
  factory for Teensy 4.x. Wraps the procedural driver in the existing
  ILPUARTInstance interface that the mock in
  src/platforms/shared/mock/arm/teensy4/drivers/lpuart/ already targets.
- tests/.../drivers/lpuart/lpuart_encoder.cpp: 8 host-side unit tests
  covering all-zeros, all-ones, MSB-first ordering, palindromic
  patterns, the pair-byte table, and the wire-format invariant.

Verified:
- bash test ilpuart_peripheral: existing mock interface tests pass
- bash test lpuart_encoder: 8/8 encoder tests pass on host
- bash compile teensy40 --examples Blink: clean build on T4.0 with
  the new driver in the unity build path

Pin map (T4.0): pin 1/8/14/17/20/24/29 map to LPUART6/4/2/3/8/1/7
TX respectively. Bench-rig pin 8 reuses the existing FlexIO/ObjectFLED
loopback jumper to FlexPWM-RX pin 22.

Refs #3023

* feat(lpuart): channel engine + BusTraits registration

Add the high-level ChannelEngineLPUART (mirrors ChannelEngineFlexIO)
plus a BusTraits<Bus::LPUART> specialisation so Bus::LPUART routes
through the real Teensy 4.x driver.

- channel_engine_lpuart.{h,cpp.hpp}: engine creates one ILPUARTInstance
  per (pin, strip-length) combination, encodes raw WS2812 bytes into
  the instance buffer using lpuart_encode_byte(), and calls
  instance->show().
- bus_traits.h: standard registerWithManager() pattern.
- lpuart_driver: add lpuart_show_encoded() for callers (the engine)
  that pre-encode externally; refactor common TCD arming into
  lpuart_arm_dma().
- bus_priorities.h: Bus::LPUART defaults to priority 1 (same as FlexIO
  and ObjectFLED).

Teensy 4.0 AutoResearch builds clean. Hardware test next.

* debug(lpuart): polled-tx diagnostic confirms LPUART4 transmits

Hardware bring-up progress on Teensy 4.0:
- Init sequence runs cleanly: clock gate, BAUD config, FIFO+CTRL,
  pin mux + IOMUXC SELECT_INPUT daisy.
- LPUART4 STAT = 0xC00000 after configure -> TC+TDRE both set,
  transmitter is alive.
- Polled writes successfully push 1200 wave8 UART bytes in 10 ms
  (= ~120 kbps actual due to per-byte STAT-polling overhead, well
  short of the 4 Mbps the BAUD divisor targets but proves the
  hardware path works).
- DMA arming sequence currently never sees the major-loop ISR fire;
  next iteration adds DMA_ES + CITER snapshots to diagnose whether
  TDMAE is being honored.

Also wires --lpuart through the autoresearch driver dispatcher and
enables Bus::LPUART in the Teensy 4.x enableAllChannelDrivers list.

Hardware test reproducible: bash autoresearch teensy40 --lpuart
--tx-pin 8 --rx-pin 22 reaches LPUART firmware and emits bytes on
pin 8 (polled path). Full WS2812-rate DMA path is the remaining
work.

* feat(lpuart): hardware-verified DMA path on Teensy 4.0

Working LPUART driver path bring-up:
- Force CCM_CSCDR1 UART_CLK_SEL=PLL3_80M / UART_CLK_PODF=1 so the
  LPUART clock is 80 MHz regardless of what the Teensyduino boot
  state left CSCDR1 at. Empirical: post-boot the LPUART clock was
  24 MHz, making OSR=4/SBR=4 produce ~1.2 Mbps instead of 4 Mbps.
- Move triggerAtHardwareEvent() + attachInterrupt() out of the
  per-show arm path into lpuart_dma_init() (set once at init).
- Add LPUART transmit-complete (STAT.TC) wait after the DMA major-
  loop ISR fires, so the final byte fully drains through the FIFO
  + shift register before show_encoded() returns.

Hardware verification (bench loopback, Teensy 4.0 pin 8 -> pin 22
via FlexPWM4_SM0_A RX):

  raw_sample: H753 L499 H746 L499 H753 L499 ... H253 L999 H246 L999
  -> exactly matches wave8 4-Mbps encoding:
       '1' bit = ~750 ns HIGH + ~500 ns LOW
       '0' bit = ~250 ns HIGH + ~1000 ns LOW
  -> Byte corruption: 1.4% (17/1200) on the first 4-pattern frame
     -- matches the FlexIO/ObjectFLED noise floor on the same rig.

DMA progression confirmed via CITER snapshots (in earlier diagnostic
revs): CITER decrements smoothly from BITER=1200 to 0 within ~3 ms
at 4 Mbps, then the major-loop ISR fires and resets CITER back to
BITER and sets sLpDmaComplete = true.

Still TODO: the autoresearch RPC sometimes times out after 2 TX
frames before the test framework collects results. The TX driver
itself completes cleanly each time -- the hang is in the test
harness's between-pattern handoff, not in the LPUART path.

* fix(lpuart): refactor engine, ws2812b-v5 reset=150us, add yield()

- Replace function-local static CachedInstance with proper member
  state (mInstance, mCurrentPin, mCurrentRawBytes, mCurrentTiming)
  mirroring ChannelEngineFlexIO's per-engine cache pattern.
- Add yield() after each show() so the USB-CDC RPC stack can flush
  responses; without it the autoresearch test pipeline stalls.
- Per user note: ws2812b-v5 datasheet specifies 150 us reset/latch,
  not the 280 us we had hard-coded. Update TIMING_WS2812B_MINI_V3
  (which TIMING_WS2812B_V5 aliases). The longer 280 us was a
  conservative carry-over from older WS2812 variants.

* fix(lpuart): audit pin map against Teensyduino HardwareSerial sources

Audited every entry in kLpuartPins[] against the matching
UARTn_Hardware struct in Teensyduino's HardwareSerial[1-7].cpp and
the IOMUXC_SW_MUX_CTL_PAD_GPIO_* offsets in imxrt.h. Found 6 of 7
entries had wrong mux_offset/pad_offset/select_input_value -- only
pin 8 was correct, which is why the bench rig works there but other
pins would have silently driven the wrong pad.

Corrected (all entries verified for Teensy 4.0):
  pin  1 -> LPUART6 TX, GPIO_AD_B0_12 (mux 0x0EC),  SELECT_INPUT=1
  pin  8 -> LPUART4 TX, GPIO_B1_00    (mux 0x17C),  SELECT_INPUT=2
  pin 14 -> LPUART2 TX, GPIO_AD_B1_02 (mux 0x104),  SELECT_INPUT=1
  pin 17 -> LPUART3 TX, GPIO_AD_B1_06 (mux 0x114),  SELECT_INPUT=0
  pin 20 -> LPUART8 TX, GPIO_AD_B1_10 (mux 0x124),  SELECT_INPUT=1
  pin 24 -> LPUART1 TX, GPIO_AD_B0_13 (mux 0x0F0),  no SELECT_INPUT
  pin 29 -> LPUART7 TX, GPIO_EMC_31   (mux 0x090),  SELECT_INPUT=1

Also revert WS2812B_V5 RESET back to 280 us per user follow-up.

Strip debug Serial.printf from engine + driver. Engine kept member-
state refactor (mInstance/mCurrentPin/mCurrentRawBytes) + yield()
after show.

Hardware status: bench rig with pin 8 LPUART loopback to pin 22
FlexPWM RX intermittently completes the 4-pattern test at the
~1% byte corruption noise floor matching FlexIO/ObjectFLED. Some
runs RPC-timeout downstream of the engine show() -- the LPUART TX
itself completes cleanly each time per the diagnostic snapshots.

* fix(autoresearch): LPUART takes the UART-decode path

In examples/AutoResearch/AutoResearchTest.cpp `is_uart_driver` was
narrowly checking `driver_name == "UART"`. The LPUART driver
emits a wave8-encoded 4 Mbps signal whose wire shape is functionally
identical to the existing UART path -- T0H=250 ns, T1H=750 ns,
T1L=500 ns -- so it should take the same decode branch (UART-specific
timing thresholds, 500 ms RX wait, gap_tolerance_ns=100us). Expand
the check to also match LPUART.

* fix(lpuart): address CodeRabbit review on PR #3421

5 actionable findings:

- bus_traits.h: move BusTraits<Bus::LPUART>::instancePtr() function-
  local static `gHolder` out of the header into the .cpp.hpp TU
  (per repo's no-static-in-headers rule).
- channel_engine_lpuart.h: move getName() / getCapabilities() bodies
  out of the header into the .cpp.hpp.
- channel_engine_lpuart.cpp.hpp: clear mHwInitialized/mCurrentPin/
  mCurrentRawBytes BEFORE attempting createInstance() so a failed
  create leaves the engine in a clean re-init-required state instead
  of a half-torn-down state that the next channel could inherit.
- lpuart_driver.cpp.hpp: honour reset_us. Record the previous
  frame's end-of-TC micros and stall the next show until reset_us
  has elapsed -- contractual fix per the public docstring.
- ci/autoresearch/args.py: pin-to-LPUART mapping is board-dependent
  (T4.0 vs T4.1), don't hard-code "pin 8 -> LPUART4" in help text.

Remaining CodeRabbit MAJOR finding (pin map missing pins 35/47/48
per kLPUARTTxPins contract) is T4.1-only / SD-bottom-pad coverage,
deferred to follow-up.

Verified: teensy40 AutoResearch builds clean, lpuart_encoder host
tests still 1/1 pass.

* fix(lpuart): Bus::UART specialization + remaining CodeRabbit fixes

Per user feedback:
- BusTraits<Bus::UART> specialised for Teensy 4.x to route through
  ChannelEngineLPUART. This matches the ESP32 pattern where Bus::UART
  binds to that platform's UART hardware; sketches that name
  Bus::UART work portably across both platforms.
- Bus::LPUART kept as an alias resolving to the same singleton
  instance so code that names the hardware directly still works.

CodeRabbit-flagged fixes:
- lpuart_encoder.h: replace `u8*` with `fl::span<u8, 4>` (static-
  extent span) so the 4-byte-output contract is checked at the type
  level. Call sites use `fl::span<u8, 4>{&buf[i*4], 4}`.
- lpuart_driver.cpp.hpp: reject oversize transfers instead of
  silently truncating them (was logging + truncating + returning
  success, leaving tail LEDs stale).
- lpuart_peripheral_real.cpp.hpp: return nullptr from createInstance
  if hardware init failed inside the constructor, instead of handing
  back a non-functional instance that would silently drop frames.
  Switch mTxBuffer from raw `new[]`/`delete[]` to
  `fl::unique_ptr<u8[]>` RAII.

Verified: bash test lpuart_encoder 8/8 pass; bash compile teensy40
AutoResearch clean.

* fix(lpuart): lint cleanup + single Bus::UART registration

- channel_drivers_teensy.impl.hpp: register only Bus::UART (not both
  Bus::UART and Bus::LPUART). Both resolve to the same singleton via
  the trait alias in bus_traits.h, so registering both was triggering
  the ChannelManager replace-driver path on every boot.

- lpuart_encoder.h: add IWYU pragma: private + FL_NO_EXCEPT on the
  two inline encode helpers.

- lpuart_driver.cpp.hpp: suppress BareAllocationChecker on the
  DMAChannel new/delete pair (Teensyduino DMAChannel has no
  fl smart-pointer factory).

- _build.cpp.hpp: alphabetize unity build includes (channel_engine
  before lpuart_*).

- flexio_driver.cpp.hpp: use FL_STATIC_ASSERT instead of raw
  static_assert per BannedMacrosChecker.

- third_party/object_fled/src/_build.cpp.hpp: alphabetize (ObjectFLED
  before ObjectFLEDDmaManager).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(lpuart): per-pin mux_alt + audited T4.1 entries + trim JSON-RPC

Pin map audit (per user's "Audit pin map against every Teensyduino
HardwareSerial*.cpp" blocker):
- Cross-referenced every kLpuartPins entry against the corresponding
  HardwareSerial[1-8].cpp UARTn_Hardware struct's {pin, mux_val,
  select_input_reg, select_input_value} 4-tuple.
- Added per-entry mux_alt field so the T4.1 LPUART5_TX (pin 35,
  ALT 1, not 2) doesn't get force-driven through the wrong alt.
- Added T4.1-only entries (pins 35, 47, 53) gated on
  ARDUINO_TEENSY41. Verified IOMUXC offsets against imxrt.h.
- Corrected the kLPUARTTxPins public contract: the original list
  included pin 48 (which is actually LPUART5_RX_ALT on T4.1, not
  a TX pin) and was missing pin 53 (the real T4.1 LPUART6_TX_ALT).
  Fixed list is {1, 8, 14, 17, 20, 24, 29, 35, 47, 53}.

JSON-RPC minimization (per user "json-rpc should be kept to the
minimal possible without excessive spam"):
- runSingleTestImpl: skip flexPwmRxDiagnostics and flexIoDiagnostics
  emit for LPUART tests. Both are FlexIO/FlexPWM register snapshots
  that surface nothing LPUART-relevant; LPUART status already lives
  in lpuart_read_diagnostics. Trims ~660 bytes of JSON per response.
- ScopedLogDisable scope: kept enabled for all drivers including
  LPUART (per-driver carve-out empirically worsened hangs to 0/3
  due to USB-CDC saturation from FL_WARN spam during the 4-pattern
  loop).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(autoresearch): gate FL_WARN sstream construction on log level

Resolves intermittent ~55s RPC timeout on Teensy 4 clockless tests
(LPUART, FlexIO, ObjectFLED autoresearch) when the test framework's
RPC ASYNC handler wraps execution in `fl::ScopedLogDisable`.

Root cause (marker-narrowed across this session):
`FL_WARN(...)` macro ALWAYS constructs `fl::sstream() << X` regardless
of log level -- `ScopedLogDisable` only suppresses OUTPUT inside
`log_emit`. The cumulative `fl::sstream`/`fl::string` heap alloc/free
cycles across this file's many FL_WARN sites (banner, per-run dump,
per-pattern hex dump, summary, OVERALL pass/fail) leave the Teensy 4
heap in a state where the function-exit destructor of a heap-backed
`fl::string` hangs indefinitely -- traced via Serial.println markers
to the `fl::variant<NotNullStringHolderPtr, ...>` destructor in
fl::sstream::~fl::sstream() at the close of runMultiTest.

Reproduction: ~80% of LPUART/FlexIO/ObjectFLED runs hung at exactly
`mt_pre_inner_close` marker → no `mt_dtors_done` → no
`art_after_multitest` → ~55s host timeout.

Fix: introduce `AR_FL_WARN` / `AR_FL_ERROR` macros that check
`fl::getLogLevel()` before expanding FL_WARN -- when under
ScopedLogDisable (level=NONE), the sstream is never constructed and
the heap stays clean. Sed-swept all 73 FL_WARN sites in
AutoResearchTest.cpp and 8 sites in AutoResearchHelpers.cpp.

Also gates `flexIoDiagnostics` / `flexPwmRxDiagnostics` JSON emit
to OBJECT_FLED only (their original #3343/#3410 purpose). LPUART
and FLEX_IO no longer carry that ~660-byte / 22-field JSON payload
that further compounds the heap pressure post-test.

Results (bench rig, Teensy 4.0, --lpuart --tx-pin 8 --rx-pin 22):
- LPUART:  1/5 baseline → 5/5 success (clean 0.3-2.0% noise floor)
- FlexIO:  0/5 baseline → 1-2/5 success (intermittent residual --
           likely additional heap pressure outside this file; not
           blocking since FlexIO landed via #3415 prior)
- LPUART tests now return reliable byte-corruption reports
  matching FlexIO/ObjectFLED noise floor, confirming the LPUART
  driver itself works correctly when the framework returns.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(arduino/io): ride out Teensy 4 USB-CDC DTR debounce in fl::print(ln)

Per /goal "USB-CDC DTR race" research follow-up.

Teensy 4 `Serial.operator bool()` (usb_serial.h:166-169) returns
false for a hard-coded 15ms after every DTR transition (line
discipline settle window). Without a retry on the device side, the
first messages emitted by the device after a host re-opens the
serial port are silently dropped -- the `if (!Serial) return;`
guard in fl::print/fl::println short-circuits before the debounce
clears.

Reproduction surface: autoresearch RPC reconnects for each new test
session (close → re-open). Device output during the first ~15ms
after re-open vanishes -- visible as "missing log lines between
RPC sessions" or "first FL_WARN after reconnect never arrives".

Fix: extract a small `waitForSerialReady_DtrSettle()` helper that:
  - Fast-paths the common case (Serial already true → no wait)
  - Otherwise yields in a bounded 30ms loop (2× the Teensy 4
    debounce) waiting for `Serial.operator bool()` to settle true
  - Drops the message after 30ms if host is genuinely absent

On non-Teensy Arduino platforms `Serial.operator bool()` either
always returns true (real UART) or has its own non-blocking drop
path (ESP32 HWCDC: setTxTimeoutMs(0) applied by fl::begin()), so
the 30ms bound is invisible there.

Cross-platform compile verified: teensy40 ✓, esp32dev ✓, uno ✓.
Lint clean. 338/338 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(arduino/io): extend DTR settle wait to fl::flush + fl::serial_ready

Follow-up to 6c2d12e. The DTR debounce race window doesn't only
affect fl::print/fl::println -- fl::flush and fl::serial_ready use
the same `if (!Serial) return ...` short-circuit pattern, and would
also report "host absent" during the first ~15ms after a host
re-opens the USB-CDC port on Teensy 4.

Wire both through the same `waitForSerialReady_DtrSettle()` helper
so the device-side host-presence view stays consistent across all
three paths: print, flush, and the explicit ready-check.

`fl::write_bytes` is intentionally left untouched -- it does not
gate on `Serial`, so the underlying `Serial.write` path drives its
own back-pressure / drop semantics (Teensy 4 usb_serial_write has
its own 120ms tx-buffer-wait timeout). LPC platforms are also
intentionally left untouched -- their Arduino-core USB-VCOM bridge
has different debounce semantics that aren't documented to need
the same window.

Cross-platform compile: teensy40 ✓, esp32dev ✓.
Lint clean. 338/338 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 27, 2026
…3296) (#3424)

* feat(lpuart): wave8 encoder + Teensy 4.x real driver + host unit tests

Adds Bus::LPUART workstream A from #3023:

- src/.../drivers/lpuart/lpuart_encoder.h: header-only WS2812 -> UART
  byte encoder. 2 WS2812 bits per UART byte using TXINV semantics.
  Wire pattern per bit at 4 Mbps:
    '0' -> H L L L L  (250 ns + 1000 ns)
    '1' -> H H H L L  (750 ns + 500 ns)
  Pair-to-byte table: (0,0)->0xEF, (0,1)->0x8F, (1,0)->0xEC, (1,1)->0x8C.
- src/.../drivers/lpuart/lpuart_driver.{h,cpp.hpp}: Teensy 4.x real
  driver. Configures LPUARTn for 4 Mbps with TXINV + TDMAE, programs
  the IOMUXC pad to ALT2 + SION, allocates a 4 KB DMAMEM buffer, and
  drives eDMA from the encoded byte stream to LPUARTn_DATA.
- src/.../drivers/lpuart/lpuart_peripheral_real.cpp.hpp: ILPUARTPeripheral
  factory for Teensy 4.x. Wraps the procedural driver in the existing
  ILPUARTInstance interface that the mock in
  src/platforms/shared/mock/arm/teensy4/drivers/lpuart/ already targets.
- tests/.../drivers/lpuart/lpuart_encoder.cpp: 8 host-side unit tests
  covering all-zeros, all-ones, MSB-first ordering, palindromic
  patterns, the pair-byte table, and the wire-format invariant.

Verified:
- bash test ilpuart_peripheral: existing mock interface tests pass
- bash test lpuart_encoder: 8/8 encoder tests pass on host
- bash compile teensy40 --examples Blink: clean build on T4.0 with
  the new driver in the unity build path

Pin map (T4.0): pin 1/8/14/17/20/24/29 map to LPUART6/4/2/3/8/1/7
TX respectively. Bench-rig pin 8 reuses the existing FlexIO/ObjectFLED
loopback jumper to FlexPWM-RX pin 22.

Refs #3023

* feat(lpuart): channel engine + BusTraits registration

Add the high-level ChannelEngineLPUART (mirrors ChannelEngineFlexIO)
plus a BusTraits<Bus::LPUART> specialisation so Bus::LPUART routes
through the real Teensy 4.x driver.

- channel_engine_lpuart.{h,cpp.hpp}: engine creates one ILPUARTInstance
  per (pin, strip-length) combination, encodes raw WS2812 bytes into
  the instance buffer using lpuart_encode_byte(), and calls
  instance->show().
- bus_traits.h: standard registerWithManager() pattern.
- lpuart_driver: add lpuart_show_encoded() for callers (the engine)
  that pre-encode externally; refactor common TCD arming into
  lpuart_arm_dma().
- bus_priorities.h: Bus::LPUART defaults to priority 1 (same as FlexIO
  and ObjectFLED).

Teensy 4.0 AutoResearch builds clean. Hardware test next.

* debug(lpuart): polled-tx diagnostic confirms LPUART4 transmits

Hardware bring-up progress on Teensy 4.0:
- Init sequence runs cleanly: clock gate, BAUD config, FIFO+CTRL,
  pin mux + IOMUXC SELECT_INPUT daisy.
- LPUART4 STAT = 0xC00000 after configure -> TC+TDRE both set,
  transmitter is alive.
- Polled writes successfully push 1200 wave8 UART bytes in 10 ms
  (= ~120 kbps actual due to per-byte STAT-polling overhead, well
  short of the 4 Mbps the BAUD divisor targets but proves the
  hardware path works).
- DMA arming sequence currently never sees the major-loop ISR fire;
  next iteration adds DMA_ES + CITER snapshots to diagnose whether
  TDMAE is being honored.

Also wires --lpuart through the autoresearch driver dispatcher and
enables Bus::LPUART in the Teensy 4.x enableAllChannelDrivers list.

Hardware test reproducible: bash autoresearch teensy40 --lpuart
--tx-pin 8 --rx-pin 22 reaches LPUART firmware and emits bytes on
pin 8 (polled path). Full WS2812-rate DMA path is the remaining
work.

* feat(lpuart): hardware-verified DMA path on Teensy 4.0

Working LPUART driver path bring-up:
- Force CCM_CSCDR1 UART_CLK_SEL=PLL3_80M / UART_CLK_PODF=1 so the
  LPUART clock is 80 MHz regardless of what the Teensyduino boot
  state left CSCDR1 at. Empirical: post-boot the LPUART clock was
  24 MHz, making OSR=4/SBR=4 produce ~1.2 Mbps instead of 4 Mbps.
- Move triggerAtHardwareEvent() + attachInterrupt() out of the
  per-show arm path into lpuart_dma_init() (set once at init).
- Add LPUART transmit-complete (STAT.TC) wait after the DMA major-
  loop ISR fires, so the final byte fully drains through the FIFO
  + shift register before show_encoded() returns.

Hardware verification (bench loopback, Teensy 4.0 pin 8 -> pin 22
via FlexPWM4_SM0_A RX):

  raw_sample: H753 L499 H746 L499 H753 L499 ... H253 L999 H246 L999
  -> exactly matches wave8 4-Mbps encoding:
       '1' bit = ~750 ns HIGH + ~500 ns LOW
       '0' bit = ~250 ns HIGH + ~1000 ns LOW
  -> Byte corruption: 1.4% (17/1200) on the first 4-pattern frame
     -- matches the FlexIO/ObjectFLED noise floor on the same rig.

DMA progression confirmed via CITER snapshots (in earlier diagnostic
revs): CITER decrements smoothly from BITER=1200 to 0 within ~3 ms
at 4 Mbps, then the major-loop ISR fires and resets CITER back to
BITER and sets sLpDmaComplete = true.

Still TODO: the autoresearch RPC sometimes times out after 2 TX
frames before the test framework collects results. The TX driver
itself completes cleanly each time -- the hang is in the test
harness's between-pattern handoff, not in the LPUART path.

* fix(lpuart): refactor engine, ws2812b-v5 reset=150us, add yield()

- Replace function-local static CachedInstance with proper member
  state (mInstance, mCurrentPin, mCurrentRawBytes, mCurrentTiming)
  mirroring ChannelEngineFlexIO's per-engine cache pattern.
- Add yield() after each show() so the USB-CDC RPC stack can flush
  responses; without it the autoresearch test pipeline stalls.
- Per user note: ws2812b-v5 datasheet specifies 150 us reset/latch,
  not the 280 us we had hard-coded. Update TIMING_WS2812B_MINI_V3
  (which TIMING_WS2812B_V5 aliases). The longer 280 us was a
  conservative carry-over from older WS2812 variants.

* fix(lpuart): audit pin map against Teensyduino HardwareSerial sources

Audited every entry in kLpuartPins[] against the matching
UARTn_Hardware struct in Teensyduino's HardwareSerial[1-7].cpp and
the IOMUXC_SW_MUX_CTL_PAD_GPIO_* offsets in imxrt.h. Found 6 of 7
entries had wrong mux_offset/pad_offset/select_input_value -- only
pin 8 was correct, which is why the bench rig works there but other
pins would have silently driven the wrong pad.

Corrected (all entries verified for Teensy 4.0):
  pin  1 -> LPUART6 TX, GPIO_AD_B0_12 (mux 0x0EC),  SELECT_INPUT=1
  pin  8 -> LPUART4 TX, GPIO_B1_00    (mux 0x17C),  SELECT_INPUT=2
  pin 14 -> LPUART2 TX, GPIO_AD_B1_02 (mux 0x104),  SELECT_INPUT=1
  pin 17 -> LPUART3 TX, GPIO_AD_B1_06 (mux 0x114),  SELECT_INPUT=0
  pin 20 -> LPUART8 TX, GPIO_AD_B1_10 (mux 0x124),  SELECT_INPUT=1
  pin 24 -> LPUART1 TX, GPIO_AD_B0_13 (mux 0x0F0),  no SELECT_INPUT
  pin 29 -> LPUART7 TX, GPIO_EMC_31   (mux 0x090),  SELECT_INPUT=1

Also revert WS2812B_V5 RESET back to 280 us per user follow-up.

Strip debug Serial.printf from engine + driver. Engine kept member-
state refactor (mInstance/mCurrentPin/mCurrentRawBytes) + yield()
after show.

Hardware status: bench rig with pin 8 LPUART loopback to pin 22
FlexPWM RX intermittently completes the 4-pattern test at the
~1% byte corruption noise floor matching FlexIO/ObjectFLED. Some
runs RPC-timeout downstream of the engine show() -- the LPUART TX
itself completes cleanly each time per the diagnostic snapshots.

* fix(autoresearch): LPUART takes the UART-decode path

In examples/AutoResearch/AutoResearchTest.cpp `is_uart_driver` was
narrowly checking `driver_name == "UART"`. The LPUART driver
emits a wave8-encoded 4 Mbps signal whose wire shape is functionally
identical to the existing UART path -- T0H=250 ns, T1H=750 ns,
T1L=500 ns -- so it should take the same decode branch (UART-specific
timing thresholds, 500 ms RX wait, gap_tolerance_ns=100us). Expand
the check to also match LPUART.

* fix(lpuart): address CodeRabbit review on PR #3421

5 actionable findings:

- bus_traits.h: move BusTraits<Bus::LPUART>::instancePtr() function-
  local static `gHolder` out of the header into the .cpp.hpp TU
  (per repo's no-static-in-headers rule).
- channel_engine_lpuart.h: move getName() / getCapabilities() bodies
  out of the header into the .cpp.hpp.
- channel_engine_lpuart.cpp.hpp: clear mHwInitialized/mCurrentPin/
  mCurrentRawBytes BEFORE attempting createInstance() so a failed
  create leaves the engine in a clean re-init-required state instead
  of a half-torn-down state that the next channel could inherit.
- lpuart_driver.cpp.hpp: honour reset_us. Record the previous
  frame's end-of-TC micros and stall the next show until reset_us
  has elapsed -- contractual fix per the public docstring.
- ci/autoresearch/args.py: pin-to-LPUART mapping is board-dependent
  (T4.0 vs T4.1), don't hard-code "pin 8 -> LPUART4" in help text.

Remaining CodeRabbit MAJOR finding (pin map missing pins 35/47/48
per kLPUARTTxPins contract) is T4.1-only / SD-bottom-pad coverage,
deferred to follow-up.

Verified: teensy40 AutoResearch builds clean, lpuart_encoder host
tests still 1/1 pass.

* fix(lpuart): Bus::UART specialization + remaining CodeRabbit fixes

Per user feedback:
- BusTraits<Bus::UART> specialised for Teensy 4.x to route through
  ChannelEngineLPUART. This matches the ESP32 pattern where Bus::UART
  binds to that platform's UART hardware; sketches that name
  Bus::UART work portably across both platforms.
- Bus::LPUART kept as an alias resolving to the same singleton
  instance so code that names the hardware directly still works.

CodeRabbit-flagged fixes:
- lpuart_encoder.h: replace `u8*` with `fl::span<u8, 4>` (static-
  extent span) so the 4-byte-output contract is checked at the type
  level. Call sites use `fl::span<u8, 4>{&buf[i*4], 4}`.
- lpuart_driver.cpp.hpp: reject oversize transfers instead of
  silently truncating them (was logging + truncating + returning
  success, leaving tail LEDs stale).
- lpuart_peripheral_real.cpp.hpp: return nullptr from createInstance
  if hardware init failed inside the constructor, instead of handing
  back a non-functional instance that would silently drop frames.
  Switch mTxBuffer from raw `new[]`/`delete[]` to
  `fl::unique_ptr<u8[]>` RAII.

Verified: bash test lpuart_encoder 8/8 pass; bash compile teensy40
AutoResearch clean.

* fix(lpuart): lint cleanup + single Bus::UART registration

- channel_drivers_teensy.impl.hpp: register only Bus::UART (not both
  Bus::UART and Bus::LPUART). Both resolve to the same singleton via
  the trait alias in bus_traits.h, so registering both was triggering
  the ChannelManager replace-driver path on every boot.

- lpuart_encoder.h: add IWYU pragma: private + FL_NO_EXCEPT on the
  two inline encode helpers.

- lpuart_driver.cpp.hpp: suppress BareAllocationChecker on the
  DMAChannel new/delete pair (Teensyduino DMAChannel has no
  fl smart-pointer factory).

- _build.cpp.hpp: alphabetize unity build includes (channel_engine
  before lpuart_*).

- flexio_driver.cpp.hpp: use FL_STATIC_ASSERT instead of raw
  static_assert per BannedMacrosChecker.

- third_party/object_fled/src/_build.cpp.hpp: alphabetize (ObjectFLED
  before ObjectFLEDDmaManager).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(lpuart): per-pin mux_alt + audited T4.1 entries + trim JSON-RPC

Pin map audit (per user's "Audit pin map against every Teensyduino
HardwareSerial*.cpp" blocker):
- Cross-referenced every kLpuartPins entry against the corresponding
  HardwareSerial[1-8].cpp UARTn_Hardware struct's {pin, mux_val,
  select_input_reg, select_input_value} 4-tuple.
- Added per-entry mux_alt field so the T4.1 LPUART5_TX (pin 35,
  ALT 1, not 2) doesn't get force-driven through the wrong alt.
- Added T4.1-only entries (pins 35, 47, 53) gated on
  ARDUINO_TEENSY41. Verified IOMUXC offsets against imxrt.h.
- Corrected the kLPUARTTxPins public contract: the original list
  included pin 48 (which is actually LPUART5_RX_ALT on T4.1, not
  a TX pin) and was missing pin 53 (the real T4.1 LPUART6_TX_ALT).
  Fixed list is {1, 8, 14, 17, 20, 24, 29, 35, 47, 53}.

JSON-RPC minimization (per user "json-rpc should be kept to the
minimal possible without excessive spam"):
- runSingleTestImpl: skip flexPwmRxDiagnostics and flexIoDiagnostics
  emit for LPUART tests. Both are FlexIO/FlexPWM register snapshots
  that surface nothing LPUART-relevant; LPUART status already lives
  in lpuart_read_diagnostics. Trims ~660 bytes of JSON per response.
- ScopedLogDisable scope: kept enabled for all drivers including
  LPUART (per-driver carve-out empirically worsened hangs to 0/3
  due to USB-CDC saturation from FL_WARN spam during the 4-pattern
  loop).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(autoresearch): gate FL_WARN sstream construction on log level

Resolves intermittent ~55s RPC timeout on Teensy 4 clockless tests
(LPUART, FlexIO, ObjectFLED autoresearch) when the test framework's
RPC ASYNC handler wraps execution in `fl::ScopedLogDisable`.

Root cause (marker-narrowed across this session):
`FL_WARN(...)` macro ALWAYS constructs `fl::sstream() << X` regardless
of log level -- `ScopedLogDisable` only suppresses OUTPUT inside
`log_emit`. The cumulative `fl::sstream`/`fl::string` heap alloc/free
cycles across this file's many FL_WARN sites (banner, per-run dump,
per-pattern hex dump, summary, OVERALL pass/fail) leave the Teensy 4
heap in a state where the function-exit destructor of a heap-backed
`fl::string` hangs indefinitely -- traced via Serial.println markers
to the `fl::variant<NotNullStringHolderPtr, ...>` destructor in
fl::sstream::~fl::sstream() at the close of runMultiTest.

Reproduction: ~80% of LPUART/FlexIO/ObjectFLED runs hung at exactly
`mt_pre_inner_close` marker → no `mt_dtors_done` → no
`art_after_multitest` → ~55s host timeout.

Fix: introduce `AR_FL_WARN` / `AR_FL_ERROR` macros that check
`fl::getLogLevel()` before expanding FL_WARN -- when under
ScopedLogDisable (level=NONE), the sstream is never constructed and
the heap stays clean. Sed-swept all 73 FL_WARN sites in
AutoResearchTest.cpp and 8 sites in AutoResearchHelpers.cpp.

Also gates `flexIoDiagnostics` / `flexPwmRxDiagnostics` JSON emit
to OBJECT_FLED only (their original #3343/#3410 purpose). LPUART
and FLEX_IO no longer carry that ~660-byte / 22-field JSON payload
that further compounds the heap pressure post-test.

Results (bench rig, Teensy 4.0, --lpuart --tx-pin 8 --rx-pin 22):
- LPUART:  1/5 baseline → 5/5 success (clean 0.3-2.0% noise floor)
- FlexIO:  0/5 baseline → 1-2/5 success (intermittent residual --
           likely additional heap pressure outside this file; not
           blocking since FlexIO landed via #3415 prior)
- LPUART tests now return reliable byte-corruption reports
  matching FlexIO/ObjectFLED noise floor, confirming the LPUART
  driver itself works correctly when the framework returns.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(arduino/io): ride out Teensy 4 USB-CDC DTR debounce in fl::print(ln)

Per /goal "USB-CDC DTR race" research follow-up.

Teensy 4 `Serial.operator bool()` (usb_serial.h:166-169) returns
false for a hard-coded 15ms after every DTR transition (line
discipline settle window). Without a retry on the device side, the
first messages emitted by the device after a host re-opens the
serial port are silently dropped -- the `if (!Serial) return;`
guard in fl::print/fl::println short-circuits before the debounce
clears.

Reproduction surface: autoresearch RPC reconnects for each new test
session (close → re-open). Device output during the first ~15ms
after re-open vanishes -- visible as "missing log lines between
RPC sessions" or "first FL_WARN after reconnect never arrives".

Fix: extract a small `waitForSerialReady_DtrSettle()` helper that:
  - Fast-paths the common case (Serial already true → no wait)
  - Otherwise yields in a bounded 30ms loop (2× the Teensy 4
    debounce) waiting for `Serial.operator bool()` to settle true
  - Drops the message after 30ms if host is genuinely absent

On non-Teensy Arduino platforms `Serial.operator bool()` either
always returns true (real UART) or has its own non-blocking drop
path (ESP32 HWCDC: setTxTimeoutMs(0) applied by fl::begin()), so
the 30ms bound is invisible there.

Cross-platform compile verified: teensy40 ✓, esp32dev ✓, uno ✓.
Lint clean. 338/338 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(arduino/io): extend DTR settle wait to fl::flush + fl::serial_ready

Follow-up to 6c2d12e. The DTR debounce race window doesn't only
affect fl::print/fl::println -- fl::flush and fl::serial_ready use
the same `if (!Serial) return ...` short-circuit pattern, and would
also report "host absent" during the first ~15ms after a host
re-opens the USB-CDC port on Teensy 4.

Wire both through the same `waitForSerialReady_DtrSettle()` helper
so the device-side host-presence view stays consistent across all
three paths: print, flush, and the explicit ready-check.

`fl::write_bytes` is intentionally left untouched -- it does not
gate on `Serial`, so the underlying `Serial.write` path drives its
own back-pressure / drop semantics (Teensy 4 usb_serial_write has
its own 120ms tx-buffer-wait timeout). LPC platforms are also
intentionally left untouched -- their Arduino-core USB-VCOM bridge
has different debounce semantics that aren't documented to need
the same window.

Cross-platform compile: teensy40 ✓, esp32dev ✓.
Lint clean. 338/338 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(lpc/autoresearch): document --auto-discover-pins default behavior (closes #3296)

The --auto-discover-pins flag has been the default for autoresearch
runs (default=True in ci/autoresearch/args.py:485), but the
src/platforms/arm/lpc/README.md procedure didn't mention it. Add a
note to the loopback-setup section so agents reading the README
first see the discovery default and the --no-auto-discover-pins
opt-out.

Closes #3296.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 27, 2026
… (#3426)

* feat(lpuart): wave8 encoder + Teensy 4.x real driver + host unit tests

Adds Bus::LPUART workstream A from #3023:

- src/.../drivers/lpuart/lpuart_encoder.h: header-only WS2812 -> UART
  byte encoder. 2 WS2812 bits per UART byte using TXINV semantics.
  Wire pattern per bit at 4 Mbps:
    '0' -> H L L L L  (250 ns + 1000 ns)
    '1' -> H H H L L  (750 ns + 500 ns)
  Pair-to-byte table: (0,0)->0xEF, (0,1)->0x8F, (1,0)->0xEC, (1,1)->0x8C.
- src/.../drivers/lpuart/lpuart_driver.{h,cpp.hpp}: Teensy 4.x real
  driver. Configures LPUARTn for 4 Mbps with TXINV + TDMAE, programs
  the IOMUXC pad to ALT2 + SION, allocates a 4 KB DMAMEM buffer, and
  drives eDMA from the encoded byte stream to LPUARTn_DATA.
- src/.../drivers/lpuart/lpuart_peripheral_real.cpp.hpp: ILPUARTPeripheral
  factory for Teensy 4.x. Wraps the procedural driver in the existing
  ILPUARTInstance interface that the mock in
  src/platforms/shared/mock/arm/teensy4/drivers/lpuart/ already targets.
- tests/.../drivers/lpuart/lpuart_encoder.cpp: 8 host-side unit tests
  covering all-zeros, all-ones, MSB-first ordering, palindromic
  patterns, the pair-byte table, and the wire-format invariant.

Verified:
- bash test ilpuart_peripheral: existing mock interface tests pass
- bash test lpuart_encoder: 8/8 encoder tests pass on host
- bash compile teensy40 --examples Blink: clean build on T4.0 with
  the new driver in the unity build path

Pin map (T4.0): pin 1/8/14/17/20/24/29 map to LPUART6/4/2/3/8/1/7
TX respectively. Bench-rig pin 8 reuses the existing FlexIO/ObjectFLED
loopback jumper to FlexPWM-RX pin 22.

Refs #3023

* feat(lpuart): channel engine + BusTraits registration

Add the high-level ChannelEngineLPUART (mirrors ChannelEngineFlexIO)
plus a BusTraits<Bus::LPUART> specialisation so Bus::LPUART routes
through the real Teensy 4.x driver.

- channel_engine_lpuart.{h,cpp.hpp}: engine creates one ILPUARTInstance
  per (pin, strip-length) combination, encodes raw WS2812 bytes into
  the instance buffer using lpuart_encode_byte(), and calls
  instance->show().
- bus_traits.h: standard registerWithManager() pattern.
- lpuart_driver: add lpuart_show_encoded() for callers (the engine)
  that pre-encode externally; refactor common TCD arming into
  lpuart_arm_dma().
- bus_priorities.h: Bus::LPUART defaults to priority 1 (same as FlexIO
  and ObjectFLED).

Teensy 4.0 AutoResearch builds clean. Hardware test next.

* debug(lpuart): polled-tx diagnostic confirms LPUART4 transmits

Hardware bring-up progress on Teensy 4.0:
- Init sequence runs cleanly: clock gate, BAUD config, FIFO+CTRL,
  pin mux + IOMUXC SELECT_INPUT daisy.
- LPUART4 STAT = 0xC00000 after configure -> TC+TDRE both set,
  transmitter is alive.
- Polled writes successfully push 1200 wave8 UART bytes in 10 ms
  (= ~120 kbps actual due to per-byte STAT-polling overhead, well
  short of the 4 Mbps the BAUD divisor targets but proves the
  hardware path works).
- DMA arming sequence currently never sees the major-loop ISR fire;
  next iteration adds DMA_ES + CITER snapshots to diagnose whether
  TDMAE is being honored.

Also wires --lpuart through the autoresearch driver dispatcher and
enables Bus::LPUART in the Teensy 4.x enableAllChannelDrivers list.

Hardware test reproducible: bash autoresearch teensy40 --lpuart
--tx-pin 8 --rx-pin 22 reaches LPUART firmware and emits bytes on
pin 8 (polled path). Full WS2812-rate DMA path is the remaining
work.

* feat(lpuart): hardware-verified DMA path on Teensy 4.0

Working LPUART driver path bring-up:
- Force CCM_CSCDR1 UART_CLK_SEL=PLL3_80M / UART_CLK_PODF=1 so the
  LPUART clock is 80 MHz regardless of what the Teensyduino boot
  state left CSCDR1 at. Empirical: post-boot the LPUART clock was
  24 MHz, making OSR=4/SBR=4 produce ~1.2 Mbps instead of 4 Mbps.
- Move triggerAtHardwareEvent() + attachInterrupt() out of the
  per-show arm path into lpuart_dma_init() (set once at init).
- Add LPUART transmit-complete (STAT.TC) wait after the DMA major-
  loop ISR fires, so the final byte fully drains through the FIFO
  + shift register before show_encoded() returns.

Hardware verification (bench loopback, Teensy 4.0 pin 8 -> pin 22
via FlexPWM4_SM0_A RX):

  raw_sample: H753 L499 H746 L499 H753 L499 ... H253 L999 H246 L999
  -> exactly matches wave8 4-Mbps encoding:
       '1' bit = ~750 ns HIGH + ~500 ns LOW
       '0' bit = ~250 ns HIGH + ~1000 ns LOW
  -> Byte corruption: 1.4% (17/1200) on the first 4-pattern frame
     -- matches the FlexIO/ObjectFLED noise floor on the same rig.

DMA progression confirmed via CITER snapshots (in earlier diagnostic
revs): CITER decrements smoothly from BITER=1200 to 0 within ~3 ms
at 4 Mbps, then the major-loop ISR fires and resets CITER back to
BITER and sets sLpDmaComplete = true.

Still TODO: the autoresearch RPC sometimes times out after 2 TX
frames before the test framework collects results. The TX driver
itself completes cleanly each time -- the hang is in the test
harness's between-pattern handoff, not in the LPUART path.

* fix(lpuart): refactor engine, ws2812b-v5 reset=150us, add yield()

- Replace function-local static CachedInstance with proper member
  state (mInstance, mCurrentPin, mCurrentRawBytes, mCurrentTiming)
  mirroring ChannelEngineFlexIO's per-engine cache pattern.
- Add yield() after each show() so the USB-CDC RPC stack can flush
  responses; without it the autoresearch test pipeline stalls.
- Per user note: ws2812b-v5 datasheet specifies 150 us reset/latch,
  not the 280 us we had hard-coded. Update TIMING_WS2812B_MINI_V3
  (which TIMING_WS2812B_V5 aliases). The longer 280 us was a
  conservative carry-over from older WS2812 variants.

* fix(lpuart): audit pin map against Teensyduino HardwareSerial sources

Audited every entry in kLpuartPins[] against the matching
UARTn_Hardware struct in Teensyduino's HardwareSerial[1-7].cpp and
the IOMUXC_SW_MUX_CTL_PAD_GPIO_* offsets in imxrt.h. Found 6 of 7
entries had wrong mux_offset/pad_offset/select_input_value -- only
pin 8 was correct, which is why the bench rig works there but other
pins would have silently driven the wrong pad.

Corrected (all entries verified for Teensy 4.0):
  pin  1 -> LPUART6 TX, GPIO_AD_B0_12 (mux 0x0EC),  SELECT_INPUT=1
  pin  8 -> LPUART4 TX, GPIO_B1_00    (mux 0x17C),  SELECT_INPUT=2
  pin 14 -> LPUART2 TX, GPIO_AD_B1_02 (mux 0x104),  SELECT_INPUT=1
  pin 17 -> LPUART3 TX, GPIO_AD_B1_06 (mux 0x114),  SELECT_INPUT=0
  pin 20 -> LPUART8 TX, GPIO_AD_B1_10 (mux 0x124),  SELECT_INPUT=1
  pin 24 -> LPUART1 TX, GPIO_AD_B0_13 (mux 0x0F0),  no SELECT_INPUT
  pin 29 -> LPUART7 TX, GPIO_EMC_31   (mux 0x090),  SELECT_INPUT=1

Also revert WS2812B_V5 RESET back to 280 us per user follow-up.

Strip debug Serial.printf from engine + driver. Engine kept member-
state refactor (mInstance/mCurrentPin/mCurrentRawBytes) + yield()
after show.

Hardware status: bench rig with pin 8 LPUART loopback to pin 22
FlexPWM RX intermittently completes the 4-pattern test at the
~1% byte corruption noise floor matching FlexIO/ObjectFLED. Some
runs RPC-timeout downstream of the engine show() -- the LPUART TX
itself completes cleanly each time per the diagnostic snapshots.

* fix(autoresearch): LPUART takes the UART-decode path

In examples/AutoResearch/AutoResearchTest.cpp `is_uart_driver` was
narrowly checking `driver_name == "UART"`. The LPUART driver
emits a wave8-encoded 4 Mbps signal whose wire shape is functionally
identical to the existing UART path -- T0H=250 ns, T1H=750 ns,
T1L=500 ns -- so it should take the same decode branch (UART-specific
timing thresholds, 500 ms RX wait, gap_tolerance_ns=100us). Expand
the check to also match LPUART.

* fix(lpuart): address CodeRabbit review on PR #3421

5 actionable findings:

- bus_traits.h: move BusTraits<Bus::LPUART>::instancePtr() function-
  local static `gHolder` out of the header into the .cpp.hpp TU
  (per repo's no-static-in-headers rule).
- channel_engine_lpuart.h: move getName() / getCapabilities() bodies
  out of the header into the .cpp.hpp.
- channel_engine_lpuart.cpp.hpp: clear mHwInitialized/mCurrentPin/
  mCurrentRawBytes BEFORE attempting createInstance() so a failed
  create leaves the engine in a clean re-init-required state instead
  of a half-torn-down state that the next channel could inherit.
- lpuart_driver.cpp.hpp: honour reset_us. Record the previous
  frame's end-of-TC micros and stall the next show until reset_us
  has elapsed -- contractual fix per the public docstring.
- ci/autoresearch/args.py: pin-to-LPUART mapping is board-dependent
  (T4.0 vs T4.1), don't hard-code "pin 8 -> LPUART4" in help text.

Remaining CodeRabbit MAJOR finding (pin map missing pins 35/47/48
per kLPUARTTxPins contract) is T4.1-only / SD-bottom-pad coverage,
deferred to follow-up.

Verified: teensy40 AutoResearch builds clean, lpuart_encoder host
tests still 1/1 pass.

* fix(lpuart): Bus::UART specialization + remaining CodeRabbit fixes

Per user feedback:
- BusTraits<Bus::UART> specialised for Teensy 4.x to route through
  ChannelEngineLPUART. This matches the ESP32 pattern where Bus::UART
  binds to that platform's UART hardware; sketches that name
  Bus::UART work portably across both platforms.
- Bus::LPUART kept as an alias resolving to the same singleton
  instance so code that names the hardware directly still works.

CodeRabbit-flagged fixes:
- lpuart_encoder.h: replace `u8*` with `fl::span<u8, 4>` (static-
  extent span) so the 4-byte-output contract is checked at the type
  level. Call sites use `fl::span<u8, 4>{&buf[i*4], 4}`.
- lpuart_driver.cpp.hpp: reject oversize transfers instead of
  silently truncating them (was logging + truncating + returning
  success, leaving tail LEDs stale).
- lpuart_peripheral_real.cpp.hpp: return nullptr from createInstance
  if hardware init failed inside the constructor, instead of handing
  back a non-functional instance that would silently drop frames.
  Switch mTxBuffer from raw `new[]`/`delete[]` to
  `fl::unique_ptr<u8[]>` RAII.

Verified: bash test lpuart_encoder 8/8 pass; bash compile teensy40
AutoResearch clean.

* fix(lpuart): lint cleanup + single Bus::UART registration

- channel_drivers_teensy.impl.hpp: register only Bus::UART (not both
  Bus::UART and Bus::LPUART). Both resolve to the same singleton via
  the trait alias in bus_traits.h, so registering both was triggering
  the ChannelManager replace-driver path on every boot.

- lpuart_encoder.h: add IWYU pragma: private + FL_NO_EXCEPT on the
  two inline encode helpers.

- lpuart_driver.cpp.hpp: suppress BareAllocationChecker on the
  DMAChannel new/delete pair (Teensyduino DMAChannel has no
  fl smart-pointer factory).

- _build.cpp.hpp: alphabetize unity build includes (channel_engine
  before lpuart_*).

- flexio_driver.cpp.hpp: use FL_STATIC_ASSERT instead of raw
  static_assert per BannedMacrosChecker.

- third_party/object_fled/src/_build.cpp.hpp: alphabetize (ObjectFLED
  before ObjectFLEDDmaManager).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(lpuart): per-pin mux_alt + audited T4.1 entries + trim JSON-RPC

Pin map audit (per user's "Audit pin map against every Teensyduino
HardwareSerial*.cpp" blocker):
- Cross-referenced every kLpuartPins entry against the corresponding
  HardwareSerial[1-8].cpp UARTn_Hardware struct's {pin, mux_val,
  select_input_reg, select_input_value} 4-tuple.
- Added per-entry mux_alt field so the T4.1 LPUART5_TX (pin 35,
  ALT 1, not 2) doesn't get force-driven through the wrong alt.
- Added T4.1-only entries (pins 35, 47, 53) gated on
  ARDUINO_TEENSY41. Verified IOMUXC offsets against imxrt.h.
- Corrected the kLPUARTTxPins public contract: the original list
  included pin 48 (which is actually LPUART5_RX_ALT on T4.1, not
  a TX pin) and was missing pin 53 (the real T4.1 LPUART6_TX_ALT).
  Fixed list is {1, 8, 14, 17, 20, 24, 29, 35, 47, 53}.

JSON-RPC minimization (per user "json-rpc should be kept to the
minimal possible without excessive spam"):
- runSingleTestImpl: skip flexPwmRxDiagnostics and flexIoDiagnostics
  emit for LPUART tests. Both are FlexIO/FlexPWM register snapshots
  that surface nothing LPUART-relevant; LPUART status already lives
  in lpuart_read_diagnostics. Trims ~660 bytes of JSON per response.
- ScopedLogDisable scope: kept enabled for all drivers including
  LPUART (per-driver carve-out empirically worsened hangs to 0/3
  due to USB-CDC saturation from FL_WARN spam during the 4-pattern
  loop).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(autoresearch): gate FL_WARN sstream construction on log level

Resolves intermittent ~55s RPC timeout on Teensy 4 clockless tests
(LPUART, FlexIO, ObjectFLED autoresearch) when the test framework's
RPC ASYNC handler wraps execution in `fl::ScopedLogDisable`.

Root cause (marker-narrowed across this session):
`FL_WARN(...)` macro ALWAYS constructs `fl::sstream() << X` regardless
of log level -- `ScopedLogDisable` only suppresses OUTPUT inside
`log_emit`. The cumulative `fl::sstream`/`fl::string` heap alloc/free
cycles across this file's many FL_WARN sites (banner, per-run dump,
per-pattern hex dump, summary, OVERALL pass/fail) leave the Teensy 4
heap in a state where the function-exit destructor of a heap-backed
`fl::string` hangs indefinitely -- traced via Serial.println markers
to the `fl::variant<NotNullStringHolderPtr, ...>` destructor in
fl::sstream::~fl::sstream() at the close of runMultiTest.

Reproduction: ~80% of LPUART/FlexIO/ObjectFLED runs hung at exactly
`mt_pre_inner_close` marker → no `mt_dtors_done` → no
`art_after_multitest` → ~55s host timeout.

Fix: introduce `AR_FL_WARN` / `AR_FL_ERROR` macros that check
`fl::getLogLevel()` before expanding FL_WARN -- when under
ScopedLogDisable (level=NONE), the sstream is never constructed and
the heap stays clean. Sed-swept all 73 FL_WARN sites in
AutoResearchTest.cpp and 8 sites in AutoResearchHelpers.cpp.

Also gates `flexIoDiagnostics` / `flexPwmRxDiagnostics` JSON emit
to OBJECT_FLED only (their original #3343/#3410 purpose). LPUART
and FLEX_IO no longer carry that ~660-byte / 22-field JSON payload
that further compounds the heap pressure post-test.

Results (bench rig, Teensy 4.0, --lpuart --tx-pin 8 --rx-pin 22):
- LPUART:  1/5 baseline → 5/5 success (clean 0.3-2.0% noise floor)
- FlexIO:  0/5 baseline → 1-2/5 success (intermittent residual --
           likely additional heap pressure outside this file; not
           blocking since FlexIO landed via #3415 prior)
- LPUART tests now return reliable byte-corruption reports
  matching FlexIO/ObjectFLED noise floor, confirming the LPUART
  driver itself works correctly when the framework returns.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(arduino/io): ride out Teensy 4 USB-CDC DTR debounce in fl::print(ln)

Per /goal "USB-CDC DTR race" research follow-up.

Teensy 4 `Serial.operator bool()` (usb_serial.h:166-169) returns
false for a hard-coded 15ms after every DTR transition (line
discipline settle window). Without a retry on the device side, the
first messages emitted by the device after a host re-opens the
serial port are silently dropped -- the `if (!Serial) return;`
guard in fl::print/fl::println short-circuits before the debounce
clears.

Reproduction surface: autoresearch RPC reconnects for each new test
session (close → re-open). Device output during the first ~15ms
after re-open vanishes -- visible as "missing log lines between
RPC sessions" or "first FL_WARN after reconnect never arrives".

Fix: extract a small `waitForSerialReady_DtrSettle()` helper that:
  - Fast-paths the common case (Serial already true → no wait)
  - Otherwise yields in a bounded 30ms loop (2× the Teensy 4
    debounce) waiting for `Serial.operator bool()` to settle true
  - Drops the message after 30ms if host is genuinely absent

On non-Teensy Arduino platforms `Serial.operator bool()` either
always returns true (real UART) or has its own non-blocking drop
path (ESP32 HWCDC: setTxTimeoutMs(0) applied by fl::begin()), so
the 30ms bound is invisible there.

Cross-platform compile verified: teensy40 ✓, esp32dev ✓, uno ✓.
Lint clean. 338/338 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(arduino/io): extend DTR settle wait to fl::flush + fl::serial_ready

Follow-up to 6c2d12e. The DTR debounce race window doesn't only
affect fl::print/fl::println -- fl::flush and fl::serial_ready use
the same `if (!Serial) return ...` short-circuit pattern, and would
also report "host absent" during the first ~15ms after a host
re-opens the USB-CDC port on Teensy 4.

Wire both through the same `waitForSerialReady_DtrSettle()` helper
so the device-side host-presence view stays consistent across all
three paths: print, flush, and the explicit ready-check.

`fl::write_bytes` is intentionally left untouched -- it does not
gate on `Serial`, so the underlying `Serial.write` path drives its
own back-pressure / drop semantics (Teensy 4 usb_serial_write has
its own 120ms tx-buffer-wait timeout). LPC platforms are also
intentionally left untouched -- their Arduino-core USB-VCOM bridge
has different debounce semantics that aren't documented to need
the same window.

Cross-platform compile: teensy40 ✓, esp32dev ✓.
Lint clean. 338/338 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(lpc/autoresearch): document --auto-discover-pins default behavior (closes #3296)

The --auto-discover-pins flag has been the default for autoresearch
runs (default=True in ci/autoresearch/args.py:485), but the
src/platforms/arm/lpc/README.md procedure didn't mention it. Add a
note to the loopback-setup section so agents reading the README
first see the discovery default and the --no-auto-discover-pins
opt-out.

Closes #3296.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(simd/arm-dsp): wire UXTB16/PKHBT/PKHTB/USAT16/SEL ops (refs #3425)

Promotes the remaining 🟢 (high-ROI) ops from scalar fallback to
Cortex-M DSP-ext intrinsics in src/platforms/arm/teensy/simd_arm_dsp.hpp.
Each was added one-at-a-time and validated via the device-side SIMD
self-test suite (85/85 passing after every op):

- **avg_round_u8_16** — rounded average via UHADD8 NOT-trick:
  per byte `(a+b+1)>>1` = `~UHADD8(~a, ~b)`. 4 DSP ops + 4 NOT vs 16-iter
  scalar widening loop. Replaces the (a + b + 1) >> 1 reference path.

- **widen_lo_u8_to_u16 / widen_hi_u8_to_u16** — zero-extend 8 bytes to
  8 halfwords via UXTB16 (bytes 0,2) + UXTB16 ROR #8 (bytes 1,3) +
  PKHBT/PKHTB to re-pack lanes into sequential halfword order. 4 DSP
  ops per pair of output u32 words vs 8 LDRB+STRH scalar pairs.

- **narrow_u16_to_u8** — USAT16 #8 saturates two halfwords to [0,255]
  in one DSP op; scalar mask+shift then packs 4 halfword-LSBs into one
  output u32 byte-aligned. Replaces the per-lane `> 255 ? 255 : value`
  branch sequence.

- **min_u8_16 / max_u8_16** — USUB8 sets APSR.GE[3:0] per byte from the
  unsigned-subtract result; SEL picks the matching byte. 2 DSP ops per
  4 bytes vs 16 conditional moves. Marked `"cc"` clobber so the
  compiler can't reorder SEL ahead of USUB8 (GE flags are the only
  data-dependency carrier).

All u8x32 / u16x16 ops in this file delegate to the u8x16 / u16x8
variants above, so they pick up the DSP acceleration automatically
(avg_round_u8_32, widen_lo_u8x32_to_u16, widen_hi_u8x32_to_u16,
narrow_u16x16_to_u8).

Deferred to a follow-up (🟡 ops): scale_u8_16, blend_u8_16, mullo_u16_8
-- the PKHBT/UXTB16/SMUAD chains needed for the multiply-then-narrow
fused ops are more code than win-per-op until a specific hot path
demands them.

Verification: `bash autoresearch teensy40 --simd --skip-lint` reports
85/85 SIMD tests passing after each individual op was added (per
issue #3425's one-at-a-time mandate). Bit-exact against the noop
reference. Compile clean on teensy40 (Cortex-M7) and esp32dev (gates
correctly through __ARM_FEATURE_DSP).

Closes #3425 (🟢 ops portion).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant