4. Analyzing The Application Example

This section analyzes an example application demonstrating the use of the I2C adapter, based on the freertos_retarget sample code found in the SDK. It implements a simple request/response communication scenario over the I2C interface using the I2C adapter layer.

In this application DA1459x is configured as I2C master while HS3001 sensor is used as an I2C slave device. Link to the example. Follow the README mentioned on the Github to run the example code.

4.1. Application Structure

The I2C master initiates a write-then-read transaction sending a request string to the slave.

Depending on the value of the I2C_ASYNC_EN macro, a synchronous or asynchronous I2C read operation is attempted.

'I2C Write & Read - Main Execution Path'

Figure 2 I2C Write & Read - Main Execution Path

It is essential that developers must not call asynchronous related APIs without guaranteeing that the previous asynchronous transaction is finished. To ensure this, after triggering an asynchronous I2C read transaction, the calling task blocks its execution until the arrival of a freeRTOS signal, indicating the end of the current I2C operation.

'Async I2C write & read - Callback Function Execution Path'

Figure 3 Async I2C write & read - Callback function Execution Path