SD Card on Arbitrary SPI Interface

Status
Not open for further replies.

gfvalvo

Well-known member
Hi all.

So, the standard Teensy SD library nicely handles SPI-connected SD cards and the SDHC interface on T3.5 / T3.6. However, it's hard-coded to use the SPI instance of SPIClass (aka SPI0).

Is there a library that handles both SDHC and SPI-connected cards on an arbitary SPI interface? For T3.5 / T3.6 that could be SPI0, SPI1, or SPI2. Ideally, I could just pass a pointer to the desired SPIClass object into the constructor or begin() method.

Thanks.
 
I have not tried it, but my guess is that SDFat does support it, at least the forever beta version.

That is I think you can create an SdSpiConfig object with one of their constructors, which I think takes pointer to SPI object.
Code:
class SdSpiConfig {
 public:
   /** SdSpiConfig constructor.
   *
   * \param[in] cs Chip select pin.
   * \param[in] opt Options.
   * \param[in] maxSpeed Maximum SCK frequency.
   * \param[in] port The SPI port to use.
   */
  SdSpiConfig(SdCsPin_t cs, uint8_t opt, uint32_t maxSpeed, SpiPort_t* port) :
    csPin(cs), options(opt), maxSck(maxSpeed), spiPort(port) {}

And the begin method for the SDBase... has a version
Code:
bool begin(SdSpiConfig spiConfig) {
    return cardBegin(spiConfig) && Vol::begin(m_card);
  }

But again I have not tried it, so don't know if will compile and.or work
 
Status
Not open for further replies.
Back
Top