I2C SPI USB CAN eSPI Cable Testing View All Quick Start Guides User Manuals Software Downloads Knowledge Base Videos Case Studies App Notes White Papers Sales Support About Us
Products Blog Sales Support Contact Search
How Do I Implement I2C Master Register Read with the Aardvark I2C/SPI Host Adapter?
Rena Ayeras

Question from the Customer:

I am using the Aardvark I2C/SPI Host Adapter with Aardvark Software API via Python and I need to communicate with registers. I noticed that the Python API supports functions aa_i2c_write and aa_i2c_read, which perform I2C Master write and I2C Master read respectively.  Is there an API function to perform I2C Master register read?

Response from Technical Support:

Thanks for your question! The Master Write-Read (also known as Master Register Read) is actually a combination of two I2C transactions, which is duplicated by calling these functions directly. There are two ways you can perform a register read, which are described below.

API Functions to Call for Register Read

  • The first API call is aa_i2c_write() with the AA_I2C_NO_STOP flag, and contain the device register address from which you wish to read.
  • The second API call is aa_i2c_read(), which is for the number of bytes you wish to read.

Full I2C Transaction with NO_STOP

Using the NO_STOP flag on the write combines the two API calls into a single I2C transaction. Here is an example of a full I2C transaction:

[Start] [Device Addr][W] [Register Addr] [Start] [Device Addr][R] [data] ... [data] [Stop]

Full I2C Transaction without NO_STOP

You can achieve the same operation with two transactions; the only difference would be excluding the NO_STOP flag. In this case, the I2C transaction would look like this:

[Start] [Device Addr][W] [Register Addr] [Stop] [Start] [Device Addr][R] [data] ... [data] [Stop]

About API Bindings

The Total Phase API bindings support Python 2.5 though to 3.6. Sample code is available, which can used as is, or customized for your specifications. For more information about Aardvark Software API, please refer to the API Document section of the Aardvark I2C/SPI Host Adapter User Manual. We also provide detailed examples of using API in our Software API Knowledge Base.

Additional resources that you may find helpful include the following:

We hope this answers your question. If you have other questions about our host adapters or other Total Phase products, you can contact us at sales@totalphase.com. You can also request a demo that applies to your application.

Request a Demo