def _set_rate(self, value): self._check_open() value = int(value) lgpio.spi_close(self._handle) self._baud = value self._handle = lgpio.spi_open(self._port, self._device, self._baud, self._spi_flags)
def _set_clock_mode(self, value): self._check_open() if not 0 <= value < 4: raise SPIInvalidClockMode("%d is not a valid SPI clock mode" % value) lgpio.spi_close(self._handle) self._spi_flags = value self._handle = lgpio.spi_open( self._port, self._device, self._baud, self._spi_flags)
def close(self): if not self.closed: lgpio.spi_close(self._handle) self._handle = None self.pin_factory.release_all(self) super().close()
status = sbc.serial_read_byte(9999) check("serial_read_byte 1", sbc.BAD_HANDLE, status) status = sbc.serial_write(9999, []) check("serial_write 1", sbc.BAD_SERIAL_PARAM, status) status = sbc.serial_write(9999, [88, 77, 66, 55, 44, 33, 22, 11]) check("serial_write 2", sbc.BAD_HANDLE, status) status = sbc.serial_write_byte(9999, 256) check("serial_write_byte 2", sbc.BAD_SERIAL_PARAM, status) status = sbc.serial_write_byte(9999, 88) check("serial_write_byte 2", sbc.BAD_HANDLE, status) status = sbc.spi_close(9999) check("spi_close 1", sbc.BAD_HANDLE, status) status = sbc.spi_open(2, 1, 7777, 6666) check("spi_open 1", sbc.SPI_OPEN_FAILED, status) status, dummy = sbc.spi_read(9999, 0) check("spi_read 1", sbc.BAD_SPI_COUNT, status) status, dummy = sbc.spi_read(9999, 8888) check("spi_read 2", sbc.BAD_HANDLE, status) status = sbc.spi_write(9999, []) check("spi_write 1", sbc.BAD_SPI_COUNT, status) status = sbc.spi_write(9999, [88, 77, 66, 55, 44, 33, 22, 11])
count = 0 nrf.setLocalAddress("h1") nrf.setRemoteAddress("h2") while time.time() < end_time: #print(nrf.format_FIFO_STATUS()) #print(nrf.format_OBSERVE_TX()) if not nrf.isSending(): print("{}> {}".format(ver, test_words[count])) nrf.send(test_words[count]) count += 1 if count >= number_of_test_words: count = 0 time.sleep(0.5) else: nrf.setLocalAddress("h2") nrf.setRemoteAddress("h1") while time.time() < end_time: #print(nrf.format_FIFO_STATUS()) #print(nrf.format_OBSERVE_TX()) while nrf.dataReady(): print("{}< {}".format(ver, nrf.getPayload())) time.sleep(0.5) sbc.spi_close(nrf.spih)
def close(self): if not self.closed: lgpio.spi_close(self._handle) self._handle = None self.pin_factory.release_all(self) super(LGPIOHardwareSPI, self).close()