I have the following problem: I want to read out a motion sensor from Invensense (ICM-20602) through the spi interface with the FTDI USB Spi converter connected to a Debian linux system with a python3 program. I set up all the necessary libraries and drivers and I can set the CS line and also verified my MOSI, Clock and CS line outputs by an oscilloscope. There is also MISO input from the device but not what I would expect. I am sending the register address to the whois-register to get the device ID to verify that the read/write is working. I dont understand why the device is not responding properly. This is my code at the moment:
#pyspi - pyftdi
from pyftdi.spi import SpiController, SpiIOError
from struct import *
ctrl= SpiController()#spi
ctrl.configure('ftdi://ftdi:232h/1') # Assuming there is only one FT232H.
spi = ctrl.get_port(cs=0, freq=1E6, mode=0)# Assuming D3 is used for chip select.
write_buf = b'\x75\0xdf'
spi.write(write_buf,True,False)
read_1= spi.read(2, start=False, stop=True).tobytes()
id = spi.exchange([0x75,0xff,],2).tobytes()
#ctrl.get_port(cs=1, freq=1E6, mode=1)
print(read_1)
print(id)
There is no code error - only the read buffer is 0x00 or sometimes 0x10 but not what I would expect: the device ID: 0xAF
Has someone an idea how to get the device to answer properly?
By the way: the device is working properly with the invensense evaluation board - so the device should work properly.