本文整理汇总了Python中spi.openSPI函数的典型用法代码示例。如果您正苦于以下问题:Python openSPI函数的具体用法?Python openSPI怎么用?Python openSPI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了openSPI函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,spd=1000000):
spi.openSPI(speed=spd)
#GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
GPIO.setup(self.NRSTPD, GPIO.OUT)
GPIO.output(self.NRSTPD, GPIO.HIGH)
self.MFRC522_Init()
示例2: main
def main():
# Open file descriptor for
# spi device 0 using the CE0 pin for chip select
device_0 = spi.openSPI(device="/dev/spidev0.0",
mode=0,
speed=1000000)
# Open file descriptor for
# spi device 0 using the CE1 pin for chip select
device_1 = spi.openSPI(device="/dev/spidev0.1",
mode=0,
speed=1000000)
# Transact data
data_out = (0xFF, 0x00, 0xFF)
# This is not necessary, not just demonstrate loop-back
data_in = (0x00, 0x00, 0x00)
data_in = spi.transfer(device_0, data_out)
print("Received from device 0:")
print(data_in)
data_in = (0x00, 0x00, 0x00)
data_in = spi.transfer(device_1, data_out)
print("Received from device 1:")
print(data_in)
# Close file descriptors
spi.closeSPI(device_0)
spi.closeSPI(device_1)
示例3: __init__
def __init__(self, *args, **kargs):
GPIO.setmode(GPIO.BOARD)
# pin15=GPIO22 is linked to MAX3420 -RST
GPIO.setup(15, GPIO.OUT)
GPIO.output(15,GPIO.LOW)
GPIO.output(15,GPIO.HIGH)
spi.openSPI(speed=26000000)
示例4: __init__
def __init__(self,spd=1000000):
spi.openSPI(speed=spd)
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(22, GPIO.OUT)
GPIO.output(self.NRSTPD, 1)
self.MFRC522_Init()
示例5: __init__
def __init__(self, *args, **kargs):
# GPIO.setmode(GPIO.BOARD)
# # pin15=GPIO22 is linked to MAX3420 -RST
# GPIO.setup(15, GPIO.OUT)
# GPIO.output(15,GPIO.LOW)
# GPIO.output(15,GPIO.HIGH)
spi.openSPI(device="/dev/spidev1.0", speed=26000000)
示例6: __init__
def __init__(self, dev='/dev/spidev0.1', spd=1000000):
spi.openSPI(device=dev,speed=spd)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(22, GPIO.OUT)
GPIO.output(self.NRSTPD, 1)
self.MFRC522_Init()
示例7: __init__
def __init__(self, dev='/dev/spidev0.0', spd=1000000):
spi.openSPI(device=dev,speed=spd)
GPIO.setmode(GPIO.BCM)
GPIO.setup(self.NRSTPD, GPIO.OUT)
GPIO.output(self.NRSTPD, 0)
GPIO.setup(self.SDA, GPIO.OUT)
GPIO.output(self.SDA, 0)
self.MFRC522_Init()
示例8: lcd_cmd
def lcd_cmd(cmd):
stat = spi.openSPI(SPI_DEVICE,speed=SPI_SPEED,bits=8)
# print "LCD CMD(1)=%X, SPI_open=" % (cmd) , stat
spi.transfer((0,cmd>>8,0x00ff&cmd,0x11)) # 0x11 - CMD_BE const from ili9341.c
spi.closeSPI()
# time.sleep(0.0001) # 100us
stat = spi.openSPI(SPI_DEVICE,speed=SPI_SPEED,bits=8)
# print "LCD CMD(2)=%X, SPI_open=" % (cmd) , stat
spi.transfer((0,cmd>>8,0x00ff&cmd,0x1B)) # x01B - CMD_AF const from ili9341.c
spi.closeSPI()
return
示例9: lcd_data
def lcd_data(data):
stat = spi.openSPI(SPI_DEVICE,speed=SPI_SPEED,bits=8)
# print "LCD DATA(1)=%X, SPI_open=" % (data) , stat
spi.transfer((0,data>>8,0x00ff&data,0x15)) # 0x15 - DATA_BE const from ili9341.c (BE is short form "before")
spi.closeSPI()
# time.sleep(0.00001) # 10us
stat = spi.openSPI(SPI_DEVICE,speed=SPI_SPEED,bits=8)
# print "LCD DATA(2)=%X, SPI_open=" % (data) , stat
spi.transfer((0,data>>8,0x00ff&data,0x1F)) # 0x1F - DATA_AF const from ili9341.c (AF is short form "after")
spi.closeSPI()
return
示例10: issue_setup
def issue_setup(self, data):
"""
Sets up the Raspdancer to communicate with the MAX324x.
"""
# pin15=GPIO22 is linked to MAX3420 -RST
GPIO.setup(15, GPIO.OUT)
GPIO.output(15,GPIO.LOW)
GPIO.output(15,GPIO.HIGH)
spi.openSPI(speed=26000000)
return b''
示例11: __init__
def __init__(self,spd=1000000, NRSTPDpin = 25, GPIO = None):
spi.openSPI(speed=spd)
if not GPIO:
import RPi.GPIO as GPIO
self.GPIO = GPIO
self.GPIO.setmode(GPIO.BCM)
self.NRSTPD = NRSTPDpin;
self.GPIO.setup(self.NRSTPD, GPIO.OUT)
self.GPIO.output(self.NRSTPD, 1)
self.MFRC522_Init()
示例12: lcd_reset
def lcd_reset():
# for reset I use slow clock - just my habit
stat = spi.openSPI(SPI_DEVICE,speed=1000000,bits=8)
# print "LCD RESET(1), SPI_open=",stat
spi.transfer((0,0,0,0)) # set 0 on U1-Q2
spi.closeSPI()
time.sleep(0.05) # 50ms reset
# unreset
stat = spi.openSPI(SPI_DEVICE,speed=1000000,bits=8)
# print "LCD RESET(2), SPI_open=",stat
spi.transfer((0,0,0,2)) # set 1 on U1-Q2
spi.closeSPI()
time.sleep(0.1) # 100ms after reset
return
示例13: __init__
def __init__(self, dev='/dev/spidev0.0', speed=1000000, pin_rst=22):
self.pin_rst = pin_rst
SPI.openSPI(device=dev, speed=speed)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(pin_rst, GPIO.OUT)
GPIO.output(pin_rst, 1)
self.reset()
self.dev_write(0x2A, 0x8D)
self.dev_write(0x2B, 0x3E)
self.dev_write(0x2D, 30)
self.dev_write(0x2C, 0)
self.dev_write(0x15, 0x40)
self.dev_write(0x11, 0x3D)
self.set_antenna(True)
示例14: __init__
def __init__(self):
self.xDefault = 148
self.yDefault = 176
self.xMin = 128
self.xMax = 168
self.yMin = 136
self.yMax = 216
self.devMaxX = None
self.devMinX = None
self.devMaxY = None
self.devMinY = None
spi.openSPI(speed=1000000, mode=0)
示例15: __init__
def __init__(self, name, bus, channel, _3wire=True):
self.serial = name
device = "/dev/spidev%s.%s" % (bus, channel)
spi.openSPI(speed=100000, mode=1, device=device)
self.config = REG_CONF_VBIAS_ON | REG_CONF_50HZ_FILTER | REG_CONF_CONVERSION_MODE_AUTO
if(_3wire):
self.config |= REG_CONF_3WIRE_RTD
self.__write__(REG_CONFIGURATION, self.config | REG_CONF_FAULT_STATUS_AUTO_CLEAR)
self.__write__(REG_LF_MSB, 0x00)
self.__write__(REG_LF_LSB, 0x00)
self.__write__(REG_HF_MSB, 0xFF)
self.__write__(REG_HF_LSB, 0xFF)