sipeed / Longduino

Longduino is an Arduino port for gd32v mcu.
Other
70 stars 21 forks source link

SPI "SS" pin #18

Open smuehlst opened 4 years ago

smuehlst commented 4 years ago

I'm trying out the SPI library from the current master branch (as of commit e7e1d8ad04875813bea83edde82f99c7bb8f61d5) with the Arduino RFID Library for MFRC522, and the firstcompilation error that comes up is that there is no SS pin is defined.

Apparently each Arduino implementation should declare a SS define that refers to the default pin to be used for the "Slave Select" signal. See https://www.arduino.cc/en/Reference/SPI.

phillowcompiler commented 4 years ago

I think you can use any pin. but,PB12 is used for TF_SS. PB0,1 is for LCD on Longan nano. so example, if you select PB11(B11) for SS, you would write :

SPIClass SPI(PB15, PB14, PB13, PB11);

smuehlst commented 4 years ago

@phillowcompiler It is clear to me that more or less any pin can be used for the Slave Select signal in my own code.

The issue is that the Arduino RFID Library for MFRC522 that depends on SPI expects the SS pin to be defined after including the SPI.h header:

https://github.com/miguelbalboa/rfid/blob/b7d7f3e572af6cfd78722f2bd693097019ec55ff/src/MFRC522.cpp#L16

/**
 * Constructor.
 */
MFRC522::MFRC522(): MFRC522(SS, UINT8_MAX) { // SS is defined in pins_arduino.h, UINT8_MAX means there is no connection from Arduino to MFRC522's reset and power down input
} // End constructor
phillowcompiler commented 4 years ago

I see😃 If so, can you try to modify "plarformio.ini"?

https://docs.platformio.org/en/latest/projectconf/section_env_build.html

smuehlst commented 4 years ago

If so, can you try to modify "plarformio.ini"?

Yes, I could do that, but my primary goal was to report this problem so it hopefully will be fixed sooner or later before an official release. An implementation of the Arduino SPI library will be useless or difficult to use if it doesn't implement the features that are expected by existing code...