- self.cs = 0
- self.freq = baudrate
- if polarity == 0 and phase == 0:
- self.mode = 0
- elif polarity == 0 and phase == 1:
- self.mode = 1
- elif polarity == 1 and phase == 0:
- raise ValueError("SPI mode 2 is not supported.")
- elif polarity == 1 and phase == 1:
- self.mode = 3
- else:
- raise ValueError("Unknown SPI mode.")
+ self._port.set_frequency(baudrate)
+ # FTDI device can only support mode 0 and mode 2
+ # due to the limitation of MPSSE engine.
+ # This means CPHA must = 0
+ self._port._cpol = polarity
+ if phase != 0:
+ raise ValueError("Only SPI phase 0 is supported by FT232H.")
+ self._port._cpha = phase
+
+ @property
+ def frequency(self):
+ return self._port.frequency