当前位置: 首页>>代码示例>>Python>>正文


Python SPI.close方法代码示例

本文整理汇总了Python中Adafruit_BBIO.SPI.SPI.close方法的典型用法代码示例。如果您正苦于以下问题:Python SPI.close方法的具体用法?Python SPI.close怎么用?Python SPI.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Adafruit_BBIO.SPI.SPI的用法示例。


在下文中一共展示了SPI.close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Adafruit_BBIO.SPI import SPI [as 别名]
# 或者: from Adafruit_BBIO.SPI.SPI import close [as 别名]
	def __init__(self, bus):
		# Use Adafruit_BBIO.SPI to initialize the cap
		# and the spi bus configuration
		s = SPI(bus, self.__DEVICE)
		s.msh = self.__SPEED
		s.mode = self.__MODE
		s.close()

		# Use normal file for writing bytes
		dev = '/dev/spidev%s.%s' % (bus + 1, self.__DEVICE)
		self.spi = open(dev, 'wb')
		print 'Opened %s, Freq: %sHz' % (dev, self.__SPEED)
开发者ID:flaub,项目名称:tikitank,代码行数:14,代码来源:leds.py

示例2: print_single_status_line

# 需要导入模块: from Adafruit_BBIO.SPI import SPI [as 别名]
# 或者: from Adafruit_BBIO.SPI.SPI import close [as 别名]

#.........这里部分代码省略.........
        # Initialize CRC and request 2-byte (16bit) CRC
        self.setCRCLength(NRF24.CRC_16)

        # Disable dynamic payloads, to match dynamic_payloads_enabled setting
        self.write_register(NRF24.DYNPD, 0)

        # Set up default configuration.  Callers can always change it later.
        # This channel should be universally safe and not bleed over into adjacent
        # spectrum.
        self.channel = 76
        self.setChannel(self.channel)

        # Powers up the radio, this can take up to 4.5ms
        # when CE is low radio will be in standby and will initiate
        # reception or transmission very shortly after CE is raised
        # If CE pin is not used, will Power up only on startListening and stopListening
        if self.ce_pin is not None:
            self.powerUp()

        # Reset current status
        # Notice reset and flush is the last thing we do
        self.write_register(NRF24.STATUS, NRF24.RX_DR | NRF24.TX_DS | NRF24.MAX_RT)

        # Flush buffers
        self.flush_rx()
        self.flush_tx()
        self.clear_irq_flags()

    def end(self):
        """ End use of the radio """
        self.ce(0)
        if self.spidev:
            self.powerDown()
            self.spidev.close()
            self.spidev = None

    def startListening(self):
        """ Set radio for reception
        
            Use openReadingPipe to set up reception pipes before listening """
        self.write_register(NRF24.CONFIG, self.read_register(NRF24.CONFIG) | NRF24.PWR_UP | NRF24.PRIM_RX)
        self.flush_tx()
        self.flush_rx()
        self.clear_irq_flags()

        # Restore the pipe0 address, if exists
        if self.pipe0_reading_address:
            self.write_register(self.RX_ADDR_P0, self.pipe0_reading_address)

        # Go!
        self.ce(1)

        # wait for the radio to come up
        if self.ce_pin is None:
            time.sleep(45 / 10000.0) # 4.5 ms
        else:
            time.sleep(130 / 1000000.0) # 130us

    def ce(self, level, pulse=0):
        """ Controls CE pin """
        # CE Pin is optional (but highly recommended)
        if self.ce_pin is not None:
            GPIO.output(self.ce_pin, level)
            if pulse > 0:
                time.sleep(pulse)
                GPIO.output(self.ce_pin, 1 - level)
开发者ID:dquadros,项目名称:SensorNRF24L01,代码行数:70,代码来源:nrf24.dq.py

示例3: print_single_status_line

# 需要导入模块: from Adafruit_BBIO.SPI import SPI [as 别名]
# 或者: from Adafruit_BBIO.SPI.SPI import close [as 别名]

