This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

I2C, I must be stupid.

Am I the only one who finds Zephyrs I2C implementation a little cludgy? Or am I just missing something?

It may be that I'm just used to bare metal I2C but I can't seem to figure out how I can send a few bytes, followed by 512 zero's without allocating a 514 byte array?

What I'm looking for is and i2c_write() that I can tell not to send an I2C_MSG_STOP....

Or am I just looking at it the wrong way?

Thanks folks, I promise I'm working hard to get past the dumb questions.

  • Hello Paul,

    Am I the only one who finds Zephyrs I2C implementation a little cludgy? Or am I just missing something?

    Since the Zephyr RTOS contains a lot of functionality, higher complexity is almost given and finding a good entry point can be challenging. So no, you are not stupid. Confused maybe, but I can definitely feel you there :-)

    What I'm looking for is and i2c_write() that I can tell not to send an I2C_MSG_STOP....

    A good starting point should be the I2C API documentation. If the peripheral to use is configured correctly in the devicetree and enabled via Kconfig, it should pretty much be straight forward to use functions like, i2c_write().

    You could also have a look at this example for your reference, demonstrating a simple use case.

    Regards,

    Markus

  • OK, I acknowledge that the scope of my question was a bit broad. Lets zoom in on an example:
    I want to send 

    0x40, 0x00, 0x00..... and another 509 of them to i2c address 25 in one transaction.

    What I don't want to do is
    uint8_t buffer[513];

    It's not clear to me that this is possible? But I may just be looking at it wrong...

  • CASWA_PK said:

    What I don't want to do is
    uint8_t buffer[513];

    It's not clear to me that this is possible? But I may just be looking at it wrong...

    Why would you not want to do that? The i2c_write() / i2c_transfer() API is designed to be assigned with a buffer and its size.

    Regards,

    Markus

  • Good question. It's probably because I've come from a decade (or so) of developing on  8 bit hardware and pulling 513 bytes off the stack seems like a dumb way to solve the problem?

  • CASWA_PK said:
    Good question. It's probably because I've come from a decade (or so) of developing on  8 bit hardware and pulling 513 bytes off the stack seems like a dumb way to solve the problem?

    I understand. I would recommend you to give it a try and play a little around. If you have specific suggestions on how we can improve our software, you are of course welcome to report them to us :-)

Related