Photon and SD-Card library Error

Hi,

I tried to flash a sketch on my new Photon but there seems to be three errors. The sketch works on my Core.
I am logging values of three sensors to an SD-Card (Adafruit Micro SD-Card breakout).

The errors:

sd-card-library/sd2-card.cpp: In member function 'uint8_t Sd2Card::sparkSPISend(uint8_t)':
This looks like an error in sd-card-library library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
sd-card-library/sd2-card.cpp:764:40: error: 'struct GPIO_TypeDef' has no member named 'BSRR'
PIN_MAP[mosiPin_].gpio_peripheral->BSRR = PIN_MAP[mosiPin_].gpio_pin; // Data High
^

This looks like an error in sd-card-library library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
sd-card-library/sd2-card.cpp:766:40: error: 'struct GPIO_TypeDef' has no member named 'BRR'
PIN_MAP[mosiPin_].gpio_peripheral->BRR = PIN_MAP[mosiPin_].gpio_pin; // Data Low
^

This looks like an error in sd-card-library library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
sd-card-library/sd2-card.cpp:768:40: error: 'struct GPIO_TypeDef' has no member named 'BSRR'
PIN_MAP[clockPin_].gpio_peripheral->BSRR = PIN_MAP[clockPin_].gpio_pin; // Clock High
^

This looks like an error in sd-card-library library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
sd-card-library/sd2-card.cpp:774:40: error: 'struct GPIO_TypeDef' has no member named 'BRR'
PIN_MAP[clockPin_].gpio_peripheral->BRR = PIN_MAP[clockPin_].gpio_pin; // Clock Low
^

make[1]: *** [../build/target/user/platform-6sd-card-library/sd2-card.o] Error 1
make: *** [user] Error 2

Has this library already been ported to the Photon? I really appreciate your help!

Kind regards,
Tom

Is there really nobody who knows how to solve this?

The registers “BRR” and “BRRH” have different names on the photon. Corresponding functions have been added which should be used instead of the PIN_MAP reference ( see https://github.com/spark/firmware/blob/develop/wiring/inc/fast_pin.h).

A quick fix in your case should be the following:
Replace statements where “BSRR” is used with “pinSetFast(PINNAME)”, statements where BRR is used with “pinResetFast(PINNAME)” and finally where IDR is used use “pinReadFast(PINNAME)” instead.

For example:
"PIN_MAP[clockPin_].gpio_peripheral->BRR = PIN_MAP[clockPin_].gpio_pin;"
should be
pinResetFast(clockPin_);

Then either copy the contents of ‘fast_pin.h’ into your firmware wiring library, write similar macros into the application header until the new system firmware is released or build your firmware using the latest development branch state.

Thank you very much for your answer @Melx
I will try do set up Particle CLI and try your solution on my local installation. :smile:

Kind regards,
Tom

@Melx when do you think this code will be merged into a stable build?

I have hit this problem whilst porting a Core application to Photon. Has the library been updated on Github or is this a local fix only solution?

@armor, as posted here
SD2-CARD.cpp SD card library fix for Photon

Have you not seen this Photon port "SD-Card-Library-Photon-Compat" on Web IDE?

1 Like