Skip to content

feat(rx): FlexIO RX hardware programming (Phase 1B of #2764) - #2766

Merged
zackees merged 1 commit into
masterfrom
feat/flexio-rx-backend-hardware
Jun 5, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/flexio-rx-backend-hardware

Conversation

@zackees

@zackees zackees commented Jun 5, 2026 •

Copy link
Copy Markdown
Member

Summary

Phase 1B of #2764 — replaces the Phase 1A skeleton (PR #2765) bodies with real FLEXIO1 register programming, IOMUXC pin muxing, and an eDMA-driven capture pipeline. The public RxDevice API is unchanged.

Capture strategy

Input-edge timing measurement, per NXP AN12686 §4 + iMXRT1062 RM chapter 50.

Resource Configuration Purpose
Timer 0 TIMOD=3 (16-bit counter), TRGSEL=2*pin+1 (external pin edge), TIMRST=trigger-rising Counter restarts on every input edge so the latched value equals the inter-edge tick count
Shifter 0 SMOD=1 (receive), TIMSEL=0, PINSEL=flexio_pin Each Timer 0 restart latches elapsed ticks into SHIFTBUF[0]
DMA DMAMUX_SOURCE_FLEXIO1_REQUEST0 → caller-sized capture buffer Streams SHIFTBUF[0] reads into RAM without CPU intervention
Clock CCM_CDCDR.FLEXIO1_CLK_SEL = PLL3_PFD3 (480 MHz), PRED=2, PODF=2 → ~120 MHz Matches FlexIO TX divider so kFlexIo1ClkMHz = 120 gives a single ns-per-tick factor across both backends

At 120 MHz functional clock, one tick = ~8.3 ns. The 16-bit timer comfortably resolves WS2812 bit cells (1.25 µs / 150 ticks) and gives σ ≪ 100 ns at the 100 kHz square-wave target from Phase 2.

Pin map

static const FlexIo1PinInfo kFlexIo1Pins[] = {
    // Teensy pin 4 = GPIO_EMC_06, ALT4 = FLEXIO1_FLEXIO06
    {4, 6, (volatile u32 *)(kFlexIo1IomuxcBase + 0x002C),
           (volatile u32 *)(kFlexIo1IomuxcBase + 0x021C)},
};

Single entry intentionally — matches the GPIO 3↔4 jumper on the dev-bench Teensy 4.0 (auto-discovered by AutoResearch's findConnectedPins), so Phase 2's square-wave validation can target pin 4 immediately without further table expansion. The table is structured for trivial growth as bench validation qualifies the rest of the GPIO_EMC_* bank.

Unity-build hygiene

Two collisions surfaced when the Teensy 4 platforms unity TU pulled in both the existing FlexPWM RX driver and this new file; the FlexIO TX driver had the same kind of issue and the patterns mirror its solutions:

Collision Fix
imxrt.h already defines FLEXIO1_* macros that expand incompatibly with our typed volatile u32 * register accessors #undef FLEXIO1_CTRL/SHIFTSTAT/SHIFTCTL/... at top of file (matches flexio_driver.cpp.hpp lines 22–34 pattern for FLEXIO2)
lookupPin(int) in anonymous namespace clashes with FlexPWM RX's Renamed → lookupFlexIo1Pin(int)
kIOMUXC_BASE clashes with FlexIO TX driver's Renamed → kFlexIo1IomuxcBase

Behavioural scope

Method behaviour

Method Behaviour
begin(RxConfig) Allocates DMA channel, configures FLEXIO1 + pin pad (ALT4 + 100 kΩ pull-up keeper + hysteresis), arms DMA on DMAMUX_SOURCE_FLEXIO1_REQUEST0, enables FlexIO. Returns false if pin not in map or another channel is already active.
wait(timeout_ms) Polls mReceiveDone (set by DMA-completion ISR). Returns SUCCESS / TIMEOUT.
getRawEdgeTimes(out, offset) Walks capture buffer, converts each 16-bit tick count to ns, emits one EdgeTime{level, ns} per segment. Reusable by Phase 2's RPC.
decode(timing, out) Builds the same edge stream then returns 0 bytes — the existing FlexPWM 4-phase decoder gets re-wired through the channel layer in a follow-up (keeps this PR focused on the hardware bring-up).
injectEdges(span) For synthetic-input testing (Phase 2 host-stub + Phase 3 bench fixture).

Verification

  • ✅ Teensy 4.0 release build clean for examples/AutoResearch via fbuild
  • ✅ Host C++ tests pass (309/309)
  • ✅ C++ lint clean (bash lint --cpp)
  • ⏳ Hardware-side bench validation is Phase 2 (RPC flexioRxBenchmark against a analogWriteFrequency-generated reference signal)
  • ⏳ End-to-end ObjectFLED loopback decode is Phase 3

Refs

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Implemented complete FlexIO receiver functionality for Teensy 4.x boards with enhanced edge capture and timing measurement support.

Replaces the Phase 1A skeleton (PR #2765) bodies with real FLEXIO1 register
programming, IOMUXC pin muxing, and an eDMA-driven capture pipeline. The
public RxDevice API is unchanged.

Capture strategy (input-edge timing measurement, per NXP AN12686 §4 +
iMXRT1062 reference manual chapter 50):

  Timer 0: 16-bit counter, TRGSEL = 2*pin+1 (external pin edge), TIMRST =
           trigger-rising → counter restarts on every input edge so the
           latched value equals the inter-edge tick count. Counts at the
           FlexIO functional clock (~120 MHz on Teensy 4 → ~8.3 ns/tick).

  Shifter 0: receive mode (SMOD=1), TIMSEL=0, PINSEL=N. Each Timer 0
             restart latches the elapsed ticks into SHIFTBUF[0].

  DMAMUX_SOURCE_FLEXIO1_REQUEST0 → eDMA streams SHIFTBUF[0] reads into a
  user-sized capture buffer (default 1024 deltas, capped at 4096).

Pin-map (`kFlexIo1Pins[]`): initial entry for Teensy pin 4 (GPIO_EMC_06 →
FLEXIO1_FLEXIO06 via ALT4) — this matches the GPIO 3↔4 jumper on the dev
bench so Phase 2's square-wave validation can target pin 4 immediately.
The table is set up for trivial expansion as bench tests qualify the rest
of the GPIO_EMC_* bank.

Clock-gate setup: enables FLEXIO1 via CCM_CCGR5_FLEXIO1, divides PLL3_PFD3
(480 MHz) by PRED=2 / PODF=2 → ~120 MHz to match the FlexIO TX driver's
divider. This keeps the ns-per-tick conversion identical across both
backends.

`begin()` allocates the DMA channel, configures FLEXIO1 + the pin pad
(ALT4 + 100 kΩ pull-up keeper + hysteresis for clean edge detection),
arms the DMA, and enables the FlexIO module.

`wait()` polls `mReceiveDone` (set by the DMA-completion ISR) with the
caller-provided timeout. `decode()` walks the capture buffer, converts each
16-bit tick count to nanoseconds, and emits one `EdgeTime{level, ns}` per
segment. `getRawEdgeTimes()` exposes the same edge stream to callers (e.g.
the AutoResearch RPC) that prefer raw access.

Unity-build hygiene:
- `#undef FLEXIO1_*` macros from imxrt.h before declaring our typed
  register accessors (same pattern as the FlexIO TX driver does for
  FLEXIO2).
- `lookupPin()` renamed to `lookupFlexIo1Pin()` and `kIOMUXC_BASE` renamed
  to `kFlexIo1IomuxcBase` so anonymous-namespace symbols don't collide
  with the FlexPWM RX driver (same translation unit in the platforms+ TU).

Behavioural scope:
- `RxBackend::PLATFORM_DEFAULT` on Teensy 4.x deliberately STILL resolves
  to FLEXPWM per the #2764 plan — the default switch waits for Phase 3
  end-to-end verification.
- All capture decisions go through the existing `RxDevice` interface, so
  no consumer needs to change.

Verification:
- ✅ Teensy 4.0 release build clean for `examples/AutoResearch`
- ✅ Host C++ tests pass (309/309)
- ✅ C++ lint clean (`bash lint --cpp`)
- ⏳ Hardware-side bench validation is Phase 2 (RPC `flexioRxBenchmark`)
- ⏳ End-to-end ObjectFLED loopback decode is Phase 3

Refs #2764

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

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 97834b22-acee-4ff4-adad-053b55f2c640

📥 Commits

Reviewing files that changed from the base of the PR and between 3b8838f and f805cdd.

📒 Files selected for processing (1)
  • src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp

📝 Walkthrough

Walkthrough

This change completes Teensy 4.x FlexIO RX Phase 1B by implementing hardware capture using FLEXIO1 timer/shifter registers and eDMA. It adds pin mapping, clock/pad initialization, register programming, DMA lifecycle management, and converts captured tick deltas into edge-time segments for downstream decode.

Changes

FlexIO RX Phase 1B Hardware Capture

Layer / File(s) Summary
Documentation, includes, and macro setup
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp (lines 2–45, 60–85)
File documentation updated from Phase 1A skeleton to Phase 1B plan; required C++ standard/result/DMA/imxrt headers added; conflicting FLEXIO1_* macros undefined to enable typed register access in this header.
FLEXIO1 hardware contracts and setup helpers
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp (lines 90–284)
FLEXIO1 register layout constants introduced; Teensy 4.x→FLEXIO1 pin mapping table and lookup helper established; flexio1_clock_init() gates FLEXIO1 and sets divider; flexio1_iomuxc_pad_init() configures ALT4 muxing with pull/keeper/hysteresis; flexio1_configure() software-resets FLEXIO1, configures shifter 0 in receive mode with timer 0 edge-triggered 16-bit counting, enables shifter DMA request, and gates the FLEXIO module.
Class state, lifecycle, and DMA interrupt management
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp (lines 290–344)
Destructor now calls stopHw() to shut down hardware and DMA on destruction; new member variables track pin info, DMA descriptors, capture buffers, sizes, completion flags, and cached edges; static instance guard enforces single active FLEXIO1 channel; stopHw() disables DMA and clears FLEXIO1 state; DMA completion ISR marks receive complete.
Initialization and DMA capture startup
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp (lines 346–395)
begin() validates the requested pin against the FLEXIO1 mux table, enforces single active channel via static guard, applies RxConfig settings, allocates and sizes a ring-buffer capture region, calls setup helpers to initialize clocks/pins/registers, configures DMA with SHIFTBUF[0] as source, RAM buffer as destination, shifter interrupt as trigger, and starts the DMA channel.
Capture completion polling and tick-delta-to-edge-time conversion
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp (lines 397–439)
finished() returns DMA completion status; wait() spins with configurable timeout; buildEdgeTimesFromCaptures() translates captured tick deltas from the DMA buffer into alternating EdgeTime segments using a computed ns-per-tick conversion factor and idle-level-derived starting polarity, then caches the result.
Edge access and decode interface
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp (lines 441–476)
decode() builds edge times from DMA captures and returns success with zero decoded bytes; getRawEdgeTimes() returns a bounded slice of cached edges; injectEdges() replaces the edge buffer with injected edges, marks them valid, and forces completion.
Factory pin validation
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp (lines 483–492)
FlexIoRxChannel::create(int pin) validates the requested pin against the FLEXIO1 mux table and returns an empty shared_ptr with a warning log when unmapped.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

  • FastLED/FastLED#2764: The main change implements the Teensy 4.x FlexIO RX backend described in this hardware driver tracking issue, with timer/shifter capture, eDMA plumbing, and edge-time pipeline.

Possibly related PRs

  • FastLED/FastLED#2765: Phase 1B replaces Phase 1A by implementing actual DMA capture and edge-time conversion in the same rx_flexio_channel.cpp.hpp header, moving from skeleton stubs to working hardware integration.

Poem

🐰 A rabbit hops through silicon dreams,
Timers and shifters now flow like streams,
DMA whispers from Teensy's heart,
Edge times sing in each captured dart—
Phase 1B blooms, the capture's smart!

✨ 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/flexio-rx-backend-hardware

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 and usage tips.

@zackees
zackees merged commit b2934f2 into master Jun 5, 2026
6 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 5, 2026
zackees added a commit that referenced this pull request Jun 5, 2026
…#2764) (#2767)

* feat(autoresearch): flexioRxBenchmark RPC + square-wave Python harness (Phase 2 of #2764)

Adds the bench-validation surface for the FlexIO RX backend from PRs #2765
(skeleton) and #2766 (FLEXIO1 hardware programming).

Firmware side — new `flexioRxBenchmark` RPC binding in AutoResearchRemote.cpp
(Teensy 4.x only; other platforms return `PlatformNotSupported` cleanly):

  Args:
    { "frequency_hz": int = 1000,
      "duration_ms":  int = 100,
      "tx_pin":       int = 3,   // matches GPIO 3↔4 jumper
      "rx_pin":       int = 4 }

  Behavior:
    1. Drives tx_pin with a square wave via analogWriteFrequency() +
       analogWrite(pin, 128) (Teensy core PWM, 50% duty)
    2. Creates an RxChannel with backend = RxBackend::FLEXIO on rx_pin
    3. Captures for duration_ms
    4. Stops the PWM
    5. Pulls captured edges via getRawEdgeTimes() and pairs them into
       periods (period = high_segment_ns + low_segment_ns)
    6. Returns { edges_captured, periods, period_mean_ns, period_sigma_ns,
                 period_min_ns, period_max_ns }

  Integer sqrt is used for σ — adequate for the Phase 2 tolerance ranges
  (σ < 100 ns at 100 kHz).

Python harness side — `ci/autoresearch/test_flexio_rx_squarewave.py`:

  Standalone pyserial-based test driver (no fbuild WebSocket daemon
  needed). Runs three cases matching the parent-issue table:

    | Frequency | Period      | σ tolerance | Mean tolerance |
    |-----------|-------------|-------------|----------------|
    | 1   kHz   | 1 000 000ns | < 1 000 ns  | ±1 %           |
    | 10  kHz   |   100 000ns | <   500 ns  | ±1 %           |
    | 100 kHz   |    10 000ns | <   100 ns  | ±1 %           |

  Exits 0 on all pass, 1 on any failure. Default port COM20 + tx/rx
  pins 3/4 match the dev-bench Teensy 4.0 setup.

Verification:
- ✅ Teensy 4.0 release build clean (`examples/AutoResearch`, ~1m 05s)
- ✅ Host C++ tests pass (309/309)
- ✅ C++ lint clean
- ⏳ Live bench-validation on the dev Teensy 4.0 lands once the firmware
     is reflashed with this RPC

Note: the firmware still has to be flashed onto the Teensy 4.0 before the
Python harness can validate the FlexIO RX capture path end-to-end. That's
a separate hardware step held out of this PR to keep the diff focused on
the software surface.

Refs #2764

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

* fix(autoresearch): address CodeRabbit review on PR #2767

Three fixes from the review:

1. **Help registry sync** (CodeRabbit minor):
   - Added `flexioRxBenchmark` to the `help()` function manifest with args,
     returns, phase, and description fields matching the binding above
   - Bumped `totalFunctions` 25 → 26 so any client that relies on `help()`
     gets the up-to-date contract

2. **Capture buffer too small at 10/100 kHz** (CodeRabbit major):
   - At 100 kHz × 100 ms the harness expects ~20 000 edges but the buffer
     was capped at 1024 — sample set was being truncated to ~5 ms.
   - `flexioRxBenchmark` now sizes `edge_capacity` from
     `2 * frequency_hz * duration_ms / 1000` with 50 % headroom, clamped
     to `[1024, 16384]` so RAM use is bounded but the requested window is
     honored.
   - Raised the matching internal cap in `rx_flexio_channel.cpp.hpp`
     `begin()` from 4096 → 16384 (64 KiB, comfortably fits 100 ms at
     100 kHz with headroom) so the channel honors the new larger requests.

3. **`sys.exit(2)` at module import** (CodeRabbit minor):
   - Moved the pyserial dependency check from the import block into
     `main()` so that test-collection (e.g. pytest on a CI runner without
     `pyserial`) doesn't abort the interpreter before the caller can
     decide to skip the hardware bench. The check now reports the same
     error and returns 2 from `main()` instead.

Verification:
- ✅ Teensy 4.0 release build clean (`examples/AutoResearch`, ~1m 10s)
- ✅ C++ lint clean
- Pyright still flags a handful of pre-existing type-narrowing warnings
  on the pyserial wrapper; left as-is since they're not from this change.

Refs #2764, PR #2767 review

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 5, 2026
…(Phase 3 of #2764) (#2769)

* feat(autoresearch): ObjectFLED -> FlexIO RX loopback + WS2812 decoder (Phase 3 of #2764)

End-to-end TX -> RX byte verification for the FlexIO RX backend landed in
PRs #2765 / #2766 / #2767. Three pieces:

1. **WS2812 bit decoder wired into FlexIO RX**
   (`src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp`)
   - Phase 1B's `decode()` returned `success(0)` as a placeholder; this PR
     replaces the body with a real edge-pair decoder that walks the captured
     `EdgeTime` stream, classifies each (HIGH, LOW) duration pair as bit 0
     or bit 1 via the `ChipsetTiming4Phase` thresholds, packs the bits into
     bytes MSB-first, and reports buffer-overflow / high-error-rate failures
     identically to the FlexPWM RX path.
   - Static helpers `decodeBitFlexIo` / `decodeEdgesFlexIo` live in the same
     TU rather than extracting to a shared header; the consolidation
     into `src/fl/channels/rx/decode_ws2812.h` is a separate refactor that
     can land after both backends are bench-validated against the same
     test matrix.

2. **`flexioObjectFledTest` RPC**
   (`examples/AutoResearch/AutoResearchRemote.cpp`)
   - Drives WS2812 frames through `Bus::OBJECT_FLED` on `tx_pin`, captures
     via `RxBackend::FLEXIO` on `rx_pin`, decodes against `TIMING_WS2812B_V5`
     4-phase timing, and returns per-byte match counts. Teensy-4-only;
     other platforms return `PlatformNotSupported` cleanly.
   - Five fixed test patterns matching the parent-issue Phase 3 table:
     0 = Red single LED, 1 = RGB three-LED chain, 2 = all zeros,
     3 = all ones, 4 = 100-LED alternating R/G/B.
   - Args: `{ test_case, tx_pin, rx_pin, capture_ms }` (all optional).
   - Returns: `{ success, test_case, tx_pin, rx_pin, num_leds,
                 expected_bytes, decoded_bytes, matched, mismatched,
                 edges_captured }`.
   - Sizes the RX edge buffer from `num_leds * 24 * 2 + 25%`, clamped to the
     16384-entry cap from PR #2767.
   - `help()` manifest updated (totalFunctions 26 -> 27) with full
     args/returns/description so any client relying on `help()` gets the
     up-to-date contract.

3. **Python harness**
   (`ci/autoresearch/test_flexio_rx_objectfled.py`)
   - Standalone pyserial driver, no fbuild daemon dependency.
   - Runs the five test cases in sequence, asserts on
     `decoded == expected && mismatched == 0`, prints PASS/FAIL per case.
   - Same `pyserial`-import-deferred-to-main() pattern from PR #2767 review.
   - Exits 0 on all pass, 1 on any failure.

Compile-side fixups during bring-up (visible in commit diff):
- `fl::ClearFlags::CHANNELS` -> `ClearFlags::CHANNELS` (global enum, not in `fl::`)
- `NamedTimingConfig{resolved_timing, name, encoder}` wrapper around
  `makeTimingConfig<>()` for the TX path; `to_runtime_timing<>()` for the
  RX 4-phase converter
- `fl::span<T>(container)` constructor instead of pointer-pair form
  (fixes the SpanFromPointerChecker hit on the decoder edge stream)

Verification:
- Host C++ tests pass (309/309)
- C++ lint clean
- Teensy 4.0 release build clean for `examples/AutoResearch`
- Hardware-side end-to-end run is the next step — once the firmware is
  flashed to the dev-bench Teensy 4.0, the harness asserts each case in
  under 1 s

Refs #2764

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

* fix(autoresearch): address CodeRabbit review on PR #2769

Three fixes from the Phase 3 review:

1. **TX-completion margin** (CodeRabbit major):
   `capture_ms` allows values down to 1 ms, but for case 4 (100 LEDs) the
   WS2812 transmission alone takes ~3 ms (24 bits × 1.25 µs × 100 + reset).
   If the caller passed a short capture_ms, `FastLED.clear(CHANNELS)` could
   tear the channel down mid-frame and leave hardware in a bad state.

   `flexioObjectFledTest` now computes a minimum capture window from the
   actual WS2812 timing:
     ws2812_tx_us = num_leds * 24 * 1.25 + 100 (reset gap)
     min_capture_ms = ceil(ws2812_tx_us / 1000) + 10
   …and uses `max(caller_capture_ms, min_capture_ms)` for the RX wait.
   At 100 LEDs that's ~13 ms minimum; the caller can still request
   larger windows for noisy environments.

2. **`totalFunctions` stale** (CodeRabbit minor):
   The help() manifest had 28 functions.push_back() calls but
   `totalFunctions` was still 27 (off-by-one — `wave8ExpandBenchmark_fn`
   was added between Phase 2 and Phase 3 and I missed it). Bumped to 28
   so clients relying on `help().totalFunctions` get an accurate count.

3. **Python `main()` testability + Ctrl-C handling**
   (CodeRabbit refactor suggestions):
   - `main()` now accepts an optional `argv: list[str] | None` parameter
     so unit tests can inject argument lists without touching `sys.argv`.
     `argparse.parse_args(argv)` interprets None as "use sys.argv[1:]" so
     CLI behavior is unchanged.
   - The serial-open `try/except` block now catches `KeyboardInterrupt`
     before `SerialException`, so interactive users can Ctrl-C out of
     the harness without dumping a stack trace.

The remaining CodeRabbit Python suggestions (add runtime type validation
to the dataclass, remove default values from send_rpc, return a dataclass
from evaluate() instead of a tuple) are intentionally not adopted — they
are pure-style refactors and the existing patterns match
test_flexio_rx_squarewave.py and ci/precheck_pins.py for consistency
across the autoresearch harness.

Verification:
- ✅ Teensy 4.0 release build clean
- ✅ C++ lint clean

Refs #2764, PR #2769 review

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

* fix(autoresearch): Python @TypeChecked + EvaluationResult dataclass (PR #2769 review)

Two CodeRabbit-flagged repo coding-guideline conformances on the Phase 3
Python harness:

1. `@typechecked` on the `@dataclass TestCase` (per repo guideline
   "Use @TypeChecked decorator with @DataClass for runtime type validation").
2. `evaluate()` now returns a typed `EvaluationResult` dataclass with `ok`
   and `message` fields, replacing the previous `(bool, str)` tuple (per
   repo guideline "Return dataclass structs instead of tuples or dicts for
   functions with multiple return values"). Callsite in `main()` updated
   to read `result.ok` / `result.message`.

Both changes are pure-additive — same call shape, same RPC contract,
same CLI behavior.

Refs #2764, PR #2769 review

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 5, 2026
… 4 of #2764) (#2770)

* docs(rx/flexio): FlexIO RX backend docs + enum-comment refresh (Phase 4 of #2764)

Final phase of #2764 — documents the new FlexIO RX backend now that
the skeleton (#2765), hardware (#2766), bench harness (#2767), and
ObjectFLED loopback (#2769) have all landed on master.

Three changes, all documentation-side; no runtime behaviour changes:

1. `src/fl/channels/rx/types.h`:
   - `RxBackend::PLATFORM_DEFAULT` comment now mentions FLEXIO as an opt-in
     alternative on Teensy 4 with a pointer to #2764.
   - `RxBackend::FLEXIO` comment notes that hardware verification ran via
     `flexioRxBenchmark` (1/10/100 kHz square wave) and
     `flexioObjectFledTest` (5-pattern ObjectFLED loopback).

2. `src/fl/channels/rx.h`:
   - Matching `RxDeviceType::PLATFORM_DEFAULT` comment refreshed.

3. `agents/docs/hardware-autoresearch.md`:
   - New top-level section "FlexIO RX Backend (Teensy 4 — opt-in)" covering:
     * How to select the backend in C++ and Python
     * Pin map (Teensy pin -> FLEXIO1 input -> IOMUXC offsets)
     * Peripheral resource budget (Shifter 0, Timer 0, DMA, FLEXIO1
       functional clock)
     * Verification surface (flexioRxBenchmark + flexioObjectFledTest with
       acceptance criteria)
     * Explicit note that `PLATFORM_DEFAULT` stays on FlexPWM until the
       follow-up default-switch PR

Intentionally NOT in this PR (per the #2764 parent-issue plan):
- Switching `PLATFORM_DEFAULT` to FLEXIO on Teensy 4 — separate PR after
  both backends are equally exercised in the dev-bench matrix.
- Adding `bash autoresearch teensy40 --rx-backend=flexio` to the nightly
  hardware test matrix — gated on the Teensy 4.1 RTV-silicone hardware
  issue (#2760) being resolved.

Verification:
- ✅ C++ lint clean
- Docs-only changes; no host-test regressions possible

Refs #2764

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

* fix(autoresearch): KBI002 — route KeyboardInterrupt through project handler

PR #2769 introduced a `try/except KeyboardInterrupt` block on the serial-open
path of `test_flexio_rx_objectfled.py` that re-raised the signal directly.
The project-wide KBI002 lint requires that KeyboardInterrupt handlers either
call `_thread.interrupt_main()` or route through
`handle_keyboard_interrupt(ki)` from `ci.util.global_interrupt_handler`.

Importing the helper and calling it before the re-raise keeps the original
abort-without-stack-trace UX while satisfying the lint check.

The KBI002 violation was surfaced by the post-stop hook on the Phase 4
branch, which lints the master state pulled into the docs branch.

Refs #2764, PR #2769 review

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/flexio-rx-backend-hardware branch August 21, 2026 19:15
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