from binascii import hexlify
from pyftdi.ftdi import Ftdi
from pyftdi.spi import SpiController
from sys import modules, stderr, stdout
spi = SpiController()
spi.configure('ftdi://::/1')
slave = spi.get_port(cs=1, freq=500000, mode=0)
print("Vitesse SPI max:",spi.frequency_max/1.0E6,"MHz")
jedec_id = slave.exchange([0x9f], 3).tobytes()
print(jedec_id)
Vitesse SPI max: 30.0 MHz
b'\xff\xff\xff'
import struct
gpio = spi.get_gpio()
print( hex( gpio.direction) )
gpio.set_direction(0x0800, 0x0100)
gpio.write(0x0100)
0x7b
gpio.write(0x0100)
slave.write([int(0xAA)], True, True)
slave.write([int(0xEB)], True, True)
slave.write([int(0x01)], True, True)
gpio.write(0x0000)
gpio.write(0x0100)