#.........这里部分代码省略.........
        # because a non-P variant won't allow the data rate to
        # be set to 250Kbps.
        if self.setDataRate(NRF24.BR_250KBPS):
            self.p_variant = True

        # Then set the data rate to the slowest (and most reliable) speed supported by all
        # hardware.
        self.setDataRate(NRF24.BR_1MBPS)

        # Initialize CRC and request 2-byte (16bit) CRC
        self.setCRCLength(NRF24.CRC_16)

        # Disable dynamic payloads, to match dynamic_payloads_enabled setting
        self.write_register(NRF24.DYNPD, 0)

        # Reset current status
        # Notice reset and flush is the last thing we do
        self.write_register(NRF24.STATUS, NRF24.RX_DR | NRF24.TX_DS | NRF24.MAX_RT)

        # Set up default configuration.  Callers can always change it later.
        # This channel should be universally safe and not bleed over into adjacent
        # spectrum.
        self.setChannel(self.channel)

        self.setRetries(15, 15)

        # Flush buffers
        self.flush_rx()
        self.flush_tx()
        self.clear_irq_flags()

    def end(self):
        if self.spidev:
            self.spidev.close()
            self.spidev = None

    def startListening(self):
        self.write_register(NRF24.CONFIG, self.read_register(NRF24.CONFIG) | NRF24.PWR_UP | NRF24.PRIM_RX)
        self.write_register(NRF24.STATUS, NRF24.RX_DR | NRF24.TX_DS | NRF24.MAX_RT)

        self.flush_tx()
        self.flush_rx()
        self.clear_irq_flags()

        # Restore the pipe0 address, if exists
        if self.pipe0_reading_address:
            self.write_register(self.RX_ADDR_P0, self.pipe0_reading_address)

        # Go!
        self.ce(1)

    def ce(self, level, pulse=0):
        # CE Pin is optional
        if self.ce_pin is not None:
            GPIO.output(self.ce_pin, level)
            if pulse > 0:
                time.sleep(pulse)
                GPIO.output(self.ce_pin, 1 - level)

    def irqWait(self, timeout=30000):
        # TODO: A race condition may occur here. => wait for level?
        if GPIO.input(self.irq_pin) == 0:  # Pin is already down. Packet is waiting?
            return True

        try:
            return GPIO.wait_for_edge(self.irq_pin, GPIO.FALLING, timeout) == 1
开发者ID:BayCEER,项目名称:pynrf24,代码行数:70,代码来源:nrf24.py

示例4: __init__

# 需要导入模块: from Adafruit_BBIO.SPI import SPI [as 别名]
# 或者: from Adafruit_BBIO.SPI.SPI import close [as 别名]

#.........这里部分代码省略.........

        # Determine if this is a p or non-p RF24 module and then
        # reset our data rate back to default value. This works
        # because a non-P variant won't allow the data rate to
        # be set to 250Kbps.
        if self.setDataRate(NRF24.BR_250KBPS):
            self.p_variant = True

        # Then set the data rate to the slowest (and most reliable) speed supported by all
        # hardware.
        self.setDataRate(NRF24.BR_1MBPS)

        # Initialize CRC and request 2-byte (16bit) CRC
        self.setCRCLength(NRF24.CRC_16)

        # Disable dynamic payloads, to match dynamic_payloads_enabled setting
        self.write_register(NRF24.DYNPD, 0)

        # Reset current status
        # Notice reset and flush is the last thing we do
        self.write_register(NRF24.STATUS, _BV(NRF24.RX_DR) | _BV(NRF24.TX_DS) | _BV(NRF24.MAX_RT))

        # Set up default configuration.  Callers can always change it later.
        # This channel should be universally safe and not bleed over into adjacent
        # spectrum.
        self.setChannel(self.channel)

        # Flush buffers
        self.flush_rx()
        self.flush_tx()

    def end(self):
        if self.spidev:
            self.spidev.close()
            self.spidev = None

    def startListening(self):
        self.write_register(NRF24.CONFIG, self.read_register(NRF24.CONFIG) | _BV(NRF24.PWR_UP) | _BV(NRF24.PRIM_RX))
        self.write_register(NRF24.STATUS, _BV(NRF24.RX_DR) | _BV(NRF24.TX_DS) | _BV(NRF24.MAX_RT))

        # Restore the pipe0 address, if exists
        if self.pipe0_reading_address:
            self.write_register(self.RX_ADDR_P0, self.pipe0_reading_address, 5)

        # Go!
        self.ce(NRF24.HIGH)

        # wait for the radio to come up (130us actually only needed)
        time.sleep(130 / 1000000.0)

    def stopListening(self):
        self.ce(NRF24.LOW)
        self.flush_tx()
        self.flush_rx()

    def powerDown(self):
        self.write_register(NRF24.CONFIG, self.read_register(NRF24.CONFIG) & ~_BV(NRF24.PWR_UP))

    def powerUp(self):
        self.write_register(NRF24.CONFIG, self.read_register(NRF24.CONFIG) | _BV(NRF24.PWR_UP))
        time.sleep(150 / 1000000.0)

    def write(self, buf):
        # Begin the write
        self.startWrite(buf)
开发者ID:surveycorps,项目名称:apro-core,代码行数:69,代码来源:nrf24.py

示例5: len

# 需要导入模块: from Adafruit_BBIO.SPI import SPI [as 别名]
# 或者: from Adafruit_BBIO.SPI.SPI import close [as 别名]
			data.append(line)
			count += 1
		elif count == 19:
			data.pop(0)
			break
	data.append(str(resultFinal))# + '\n')
	print data
	#print len(data)
	#data.pop(0)
	file.close()
	f = open('methane_test.txt' ,'w').close()
	#f = open('methane_test.txt','r+')
	#f.truncate()
	file = open('methane_test.txt', 'w')
	for number in data:
		print number
		#file.write("\n")
		file.write("%s" % number)
		#file.write("\n")
	#####################################
	#####################################

        #print data
        #print result[0] #"EYYYYY"
        #print result[1]
	file.close()
#end while

except KeyboardInterrupt:
        spi.close()
开发者ID:bradleysnyder,项目名称:BeagleBoneBlack,代码行数:32,代码来源:methane_test.py


注:本文中的Adafruit_BBIO.SPI.SPI.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。