How to remove start bit from an I2C transfer in zephyr

Hello,

I am developing a driver for the vl53l5cx TOF sensor from ST, however their sequential write format looks as such:

This is problematic for me since I can get the address, and register index sent correctly with the stop bit at the end, however zephyr always sends a start bit for the data being written and I have not found a way to disable this. How can I do this using sdk 1.9.1?

Thanks,

Jacob

Parents
  • Hello!

    What function(s) are you currently using when you try to write? i2c_write? i2c_burst_write? i2c_transfer?

    It seems to me that what you want is similar to i2c_burst_write, but with a stop condition after sending the buffer address, you might have to set up your write manually using i2c_transfer since you want this irregular formatting.

    Perhaps something like this:

    struct i2c_msg msg[2];

    msg[0].buf = &start_addr;
    msg[0].len = 1U;
    msg[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP;

    msg[1].buf = (uint8_t *)buf;
    msg[1].len = num_bytes;
    msg[1].flags = I2C_MSG_WRITE | I2C_MSG_STOP;

    i2c_transfer(dev, msg, 2, dev_addr);

    Best regards,

    Einar

Reply
  • Hello!

    What function(s) are you currently using when you try to write? i2c_write? i2c_burst_write? i2c_transfer?

    It seems to me that what you want is similar to i2c_burst_write, but with a stop condition after sending the buffer address, you might have to set up your write manually using i2c_transfer since you want this irregular formatting.

    Perhaps something like this:

    struct i2c_msg msg[2];

    msg[0].buf = &start_addr;
    msg[0].len = 1U;
    msg[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP;

    msg[1].buf = (uint8_t *)buf;
    msg[1].len = num_bytes;
    msg[1].flags = I2C_MSG_WRITE | I2C_MSG_STOP;

    i2c_transfer(dev, msg, 2, dev_addr);

    Best regards,

    Einar

Children
Related