Skip to content

sdfat(teensy3): full-duplex K64/K66 DSPI bus for SdFat's SPI transport #3972

Closed

Description

@zackees

Sub-issue of #3970. Scope: Teensy 3.5 / 3.6 (K64 / K66) only. Depends on #3971 landing the seam.

Situation

Unlike Teensy 4, there is no non-template SPI bus class for K64/K66. teensy36/fastspi_arm_k66.h has the DSPI machinery — CTAR0/CTAR1 programming (update_ctars, update_ctar0), PUSHR/POPR macros, pin config — but it is written write-only for LED output: templated on _DATA_PIN/_CLOCK_PIN, never configures MISO, never reads POPR.

The missing SPISettings::ctar_clock_table / ctar_div_table symbols in the current link failure are exactly this domain: Arduino ships the frequency-to-CTAR mapping as lookup tables.

Live surface required

Same as #3971 (both dead branches identified there apply here too):

  • begin() / end()
  • beginTransaction(settings) / endTransaction()
  • transfer(u8) -> u8 — full duplex, needs POPR
  • setTransferWriteFill(u8)
  • transfer(const void* tx, void* rx, fl::size count)
  • a settings type taking (hz, MSBFIRST, SPI_MODE0)
  • a default instance, held behind fl::Singleton so it elides when unused

Tasks

Constraints

  • Minimise churn, especially tests. Reuse the existing K66 CTAR helpers where possible instead of duplicating register logic. Do not restructure the vendored SdFat tree.
  • Do not copy code from Arduino's SPI.h/SPI.cpp. They are GPLv2/LGPLv2.1 and FastLED is MIT. Work from the K64/K66 reference manual and FastLED's existing register code.
  • Do not regress Teensy 4 — that path is settled by sdfat(teensy4): route SdFat's SPI transport onto LpspiBus #3971.

Acceptance

  • bash compile teensy35 --examples Fx/FxSdCard links, no SPIClass/SPI/ctar_*_table undefined symbols
  • bash compile teensy36 --examples Fx/FxSdCard links
  • bash test --cpp passes — 283/283 unit and 83/83 examples on host
  • bash lint clean
  • No SPIClass references remain under src/platforms/arm/teensy/sdfat/ outside comments
  • Singleton elision preserved
  • Hardware validation on a real 3.5 or 3.6 before this is trusted. A green compile proves nothing here — SD init timing is unforgiving. If no board is available, say so plainly in the PR rather than implying it was verified

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions