Open jerome60 opened 1 year ago
Hey @jerome60, have you made and progress or tried anything? I'm also curious and would love to be help.
Hi @floriangmeiner , I worked a little on the subject which I put aside for the moment. I added SPI and I2C functions to interface with the DLL which already has these functions for the moment it did not work. I can use this code for you to move forward on it if you want?
` def set_i2c_sda_pin(self, device_number, pinid):
rv = self.lib.jtagcore_i2c_set_sda_pin(self._jtag, device_number, pinid);
self._check_return(rv)
return rv
def set_i2c_scl_pin(self, device_number, pinid):
rv = self.lib.jtagcore_i2c_set_scl_pin(self._jtag, device_number, pinid);
self._check_return(rv)
return rv
def i2c_set_write_read(self, device_number, i2cadr, data):
if isinstance(data, str):
tmp_buffer2 = data.encode("utf-8")
rv = self.lib.jtagcore_i2c_write_read(self._jtag, i2cadr, 0, 16, tmp_buffer2, 0, 0);
if rv < 0:
print ("JTAG chain error !")
elif rv == 0:
print ("Warning : Device Ack not detected!")`
in JTAGCORE.py
and jtagbs.py ` def i2c_set_sda_pin(self, pins):
if isinstance(pins, str) or isinstance(pins, int):
pins = [pins]
for i in range(0, len(pins)):
pin = pins[i]
if isinstance(pin, str):
pin = self.lookup_pinid(pin)
self.jtag.interface.set_i2c_sda_pin(self.deviceid, pin);
if self.autoscan:
self.jtag.scan()
# self._check_return(rv)
# return rv
def i2c_set_scl_pin(self, pins):
if isinstance(pins, str) or isinstance(pins, int):
pins = [pins]
for i in range(0, len(pins)):
pin = pins[i]
if isinstance(pin, str):
pin = self.lookup_pinid(pin)
self.jtag.interface.set_i2c_scl_pin(self.deviceid, pin);
if self.autoscan:
self.jtag.scan()
# self._check_return(rv)
# return rv
def set_i2c_write_read(self, i2cadr, data):
self.jtag.interface.i2c_set_write_read(self.deviceid, i2cadr, data)`
and in main.py `#lattice.i2c_set_sda_pin("IOI12")
Hello, it's great work. is there any progress on spi and i2c support? I might be able to contribute on the subject.