Giter Site home page Giter Site logo

Comments (5)

nox771 avatar nox771 commented on August 20, 2024

The hardware isn't going to function properly if the pullups aren't there regardless of the order you issue calls. The pinConfigure() which is used by setSCL() and setSDA() will abort on bus busy (there is a low-level way to circumvent that, but it is a pointless exercise if pullups don't exist).

You can use getSCL() and getSDA() to verify pin changes have occurred.

Regarding setSCL() and setSDA() before begin(), the code is setup to utilize existing pin settings if they are not provided in the begin() call, so the code is already configured to operate in either order.

from i2c_t3.

mbenkmann avatar mbenkmann commented on August 20, 2024

I can only tell you that using setSCL()/setSDA() did not work for me with my Teensy 3.2. Execution stopped at the setSCL()/setSDA() call and did not continue no matter how long I waited. The only way I could change the SCL/SDA from pins 19/18 to 16/17 was to use begin(I2C_MASTER, 0,I2C_PINS_16_17). It didn't matter which order I tried. I admit that I was just guessing that the missing pullups on 19/18 were the reason. Just to avoid confusion. Of course I have pullups on 16/17. But I shouldn't need pullups on 19/18 if I don't want to use these pins for i2c.

from i2c_t3.

nox771 avatar nox771 commented on August 20, 2024

This is an interesting logical problem. setSCL/setSDA make an assumption that the current pins are on an active bus. Try this as a patch, comment out line #394 in the pinConfigure_() in i2c_t3.cpp, then try setSCL/setSDA method again.

 //if(reconfig && (*(i2c->S) & I2C_S_BUSY)) return 0; // if reconfig return immediately if bus busy (reconfig=0 for init)

That will ignore bus busy status (while not affecting reconfig function). Let me know if this works and I can push it as a patch.

from i2c_t3.

mbenkmann avatar mbenkmann commented on August 20, 2024

I'll try it but it might take a while till I get around to it. But just conceptually I would like it better if there was a special case for setSCL/setSDA being used before begin. Something like:

void setSCL(uint8_t pin) {
   if (begin not yet called) {
       i2c->currentSCL = pin;
    } else {
       pinConfigure_(i2c, bus, pin, i2c->currentSDA, i2c->currentPullup, 1); 
    }
   }

This way, if any of the begin() functions is later called that does not specify a SCL pin, the one set before begin will be used. As far as I can tell there is no need to verify the validity of the pin if setSCL() is called before begin() because the check will be done when begin() is called.

from i2c_t3.

nox771 avatar nox771 commented on August 20, 2024

I uploaded a v11 version with a fix for this. It seemed to work on my test case. If you have further problems then let me know.

from i2c_t3.

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.