-
Notifications
You must be signed in to change notification settings - Fork 150
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
Setting cs_change breaks MFRC522 RFID reader #17
Comments
mab5vot9us9a
added a commit
to mab5vot9us9a/SPI-Py
that referenced
this issue
Jul 5, 2016
Fixes issue lthiery#17 lthiery#17.
mab5vot9us9a
added a commit
to mab5vot9us9a/SPI-Py
that referenced
this issue
Jul 29, 2016
pelwell
added a commit
to pelwell/SPI-Py
that referenced
this issue
Sep 6, 2016
Normally CS is asserted between messages then deasserted after the final one. Setting cs_change to 1 deasserts CS between messages, but if set on the final message it causes CS to remain asserted until the next transfer. Counterintuitively, in the single message case, setting cs_change to 1 prevents CS from changing, while setting it to 0 allows it to change after each message/transfer. Some device, like the MFRC522 rely on a change of CS for synchronisation, and you wouldn't want to leave multiple devices selected simultaneously, so cs_change should be zero. This issue was previously masked by the use of the BCM2835 hardware chip selects, which don't allow CS to remain asserted between transfers. See: raspberrypi/linux#1547 lthiery#17
Closing, since my pull request has been accepted. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been investigating a problem using the Mifare RFID reader module on Raspberry Pi. The problem started when we made the switch to the upstream SPI driver, spi-bcm2835.
One of the features of the upstream SPI driver is that it forces software CS due to a deficiency in the hardware. I noticed that with that driver the CS line was being held active between messages, but the MFRC522 spec says that it must become inactive between messages. Hacking the downstream driver to allow hardware CS to be used if requested, and requesting it, fixed the problem. I put this down to some incompatibility in the SW CS implementation in the driver.
I now think the driver is behaving correctly, and the bug is in this library. The kernel documentation says:
I think this is a bit cryptic, but another doc I found online spells it out:
When the transfer() function sets cs_change to 1 on the one-and-only message it sends, it is asking the SPI subsystem to try to keep CS active between it and the next message. I don't know if this was your intention, but it breaks the RFC reader. I suspect it only used to work on the old SPI driver because the hardware was incapable of keep CS active between transfers.
You can read the original bug report and subsequent discussion here.
The text was updated successfully, but these errors were encountered: