Skip to content

fix(teensy4/flexio-rx): set SION + add flexioRxLoopbackPing RPC (refs #3066 phase 1.7) - #3069

Merged
zackees merged 1 commit into
masterfrom
fix/3066-iter5-sion-and-loopback-ping
Jun 15, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/3066-iter5-sion-and-loopback-ping

Conversation

@zackees

@zackees zackees commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Loop iter 5 of #3066. Two device-side changes:

  1. SION bit on pad MUX (necessary, not sufficient). Original flexio1_pin_init() wrote ALT4 alone; without SION the IOMUX doesn't force the input path through to the peripheral. The working FlexPWM RX driver sets SION the same way (rx_flexpwm_channel.cpp.hpp:405). Verified by FLEXIO1_PIN readback at the correct offset 0x00C (NOT 0x040 which the iter 5 first attempt mistakenly used):

    pre-fix:  FLEXIO1 PIN=0x0   (FlexIO sees nothing on pin 4)
    post-fix: FLEXIO1 PIN=0x40  (bit 6 set = pin 4 pulled up ✓)
    
  2. New flexioRxLoopbackPing RPC. Hand-drives tx_pin via digitalWrite while FlexIO RX is armed on rx_pin. Decisively distinguishes 'IOMUX routing broken' from 'shifter/timer wrong' without any clockless driver in the loop.

What this does NOT fix yet

Captures still come back all zero — IOMUX routing now works end-to-end (verified by FLEXIO1_PIN bit 6 tracking the pull-up), but the shifter/timer chain has a separate bug (the iter 3 TIMENA-doesn't-engage-trigger puzzle). That's the active blocker for iter 6+.

Live validation

[FlexIO RX] post-pin-init: pin=4 flexio_pin=6 mux_reg=0x14 pad_reg=0x1b000
[FlexIO RX] FLEXIO1 PIN=0x40 (expect bit 6 to track pad) ← was 0x0 pre-SION

Refs #3066

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added loopback ping test with edge timing capture and reporting for Teensy 4.x platforms.
  • Tests

    • Enhanced input pin initialization diagnostics with register verification and additional logging.

…g RPC (refs #3066 phase 1.7)

Two device-side changes from #3066 loop iter 5:

1. **SION bit on pad MUX (necessary, not sufficient).** The original
   flexio1_pin_init() wrote ALT4 (=4) to the pad mux but missed the
   SION bit (0x10). Without SION the IOMUX doesn't force the input
   path through to the peripheral when the pad selects an alt
   function. The working FlexPWM RX driver sets it the same way
   (rx_flexpwm_channel.cpp.hpp:405). Fixed by OR-ing 0x10:

     *(pin_info.mux_reg) = 4 | 0x10;   // ALT4 + SION

   Verified by reading FLEXIO1_PIN (offset 0x00C, NOT 0x040 — the
   earlier iter 5 diagnostic used the wrong offset):

     pre-fix:  FLEXIO1 PIN=0x0   (FlexIO sees nothing on pin 4)
     post-fix: FLEXIO1 PIN=0x40  (bit 6 set = pin 4 pulled up ✓)

   The IOMUX routing now works end-to-end. Captures are still zero
   because the shifter/timer chain has a separate bug (the iter 3
   TIMENA-doesn't-engage-trigger puzzle); that's the active blocker
   for iter 6+.

2. **New flexioRxLoopbackPing RPC.** Hand-drives tx_pin via
   digitalWrite while FlexIO RX is armed on rx_pin, then reads the
   captured edges. Decisively distinguishes 'IOMUX routing broken' from
   'shifter/timer wrong' without any clockless driver in the loop.

     {tx_pin?: 3, rx_pin?: 4, toggle_us?: 50, edges?: 8}
     → { success, edges_captured, first_edges: [{high, ns}, ...] }

Also moves the FLEXIO1_PIN diagnostic from the wrong offset 0x040 to
the correct 0x00C, and adds an IOMUX register read-back so future
iterations can verify pad config on the wire instead of guessing.

Refs #3066

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

coderabbitai Bot commented Jun 15, 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: 4478c3d1-7a68-45eb-a7f1-cfae70742bd7

📥 Commits

Reviewing files that changed from the base of the PR and between 789724c and 3f852fc.

📒 Files selected for processing (2)
  • examples/AutoResearch/AutoResearchRemote.cpp
  • src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp

📝 Walkthrough

Walkthrough

flexio1_pin_init() is updated to OR the IOMUXC SION bit into the ALT4 mux register and adds FL_WARN diagnostics that read back the mux/pad registers and the FLEXIO1 PIN status register. A new Teensy-4-only RPC flexioRxLoopbackPing is registered in AutoResearchRemoteControl, which drives a TX square wave and captures edges via RxBackend::FLEXIO, returning captured edge count and a diagnostic JSON array of the first eight edges.

Changes

FLEXIO RX Loopback Diagnostics

Layer / File(s) Summary
flexio1_pin_init SION bit + diagnostics
src/platforms/arm/teensy/teensy4_common/rx_flexio_channel.cpp.hpp
flexio1_pin_init() now writes ALT4 | SION to the mux register and adds post-write FL_WARN log statements that read back the mux/pad register values and the FLEXIO1 PIN status bit for the configured input pin.
flexioRxLoopbackPing RPC handler
examples/AutoResearch/AutoResearchRemote.cpp
New Teensy-4-only RPC parses tx_pin, rx_pin, toggle_us, edges params, validates edges range, arms a RxBackend::FLEXIO channel, drives a manual HIGH/LOW square wave on tx_pin, flushes, reads raw captured edge times, and returns edge count plus first-8-edge JSON diagnostics.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#2766: Shares the rx_flexio_channel.cpp.hpp file and the FlexIO1 RX hardware programming path that this PR extends with the SION bit and register diagnostics.
  • FastLED/FastLED#2765: Introduced the RxBackend::FLEXIO skeleton that this PR's flexioRxLoopbackPing RPC arms and reads from.
  • FastLED/FastLED#2767: Also adds a Teensy-4-only FlexIO RX JSON-RPC handler in AutoResearchRemote.cpp that drives a TX square wave and reads raw captured edge timing from the same RX backend.

Poem

🐇 Hop, hop, a SION bit lands in place,
The FLEXIO pin now tracks with grace.
A square wave sent, the edges caught,
Eight tidy nanoseconds, neatly brought.
The loopback pings, the rabbit cheers — 🎉
No more mysterious FLEXIO tears!

✨ 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 fix/3066-iter5-sion-and-loopback-ping

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.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 15, 2026
@zackees
zackees merged commit ff5f173 into master Jun 15, 2026
7 of 8 checks passed
@zackees
zackees deleted the fix/3066-iter5-sion-and-loopback-ping branch June 15, 2026 12:25
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 15, 2026
zackees added a commit that referenced this pull request Jun 15, 2026
… fires on pin edges (refs #3066 phase 1) (#3070)

Loop iter 6 of #3066. With IOMUX routing now proven open (PR #3069
gave us FLEXIO1.PIN bit 6 tracking pin 4's pull-up at 0x40), the
remaining bug was the timer's trigger source. The original
`TIMENA=6` + `TIMRST=6` + `TRGSEL=2*flexio_pin+1` pattern never
engaged on this iMXRT1062 build — verified across iters 2/3/5 by
TIMSTAT=0 across 8 hand-driven pin transitions.

This change drives the timer from its own PINSEL field instead of
TRGSEL:

  TIMCTL:  PINSEL = flexio_pin   (was 0)
           TRGSEL = unused        (was 2*flexio_pin+1 → Shifter 3 status)
  TIMCFG:  TIMENA = 4 (Pin rising)  (was 6 = Trigger rising + Pin high)
           TIMRST = 2 (Pin rising)  (was 6 = Trigger rising)
  TIMCMP   = 1                     (was 0xFFFF)
  SHIFTCTL: TIMPOL = 0 (positive)  (was 1 = negative)

Live diagnostic (`flexioRxLoopbackPing` with 8 toggles, 50 µs apart):

  Pre-fix:  TIMSTAT=0, transfers_done=0
  Post-fix: TIMSTAT=1, transfers_done=4 ← matches 4 rising edges in 8 toggles

DMA fires once per pin rising edge. `mCaptureBuffer` is still all-zero
(shifter is latching a 1-bit value at the timer-compare moment but it
reads as 0) — that's the next iter's puzzle around SHIFTBUF semantics.
Not enough to decode WS2812 frames yet, but the chain is alive.

Also adds an iter-6 diagnostic in `flexioRxLoopbackPing` that dumps
FLEXIO1 `PIN`/`SHIFTSTAT`/`TIMSTAT` immediately after the toggles so
the host can see whether the chain reacted in real time.

Refs #3066

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

* docs(flexio-rx): document iMXRT FlexIO architectural mismatch (#3066 iter 9)

Adds a top-of-file warning block to rx_flexio_channel.cpp.hpp capturing the
iter-9 root-cause finding from #3066: iMXRT FlexIO shifters cannot snapshot a
peer timer's count into SHIFTBUF, and SMOD=1+TIMOD=3 collides shift-and-store
on the same compare event per NXP's own documentation ('shift registers
cannot shift and store on the same clock, so input data may be lost').

This explains the all-zero captures that PRs #3067/#3068/#3069/#3070/#3071
chased without success and the loop's pause at the 5-PR cap. Future readers
should know not to twist more knobs on this file — the path forward is
FlexPWM RX (Phase 4 of #3066), which has dedicated SMx_CAPTCTRL input-capture
silicon.

Pure comment change. Verified compiles via 'bash compile teensy40 --examples
AutoResearch'. References issue comment #3066/4740201201 for the full
register-by-register NXP cross-check.

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

* fix(flexio-rx): drop emoji per C++ style (CodeRabbit on #3214)

Replace the warning-triangle emoji with a 'WARNING:' text prefix per
the FastLED C++ guideline against emoji in source files.

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