The TWI transaction manager library provides functions to create and execute transactions consisting of one or more data transfers via the two-wire interface (TWI).
Transactions can be run in the background or in blocking mode:
- Background : When the application schedules a transaction in the background ( app_twi_schedule ), it receives a callback from the library when the transaction has completed or when the transaction is interrupted due to an error.
- Blocking mode : When an application schedules a transaction in blocking mode ( app_twi_perform ), the function does not return until the transaction has finished (successfully or with an error).
Transactions can be requested from different contexts, including interrupt handlers. The library takes care of proper synchronization.
You can suppress the generation of a stop condition for selected transfers. In this case, the following transfer will start with a repeated start condition. The following example code shows how to first write one byte (for example, an register address) and then read 4 bytes, without a stop condition in between:
The API for this module is available here: TWI transaction manager . See the TWI Transaction Manager Example for a usage example.