how to do I do I2C master reads and writes in background?

mchahn
Posts: 17
Joined: Fri Sep 18, 2020 6:31 am

how to do I do I2C master reads and writes in background?

Postby mchahn » Tue Nov 09, 2021 1:44 am

I apologize if this is a duplicate question but forum search always gives me an error page. I couldn't find any good answer on google.

I need to read bytes from one slave, perform heavy calculations, and then send result bytes to another slave. I would like to do the I2C master reads and writes in the background so loop time isn't calc time plus I2C IO time but just calc time.

I think I have to use a standard interrupt routine and task setup (is this true?). The docs don't have an example and the only code I've found is for a slave and the code is just a github gist https://gist.github.com/timkoers/d5384d ... 29003ef92b of unknown status (I'm sending a message to the author to ask about this).

The gist code does a standard I2C setup and then uses i2c_slave_read_buffer() on every interrupt. It doesn't check the interrupt number. This seems very simple. In my master case I was hoping to use something like i2c_slave_write_buffer() but the docs say that is only for slaves. Is there a way to set up a send in the task with a buffer, then just be notified in an interrupt when the send is finished?

Does anyone have an example of this kind of I2C code? Also, any hints on what I should do would be greatly appreciated.

Who is online

Users browsing this forum: No registered users and 92 guests