drivers: i2c: enforce i2c stop flag in last i2c_transfer_cb msg
The i2c_transfer API specifies that the I2C_MSG_STOP flag implicitly
is set for the last message in a i2c_transfer(). This is identical to
explicitly setting the I2C_MSG_STOP flag in the last message, which is
what every driver which properly adheres to this specification does.
The i2c_transfer_cb API is seemingly identical to the i2c_transfer_api,
it references it using @see i2c_transfer(), while providing a callback,
and being available from isr context. This commit extends the wrapper
to provide the following guarantees also present in the i2c_transfer API:
- If num_msgs is 0, no transfer will occur
- The last message of the transfer implies a stop condition
This allows for users to use both functions interchangeably, while
removing handling of num_msgs = 0 and last message missing stop cond
from device drivers.
Additionally a check for num_msgs == 0 is added to prevent any transfer
and immediately call back with success then return without invoking
the transfer_cb API.
Signed-off-by:
Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Loading
Please sign in to comment