I have 2 threads accessing several devices on a shared I2C bus - I am using the I2C framework on SSP 1.3.0
I thought that with this framework I could open the different instances in different threads such as below and that each write and read etc is thread aware and will automatically acquire and relinquish mutexes etc:
I am however having an issue where there appears to be a deadlock where one thread will not give up the i2c mutex as it seems to be waiting on a event flag. As far as I can tell the UI_Thread needs the i2c mutex but the pwr_mgmt_thread will not relinquish it as it is suspended until this event flag is set - but this event flag is not something I'm explicitly setting in my code:
I have tried changing thread priorities but I don't think that is the issue - could anyone shed any light on this? I have the TraceX file but for some reason can't attach it to this post - though am not sure it tells me anything more than the RTOS resources tab. Am I missing something simple?
In reply to adboc:
garyjYou can leave the framework open for each device and just do your read, write, and write-read calls at any time from each thread. The framework will handle the mutual exclusion to the bus. In addition, you can lock the bus so that all bus transfers will be only for the thread that dose the lock until the bus is unlocked.
In reply to James: