Wire Lock Status

Is there a way to check if the Wire object is locked? It doesn't look like trylock() is implemented.


There is no tryLock() as you discovered. And actually it doesn't exist one layer farther in, in the HAL layer either. It does exist one layer up from that as it's an os_mutex_recursive_t, but there's no way to get the handle for it.

1 Like

Does it make sense to make an external lock for Wire and use that instead of the built in lock/unlock functions? I know that the power management thread for bsom tries to talk to the pmic/fuel gauge, but if that thread is disabled, would there be any other thread using the builtin Wire lock?

Fuel gauge and PMIC on the B SoM is the only thing that uses Wire from the system thread. On the Boron, it uses Wire1 so it won't interfere.

You could use your own mutex, since it's really just protecting your code from itself. You don't even need to lock if you are only using Wire from the application loop thread, but you do if you are also using it from a software timer or worker thread.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.