Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Accessing i2c on windows via i2c-tiny-usb



  • Hi All,

    I have made a small Qt program that runs on a bananapi. this is an ARM chip (Allwinner A20), with native I2C pins. I have made the below linux code to talk to i2c: full code

    I would like to access i2c also on windows. I don't have an accessable i2c port there, so I'm planning to use the i2c-tiny-usb. How can I access the i2c-tiny-usb on windows in my Qt program?

    Kind regards,
    Cedric

    #include <linux/i2c.h>
    #include <linux/i2c-dev.h>
    #include <sys/ioctl.h>
    init():
    i2cHandle = open("/dev/i2c-2", O_RDWR); //get adapter string from above routines
    opResult = ioctl(i2cHandle, I2C_TENBIT, 0); //device is 7 bit address
    read():
    opResult = ioctl(i2cHandle, I2C_SLAVE, msg.address);
    opResult = ::read(i2cHandle, msg.buffer, msg.length);
    write():
    opResult = ioctl(i2cHandle, I2C_SLAVE, msg.address);
    opResult = ::write(i2cHandle, msg.buffer, msg.length);
    close():
    close(i2cHandle);


  • Lifetime Qt Champion

    well the site says
    " A windows demo driver and demo application is included to get you started immediately."
    So that seems like a good place to start. How ever that sample talks to driver would be the same
    for Qt.


Log in to reply