The problem I have is that 3 i2c devices, each on its own i2c bus and therefore instance, are running into contention when being accessed from 3 different threads (1 thread per i2c bus instance)
Although the i2c the driver is thread safe upon digging deeper into the driver I’ve found that there is a mutex defined as a static member in the class which looks to be the cause of the contention, please see below for more background info.
My question is, has any one got any tips on how to work around this or have I missed something or am I doing something wrong?
Thanks in advance,
For the code in question please see line 240 here.
I have an STM32F4 device where we are using all 3 of it’s i2c buses, using mbedOS 6.9.0
On one bus is a very slow device that takes, say 200+ ms, to update (e.g. return from an i2c.write)
On the two other i2c buses is a single sensor of the same type. It’s not possible to change the i2c address on this particular sensor and it’s particularly sensitive to being read ‘often’.
Each device is being written and read from it’s own thread.