Need to Alter Library File for SPI1 (SD Card) Operation

Hi all - new I’m new to Particle and new to Community, so … :slight_smile:

I am using a M.2 BSOM Evaluation board with a B404X. I want to access the SD card, which as far as I can tell is on SPI1 (secondary SPI port).

I have the following:
static const int SD_CHIP_SELECT = D5;
static SdFat mSD(&SPI1);

And I am using SdFat=1.0.16

I find that this alone does not work. The only way I have been able to read/write to the SD card is by editing the pinmap_defines.h file buried in the Particle OS (/Users/xxxx/.particle/toolchains/deviceOS/4.0.0/hal/src/b5som/pinmap_defines.h) to be:

#define SS D5 /* D8 /
#define SCK D4 /
D13 /
#define MISO D3 /
D11 /
#define MOSI D2 /
D12 */

I thought that assigning the SPI port to be SPI1 would be enough, but I need to ‘brute force’ it to get it to work. What am I missing?

I might be mistaken, and also possibly looking at a different version of SdFat, but the version I’m looking at takes an integer to specify the SPI interface: 0=SPI, 1=SPI1, 2=SPI2 (if present).

  explicit SdFat(uint8_t spiIf) {
    m_spi.setSpiIf(spiIf < SPI_INTERFACE_COUNT ? spiIf : 0);

I did read about using an integer, but when I try that I get a compile error:

/Users/andreawolga/Documents/Projects/Particle/PCD-Test//src/pcd_sd_card.cpp:14:18: error: invalid conversion from ‘int’ to ‘SPIClass*’ [-fpermissive]
14 | static SdFat mSD(1);



Thanks for the suggestion, however.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.