Skip to content

fix: finish pending Teensy4 native SPI bits at transaction boundaries #5064

Closed

Description

@zackees

Context

Two independent MXRT1062 native SPI bodies buffer individual bits but never finish a partial group. writeBit transfers only on every eighth call. waitFully and finalizeTransmission are no-ops; release only calls the selectable and LpspiBus::endTransaction, which is also a no-op. A direct public select(); writeBit<0>(1); endTransaction(); therefore emits no requested bit and leaves pending state for the next operation. A later writeByte combines the old prefix, while writeBytesValueRaw bypasses pending state.

Both unchanged pinned-baseline implementations require separate validation (shared include guard does not make either a forwarding alias):

The classes are public/callable. Current hardware selection uses SPIDeviceProxy, which does not expose writeBit, so no active SM16716 producer is claimed through that proxy. SM16716's two-bit/six-byte/two-bit header is a relevant protocol case only with explicit real backend instantiation. Absence of that current producer does not make the callable transaction API correct.

Proposal

Complete pending-bit transmission with the actual supported LPSPI frame width, drain, ownership and transaction semantics, or explicitly reject an unsupported operation. Preserve mixed-operation order and prevent pending state from crossing a completed frame. Keep the independent legacy body covered.

Acceptance criteria

  • First show focused RED on each actual production class using a real Teensy vendor SDK, then GREEN after the fix. No copied writer or fabricated peripheral struct.
  • Cover every selected bit position and zero/one payload, partial counts1–7,8,9 and larger tails, plus bit-byte-bit, bit-word, repeat/raw bulk, pixel start bits where directly supported, waitFully/finalize/end/release and repeated select/reselect. Verify exact emitted bit count/order and completion before select release.
  • Assert no pending data leaks into a later transaction, no byte-only regression, and preservation of unrelated peripheral/pin state. Exercise all supported LPSPI indices or explicitly reject unsupported ones.
  • Compile both independent bodies through real compatible target/header routes. Host observations establish logic only; no electrical timing or throughput claim without measurements.
  • Restore the old no-flush and pending-state-bypass paths independently; each must fail its focused signal and return GREEN after restoration. Bind method, selector/proxy, caller, SDK and configuration inputs to test: gate software SPI changes on exhaustive production-path and mutation evidence #5031.

Decisions

One child groups pending-bit completion/order across both independent bodies, with separate evidence required. This is distinct from Teensy generic pin policy #5026 and fractional delay #5027, and from other targets' missing/native bit implementations. Purely hardware transfers are not converted to software SPI; this is a callable bit-protocol correctness gap discovered during the complete SPI inventory.

Part of #5024.

Activity

  1. added
    sanitized
    on Nov 5, 2026
  2. zackees commented on Nov 7, 2026

    @zackees
    MemberAuthor

    #5147 covers part of this issue. Pending writeBit bits now go out at release, waitFully, finalizeTransmission and endTransaction, and before writeBytesValueRaw. Bits ahead of a byte still ride in one 9-15 bit LPSPI frame. A 1-7 bit remainder, below the LPSPI minimum frame of 8 bits, goes by GPIO with both pads saved and restored. Bus indices outside 0-2 are a compile error. The legacy mxrt1062 copy is now a shim to the live header (the two shared one include guard).

    Still open here:

  3. zackees commented on Nov 22, 2026

    @zackees
    MemberAuthor

    Closing with an accepted limitation, following the #5061 precedent (no in-tree production caller).

    Fix: #5147 (e3ee4b9). Pending writeBit bits are flushed at release() (src/platforms/arm/teensy/teensy4_common/fastspi_arm_mxrt1062.h:118-120), waitFully() (:132) and finalizeTransmission() (:213), and before raw byte writes (:152-154), through flushBits() (:81). Bits ahead of a byte ride in one 9-15 bit LPSPI frame, and a 1-7 bit remainder goes by GPIO with both pads saved and restored. Bus indices outside 0-2 are a compile error. The legacy mxrt1062 header is now a shim to this one.

    Proven by: tests/platforms/arm/teensy/teensy4_common/fastspi_arm_mxrt1062.cpp, a host LPSPI/GPIO model.

    Accepted limitations:

    • There is no production caller: SPIDeviceProxy (src/platforms/arm/mxrt1062/spi_device_proxy.h) exposes no writeBit, so SM16716 cannot reach this class through the Teensy 4 SPIOutput dispatch.
    • No silicon check of the LPSPI/GPIO model and no timing or throughput measurement: no Teensy 4.x is attached here.

    The #5031 binding is replaced by a rescoped host-side gate, tracked in #5031.

  4. moved this from Triage to Done in FastLED Trackeron Nov 22, 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

    sanitized

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions