GithubHelp home page GithubHelp logo

I2C contract violation about rp-hal HOT 4 OPEN

WBosonic avatar WBosonic commented on September 2, 2024
I2C contract violation

from rp-hal.

Comments (4)

jannic avatar jannic commented on September 2, 2024

@WBosonic, thanks for the report. I agree this looks wrong. However, are you sure it's an SP (stop) you see between the write operations? I'd expect a SR (repeated start), triggered by https://github.com/rp-rs/rp-hal/blob/main/rp2040-hal/src/i2c/controller.rs#L294:

                if first_byte {
                    if !first_transaction {
                        w.restart().enable();
                    }
                    first_byte = false;
                }

@ithinuel, if I read the git history correctly, that was added in #764. Do you remember why?

from rp-hal.

WBosonic avatar WBosonic commented on September 2, 2024

Ah yes it is an SR (I encountered this bug a while ago and misremembered).

From what I see the user facing I2C transaction does not actually check if the transaction type is the same as the one before.

from rp-hal.

jannic avatar jannic commented on September 2, 2024

Ah yes it is an SR (I encountered this bug a while ago and misremembered).

From what I see the user facing I2C transaction does not actually check if the transaction type is the same as the one before.

If I understand the datasheet correctly, it doesn't need to:

1 - If IC_RESTART_EN is 1, a RESTART is issued before the
data is sent/received (according to the value of CMD),
regardless of whether or not the transfer direction is
changing from the previous command; if IC_RESTART_EN
is 0, a STOP followed by a START is issued instead.
0 - If IC_RESTART_EN is 1, a RESTART is issued only if the
transfer direction is changing from the previous
command; if IC_RESTART_EN is 0, a STOP followed by a
START is issued instead.

So the fix could be as easy as removing w.restart().enable(); entirely?

from rp-hal.

ithinuel avatar ithinuel commented on September 2, 2024

Yes, provided that ic_restart_en is set (which it is).

from rp-hal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.