示例#1
0
 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)
示例#2
0
 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
示例#3
0
 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()
示例#4
0
 def write(self, buf):
     SpiPort.write(self, buf)
示例#5
0
 def read(self, nbytes, write=0x00):
     return SpiPort.read(self, nbytes)
示例#6
0
 def write(self, buf, start=True, stop=True):
     SpiPort.write(self, buf, start, stop)
示例#7
0
 def read(self, nbytes, write=0x00, start=True, stop=True):
     return SpiPort.read(self, nbytes, start, stop)