from binascii import hexlify
from pyftdi.ftdi import Ftdi
from pyftdi.spi import SpiController,SpiGpioPort
from sys import modules, stderr, stdout
import time
from array import array
def WriteFPGA(Slave,adress,value):
Slave.write([0xAA], True, True)
Slave.write([adress], True, True)
Slave.write([value], True, True)
def WriteFPGA2(Slave,adress,value,Gpio):
Gpio.write(0x1800)
Gpio.write(0x1000)
Slave.write([adress], True, True)
gpio.write(0x1800)
Gpio.write(0x1000)
Slave.write([adress], True, True)
Gpio.write(0x1800)
Gpio.write(0x1000)
Slave.write([value], True, True)
Gpio.write(0x1800)
spi = SpiController()
spi.configure('ftdi://ftdi:2232h/1',debug=0)
slave = spi.get_port(cs=0, freq=1E6, mode=0)
print(spi.frequency_max)