-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added multiple SPI capability with minimal disruptions to the existing code #520
Conversation
I'm trying to use 2 spi buses simultaneously on my esp32 [vspi and hspi]. I'm connecting the rfid rc522 sensor on the hspi bus and tried to use your fork but I'm getting the error
|
Hello, thanks for using the fork.
Maybe this can be added to the code examples at some point. |
I think in your case, it becomes;
|
@Rotzbua you could have added the #521 to the fork milestone instead of this version. I closed this pull request on purpose because my editor changed a lot of empty lines because of some configuration problems. It should still work, however commits seems more than what they actually are. #521 is the better version of this. |
hi nice fork i trying in esp32 with HSPI with code in a comment on top but did not work
|
Excellent solution, @devrim-oguz |
He says this will not be added to the main repo. You can manually make the changes in the main repo or use my branch if you want. Not many lines have changed, it can easily be done manually. |
I advise you to use the #521 commit. |
Resubmitted on #571, I used the code in Lilygo T-Display and works as expected. Finger crossed... |
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.