Skip to content
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

Update to match the current SPI-Py API #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update to match latest SPI-Py API
A change to the SPI-Py API added a device-handle parameter to the
transfer method.

Signed-off-by: Phil Elwell <[email protected]>
  • Loading branch information
Phil Elwell committed Dec 20, 2019
commit 009e43ebff802203516ac9b065f394a9ce54c047
6 changes: 3 additions & 3 deletions MFRC522.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class MFRC522:
serNum = []

def __init__(self, dev='/dev/spidev0.0', spd=1000000):
spi.openSPI(device=dev,speed=spd)
self.dev = spi.openSPI(device=dev,speed=spd)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(self.NRSTPD, GPIO.OUT)
GPIO.output(self.NRSTPD, 1)
Expand All @@ -138,10 +138,10 @@ def MFRC522_Reset(self):
self.Write_MFRC522(self.CommandReg, self.PCD_RESETPHASE)

def Write_MFRC522(self, addr, val):
spi.transfer(((addr<<1)&0x7E,val))
spi.transfer(self.dev, ((addr<<1)&0x7E,val))

def Read_MFRC522(self, addr):
val = spi.transfer((((addr<<1)&0x7E) | 0x80,0))
val = spi.transfer(self.dev, (((addr<<1)&0x7E) | 0x80,0))
return val[1]

def SetBitMask(self, reg, mask):
Expand Down