Skip to content

meta: post-#3428 parallel-SPI driver follow-ups (wire-drain timing, scope verify, APA102 strip test) #3436

Open

Description

@zackees

Summary

Meta issue tracking the remaining follow-ups after #3428 was closed (parallel SPI driver work via FlexIO2 + ObjectFLED on Teensy 4.x). All three subtasks need physical hardware (scope + APA102/SK9822 strip) for verification, so they're user-side; this issue keeps them grouped.

State as of #3428 close

What's hardware-confirmed: DMA cycle fires end-to-end, ISR clears, no faults, both drivers compile + transmit at the API level.

What is NOT yet confirmed: the actual bits on the MOSI wire, and a real LED strip lighting up correctly.

Follow-up checklist

1. ⏰ [#3433] FlexIO SPI: track active transfer state for accurate wire-drain timeout

Existing tracking issue. CodeRabbit heavy-lift comment from PR #3431. flexio_spi_wait() returns as soon as the DMA ISR fires, but the final byte can still be clocking out. Fast short transfers can hit this path before the caller's next flexio_spi_show(), so deinit/reinit may cut off the tail. The fixed 50 ms timeout is also based on the fastest SCLK; at the effective floor (~234 kHz) it can under-budget large frames.

Fix sketch:

  • Add a volatile bool sShifterDrained flag set when both the DMA ISR fires AND the shifter-empty status latches.
  • Compute timeout as max(50ms, num_bytes * 8 * 2 / baud_div_hz * 1.5).
  • Add a slow-end smoke-test case (4096 bytes @ 234 kHz) to lock in the fix.

2. 🔬 Scope-verify byte-level MOSI bit pattern (both drivers)

Files: src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_spi_mode.cpp.hpp + src/platforms/arm/teensy/teensy4_common/drivers/objectfled/objectfled_spi_mode.cpp.hpp (search for TODO(#3428) comments).

Test: drive 0xA5 (= 1010 0101) via flexioSpiSelfTest / objectfledSpiSelfTest and scope MOSI. Expect MSB-first: high, low, high, low, low, high, low, high.

FlexIO-SPI suspects (per in-code TODO):

  • FLEXIO_SHIFTCTL_SHIFT_ON_FALLING_EDGE (TIMPOL=1) — if data is shifted by half a clock period, flip to rising edge.
  • SHIFTBUFBBS vs SHIFTBUFBIS for the DMA destination — bit-order alias choice. Current pick (SHIFTBUFBBS = byte+bit swap) was cross-checked against Teensy's FlexIOSPI.cpp for MSBFIRST mode but should be confirmed on scope.

ObjectFLED-SPI suspects:

  • Bit-pattern encoder (16 words per byte, MSB-first per encode_byte() in objectfled_spi_mode.cpp.hpp). The QTimer3 trigger fires once per word, so each pair of words = one SCLK cycle.
  • Pad slew rate (currently FL_OBJECTFLED_SPI_SPEED=0, FL_OBJECTFLED_SPI_DSE=3) — if 25 MHz transitions undershoot, bump to SPEED=2 / DSE=6 (the FlexIO-SPI defaults).

3. 🎄 APA102/SK9822 strip end-to-end test

Hook up an APA102 (or SK9822) strip and drive it via:

auto spi = fl::SpiChipsetConfig(/*data*/14, /*clock*/15, fl::SpiEncoder::apa102(/*6 MHz*/));
FastLED.add<fl::Bus::FLEX_IO, fl::SpiChipsetConfig>(fl::ChannelConfigOf<fl::SpiChipsetConfig>(spi, leds));
// Or: Bus::OBJECT_FLED with pins on GPIO6 bank (1, 8, 14-27, 38-41 on T4.1).
FastLED.show();

What to verify:

  • Colors render correctly across SK9822 + APA102 + HD108 at default + max-spec clocks (6 / 12 / 25 MHz).
  • No flicker over long frames (the wire-drain fix from item 1 should land before stress-testing).
  • DefaultBus<SpiChipsetConfig> = Bus::FLEX_IO choice is vindicated — auto-routing puts the strip on FlexIO without explicit Bus:: selection.

Why a meta issue?

The three items are independent (any one can land without the others) but share the same prerequisite (physical bench). Tracking them together lets a single bench session knock out all three.

Closing criteria

Close when: #3433 fixed AND scope verification done on both drivers AND at least one APA102 strip lit up successfully on each driver path.

Activity

  1. zackees commented on Aug 20, 2026

    @zackees
    MemberAuthor

    Deferred under the active bug-burn-down policy. This meta explicitly groups three physical Teensy bench tasks, and the prerequisite hardware is not currently attached.

    Disposition of its checklist:

    1. FlexIO SPI: track active transfer state for accurate wire-drain timeout #3433 — still reproducible in current source and now explicitly deferred with code-level and Teensy 4.1 restart criteria.
    2. Byte-level MOSI scope verification — not complete for either FlexIO-SPI or ObjectFLED-SPI; the TODO(#3428) bit-order/edge assumptions remain hardware hypotheses.
    3. APA102/SK9822 end-to-end strip test — no preserved evidence that both driver paths were validated on a real strip across the requested clocks.

    A fresh fbuild port scan reports every PJRC identity (COM20/19/21/7) as phantom, present=no, selectable=no. The healthy attached boards are ESP32-C6 COM9 and RP-class COM18, neither of which can validate i.MX RT1062 FlexIO/ObjectFLED behavior.

    Restart criteria are exactly the meta's intended single bench session:

    • Attach a selectable Teensy 4.1, scope/logic analyzer, and APA102 or SK9822 strip.
    • Fix and validate FlexIO SPI: track active transfer state for accurate wire-drain timeout #3433 first.
    • Capture 0xA5 MOSI + SCLK traces for both drivers and preserve evidence of MSB-first phase/order.
    • Run real-strip color/flicker tests on both drivers at representative 6/12/25 MHz clocks, including a long frame.
    • Record DefaultBus auto-routing evidence.
    • Remove deferred and close only when all three closing criteria are evidenced.

    The meta remains open and is excluded from the actionable queue while labeled deferred.

  2. added
    deferred
    on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    deferred

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions