Any method to reserve/lock a device while performing another operation such as asserting GPIO?

I'm developing with nrf connect sdk.

I have an peripheral IC with a mcu interface enable pin.  This product is very focused on battery life.  The peripheral IC has higher power draw when the interface is enabled so we must keep the interface disabled as much as possible.  The interface in question is I2C, and its important that no operations be ongoing while enabling the interface, otherwise the device may miss part of the I2C operation and lock-up.  

So I need a way to assert the GPIO for the peripheral IC's mcu interface enable while the I2C bus is idle for some time before and after.   There are multiple other IC's on the same bus which need to be prevented from accessing the I2C bus.

I see the I2C driver api implementations have locking mechanisms internally.  I'm guessing that I will need to extend the I2C API to add a lock/unlock API, and then implement the same within the i2c_nrfx_twi* driver implementations.  

Alternatively I could implement a virtual bus around the i2c bus in dts that provides an extended interface beyond the basic I2C interface with support for locking/unlocking.   I think I could do this without modifying SDK code, though it seems a bit inefficient, 

Is there any other way to achieve it without modifying the zephyr SDK?

a*

Related