This is the latest (main) BeagleBoard documentation. If you are looking for stable releases, use the drop-down menu on the bottom-left and select the desired version.

Function rc_i2c_lock_bus

Function Documentation

int rc_i2c_lock_bus(int bus)

Locks the bus so other threads in the process know the bus is in use.

Locking a bus is similar to locking a mutex, it is a way for threads to communicate within one process when sharing a bus. This, however, is not a hard lock in the sense that it does not block and does not stop any of the other functions in this API from being called. It only serves as a flag that can be checked between threads if the user chooses to do so. This is encouraged in multithraded applications to prevent timing-sensitive i2c communication from being interrupted but is not enforced.

All read/write functions in this API will lock the bus during the transaction and return the lockstate to what it was at the beginning of the transaction. Ideally the user should lock the bus themselves before a sequence of transactions and unlock it afterwards.

Parameters

bus[in] The bus ID

Returns

Returns the lock state (0 or 1) when this function is called, or -1 on error.