Make this work with recent versions of SPI module

This commit is contained in:
Kumi 2021-06-18 10:05:56 +01:00
parent cf7f9ec0cc
commit dfc23b3282

View file

@ -128,7 +128,7 @@ class MFRC522:
serNum = []
def __init__(self, dev='/dev/spidev0.0', spd=1000000):
spi.openSPI(device=dev,speed=spd)
self.spidev = spi.openSPI(device=dev,speed=spd)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(self.NRSTPD, GPIO.OUT)
GPIO.output(self.NRSTPD, 1)
@ -138,10 +138,10 @@ class MFRC522:
self.Write_MFRC522(self.CommandReg, self.PCD_RESETPHASE)
def Write_MFRC522(self, addr, val):
spi.transfer(((addr<<1)&0x7E,val))
spi.transfer(self.spidev, ((addr<<1)&0x7E,val))
def Read_MFRC522(self, addr):
val = spi.transfer((((addr<<1)&0x7E) | 0x80,0))
val = spi.transfer(self.spidev, (((addr<<1)&0x7E) | 0x80,0))
return val[1]
def SetBitMask(self, reg, mask):