eblot / pyftdi

FTDI device driver written in pure Python
Other
509 stars 212 forks source link

LSB first with MPSSE SPI? #344

Closed wuzhongjie1997 closed 1 year ago

wuzhongjie1997 commented 1 year ago

First of all, thanks for this wonderful project, it allows me to convert an FT2232H dongle into a swiss army knife in embedded debugging!

My question is as follows:

In an STM32 MCU, SPI ports can operate either MSB first or LSB first. No such option seems to exist in the SPI API docs, but according to FTDI AN114 Page 3, MPSSE supports both operating modes.

As confirmed using a logic analyzer, when i follow the SPI API example the data is sent MSB first. So, other than manually converting each byte in the input (and output) array, how can I configure MPSSE SPI to transmit/receive LSB first?

Thanks for reviewing!

eblot commented 1 year ago

First of all, thanks for this wonderful project, it allows me to convert an FT2232H dongle into a swiss army knife in embedded debugging!

Thanks.

So, other than manually converting each byte in the input (and output) array, how can I configure MPSSE SPI to transmit/receive LSB first?

Up to now this feature has never been asked and is not supported (as it would require just another combination of options, tests, etc.) but it should be moderately trivial to implement this.

You would need to replace all Ftdi.*_MSB constants in _exchange_half_duplex and _exchange_full_duplex methods from spi.py file with their Ftdi.*_LSB counterparts, see # MPSSE Commands around line 148 in ftdi.py file.

HTH.

wuzhongjie1997 commented 1 year ago

Thank you for the reply, closing as completed.