miguelbalboa / rfid

Arduino RFID Library for MFRC522
The Unlicense
2.75k stars 1.43k forks source link

Added multiple SPI capability with minimal disruption to the existing code #521

Closed devrim-oguz closed 4 years ago

devrim-oguz commented 4 years ago

Added a new constructor for changing the selected SPI port and changed all of the SPI class acesses to an SPIClass pointer. Increased compatibility with other devices that has multiple SPI ports (Such as ESP32 or STM32 boards)

Example usage: MFRC522 mfrc522(SS_PIN, RST_PIN, SPI); //Works the same as: MFRC522 mfrc522(SS_PIN, RST_PIN) or MFRC522 mfrc522(SS_PIN, RST_PIN, SPI2); //Given that you created another SPIClass named SPI2

Note: You can still use it as before, like; MFRC522 mfrc522(SS_PIN, RST_PIN); or MFRC522 mfrc522(RST_PIN);

Tested on Arduino UNO and STM32F103RB, works without a problem.

Q A
Bug fix? no
New feature? yes
Doc update? no
BC breaks? no
Deprecations? no
Fixed tickets #497
Rotzbua commented 4 years ago

Injectable SPI is available at the fork.