Why I2C_SMBUS_BLOCK_MAX is limited to 32 bytes?

后端 未结 1 575
余生分开走
余生分开走 2021-02-09 14:14

I\'m trying to configure a SAA6752HS chip (a MPEG-2 encoder) through I2C bus using a Raspberry Pi as a development kit. It was a piece of cake until I had to write at the addres

相关标签:
1条回答
  • 2021-02-09 14:43

    Here's the documentation for the Linux i2c interface: https://www.kernel.org/doc/Documentation/i2c/dev-interface

    At the simplest level you can use ioctl(I2C_SLAVE) to set the slave address and the write system call to write the command. Something like:

    i2c_write(int file, int address, int subaddress, int size, char *data) {
        char buf[size + 1];               // note: variable length array
        ioctl(file, I2C_SLAVE, address);  // real code would need to check for an error
        buf[0] = subaddress;              // need to send everything in one call to write
        memcpy(buf + 1, data, size);      // so copy subaddress and data to a buffer 
        write(file, buf, size + 1); 
    }
    
    0 讨论(0)
提交回复
热议问题