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

i2c driver ACK handling for bytes #382

Open
xopxe opened this issue Jan 18, 2021 · 0 comments
Open

i2c driver ACK handling for bytes #382

xopxe opened this issue Jan 18, 2021 · 0 comments

Comments

@xopxe
Copy link
Contributor

xopxe commented Jan 18, 2021

Is there a reason why this snippet

    if (len > 1) {
        i2c_master_read(cmd, (uint8_t *) data, len, I2C_MASTER_LAST_NACK);
    } else {
        i2c_master_read_byte(cmd, (uint8_t *) data, I2C_MASTER_ACK);
    }

in the i2c driver has different ack flags when reading single bytes?

I have a device that treats the i2c as a serial device (a Pixy2 camera), and the code scans one byte at a time to find a header sync. With the i2c driver as is, i'm missing each other byte, this is, between two reads there's a byte lost. If I change the ack flag to I2C_MASTER_LAST_NACK also for the i2c_master_read_byte call, everything works. It also works if I use the i2c_master_read for reading single bytes also.

I suppose that change can break other devices, but I don't fully understand how i2c is supposed to work in this case.

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

1 participant