nRF5 SDK v12.1.0
TWI transaction manager

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:

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:

static app_twi_transfer_t const transfers[] =
{
APP_TWI_WRITE(device_address, &register_address, 1, APP_TWI_NO_STOP),
APP_TWI_READ (device_address, p_buffer, 4, 0)
};
static app_twi_transaction_t const transaction =
{
.callback = transaction_callback,
.p_user_data = NULL,
.p_transfers = transfers,
.number_of_transfers = sizeof(transfers)/sizeof(transfers[0])
};
APP_ERROR_CHECK(app_twi_schedule(&m_app_twi, &transaction));

The API for this module is available here: TWI transaction manager. See the TWI Transaction Manager Example for a usage example.


Documentation feedback | Developer Zone | Subscribe | Updated