Last active
December 19, 2019 17:51
-
-
Save pelwell/e667bc7eebfb32d18a60bc91f6411db9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf8 -*- | |
# MFRC522_test.py - Copyright 2017-2019, Phil Elwell, Raspberry Pi (Trading) Ltd. | |
import RPi.GPIO as GPIO | |
import spi | |
import signal | |
import time | |
NRSTPD = 22 | |
dev = spi.openSPI(device='/dev/spidev0.0', speed=1000000) | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(NRSTPD, GPIO.OUT) | |
GPIO.output(NRSTPD, 0) | |
time.sleep(0.1) | |
GPIO.output(NRSTPD, 1) | |
time.sleep(0.1) | |
line = '' | |
for addr in range(0,64): | |
col = addr % 8 | |
val = spi.transfer(dev, (((addr<<1)&0x7E) | 0x80,0)) | |
if col == 0: | |
line = '%02x:' % addr | |
line += ' %02x' % val[1] | |
if col == 7: | |
print line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The SPI-Py API changed. I've updated the MFRC522_test.py .gist to work with the current version.