Repository navigation
Closed
Description
Sub-issue of #3970. Scope: Teensy 4.0 / 4.1 (MXRT1062) only.
Investigation result: the live surface is smaller than the issue implies
Two branches in SdSpiTeensy3.cpp.hpp are dead, which removes most of the apparent work:
SDFAT_SDCARD_SPI/SDFAT_SDCARD_SS_PINare never defined anywhere in the tree, so thesetMISO/setMOSI/setSCKbranch is unreachable. Those three methods are not needed.USE_TRANSFER_TX_RXis always defined for Teensy, so the in-placetransfer(buf, count)branch is unreachable. Only the 3-argument full-duplex form is needed.
The live surface SpiPort_t must provide is therefore exactly:
| member | LpspiBus today |
|---|---|
begin() / end() |
present |
beginTransaction(settings) / endTransaction() |
present |
transfer(u8) -> u8 |
present (writes TDR, spins FSR, returns RDR) |
setTransferWriteFill(u8) |
missing |
transfer(const void* tx, void* rx, size count) |
missing |
Plus a settings type — LpspiSettings(clock, bit_order, data_mode) already has the identical signature to SPISettings(maxSck, MSBFIRST, SPI_MODE0) — and a default instance, for which LpspiBus::get(index) already exists behind fl::Singleton<LpspiBusStorage> (elision-safe).
Tasks
- Add
setTransferWriteFill(fl::u8)toLpspiBus(stores the fill byte used whentx == nullptr) - Add
transfer(const void* tx, void* rx, fl::size count)toLpspiBus. A loop over the existingtransfer(u8)is acceptable for a first cut;tx == nullptrsends the fill byte,rx == nullptrdiscards. Do not add DMA or async. - Make
SpiPort_tresolve toLpspiBuson Teensy 4 instead ofSPIClass, through the existingSdSpiDriver.htypedef seam, and drop the#include "SPI.h"on that path - Point
SdSpiArduinoDriver::begin()'s fallback atLpspiBus::get(0)instead of the globalSPI - Keep the Arduino path reachable behind a define as an escape hatch
Constraints
- Minimise churn, especially tests. Do not restructure the vendored SdFat tree; work through the existing seam. Do not add or rewrite test files unless something is genuinely uncovered.
- Do not touch the Teensy 3.x path — that is the sibling sub-issue.
SpiPort_tmust still resolve toSPIClassthere so 3.5/3.6 behaviour is unchanged by this PR. - No new sketch-level includes and no
lib_depsadditions — both were measured to fail (see sdfat(teensy): route the vendored SdFat SPI transport onto FastLED's own LPSPI/DSPI instead of Arduino SPIClass #3970).
Acceptance
-
bash compile teensy41 --examples Fx/FxSdCardlinks, noSPIClass/SPIundefined symbols -
bash compile teensy40 --examples Fx/FxSdCardlinks -
bash test --cpppasses — 283/283 unit and 83/83 examples on host. This is the check that caught the previous attempt (fix(examples): declare the SPI dependency in FxSdCard — takes teensy to 8/8 green (#3838) #3969), so run it, not justbash lint -
bash lintclean - teensy35/36 behaviour unchanged (still on the Arduino path, still red — expected)
- A sketch that never calls
beginSd()still emits no SdFat/SPI storage (singleton elision preserved)
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(sdfat): route Teensy 3.x/LC SdFat SPI transport onto a FastLED DS…
fix(sdfat): route Teensy 4 SdFat SPI transport onto LpspiBus (FastLED…