Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI & I2C #5

Open
jerome60 opened this issue Dec 11, 2022 · 6 comments
Open

SPI & I2C #5

jerome60 opened this issue Dec 11, 2022 · 6 comments

Comments

@jerome60
Copy link

Hello,
it's great work.
is there any progress on spi and i2c support?
I might be able to contribute on the subject.

@floriangmeiner
Copy link

Hey @jerome60, have you made and progress or tried anything? I'm also curious and would love to be help.

@jerome60
Copy link
Author

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?

@jerome60
Copy link
Author

` 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!")`

@jerome60
Copy link
Author

in JTAGCORE.py

@jerome60
Copy link
Author

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)`

@jerome60
Copy link
Author

and in main.py
#lattice.i2c_set_sda_pin("IOI12") #lattice.i2c_set_scl_pin("IOI10") #I2C_RET = lattice.set_i2c_write_read("5C","10") #print ('retour I2C',I2C_RET)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants