def __init__(self, id=-1, baudrate=10000000, polarity=0, phase=0, bits=8, firstbit=MSB, sck=None, mosi=None, miso=None, pins=None, controller=None, cs=0, cs_hold=3, spi_mode=0): mode = ((polarity << 1) | phase) if spi_mode is None else spi_mode SpiPort.__init__(self, controller, cs, cs_hold, mode) self.init(baudrate=baudrate, polarity=polarity, phase=phase, bits=bits, firstbit=firstbit, sck=sck, mosi=mosi, miso=miso, pins=pins)
def __init__(self, bus=None, controller=None, cs=0, cs_hold=3, spi_mode=0, *args, **kwargs): SpiPort.__init__(self, controller, cs, cs_hold, spi_mode) self.lsbfirst = False
def read_jedec_id(spi: SpiPort) -> bytes: """Read flash device JEDEC identifier (3 bytes)""" jedec_cmd = Array('B', (SerialFlashManager.CMD_JEDEC_ID, )) return spi.exchange(jedec_cmd, 3).tobytes()
def write(self, buf): SpiPort.write(self, buf)
def read(self, nbytes, write=0x00): return SpiPort.read(self, nbytes)
def write(self, buf, start=True, stop=True): SpiPort.write(self, buf, start, stop)
def read(self, nbytes, write=0x00, start=True, stop=True): return SpiPort.read(self, nbytes, start, stop)