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
What Are the Details of the Software Arguments when Reading I2C Data Using Aardvark API Software?
Rena Ayeras

Question from the Customer:

I am running tests with the Aardvark I2C/SPI Host Adapter using the Aardvark API Software. I have a question about the API Master Write-Read command aa_i2c_write_read. I input eight values using Arg 8 (in_data) to an array, but when I display array[0] and [1] to different elements, they show the same value. Let’s say I input 4 bytes, {00,11,22,33}  - what is the data sequence – what exactly should I read back?

Here are snippets of the code I’m using:

Snippet of code

Code snippet

Here’s the captured data:

 

Captured data

 

Here’s another question, I’m not sure what Arg 7 and Arg 9 represent. I assume Arg 7 sets the number of bytes I want to read – is that correct? Can you define what all those arguments indicate?

Response from Technical Support:

Thanks for your questions!  It looks like the data you want to read may not be transmitted over the bus. In addition to the meaning of the arguments and how to read the data, we have a tip for making sure the slave response data is being transmitted over the bus.

Reading Array Data with API Software

The argument data_in within the API is actually a pointer to the data or an array that is being read from the slave. In your code, make sure the contents are saved and read back from an array and not some other data structure.  For more information, please refer to the API examples using the data_in argument, as well as the API Documentation section in the Aardvark I2C/SPI Host Adapter User Manual.

Tip: How to Ensure Data is Being Transmitted

We recommend confirming if the data from the slave is actually being read or available on the bus. You can easily do that by monitoring the bus with a non-intrusive protocol analyzer, such as the Beagle I2C/SPI Protocol Analyzer.

Aardvark API Arguments

Here are the descriptions of each argument:

Arg 1: aardvark - Aardvark handle Arg 2: slave_addr - I2C slave/device address Arg 3: flags - to mention special operations given in the notes section of the manual Arg 4: out_num_bytes - number of bytes to write (max 65535) Arg 5: out_data - pointer to the data to be written Arg 6: num_written - number of bytes that were actually written/put on the bus Arg 7: in_num_bytes - number of bytes that are expected to be read (max 65535) Arg 8: in_data - Pointer to the buffer data received Arg 9: num_read - Actual number of bytes read

Details about Arg 9

API software updates Arg 9 with the value of the number of bytes that were read. For example, if you received AA BB CC as the slave response, then Arg 9 would be updated as 3, which indicates 3 bytes of data were received. To verify if your slave actually read the data, you can check the value acquired in Arg 9.

  • If the value of Arg 9 is 0, this indicates nothing was read: the data pointed by Arg 8 was not changed.
  • If the value of Arg 9 is non-zero, this indicates read data was collected by in_data: the data pointed by Arg 8 is the current data that was read.

Additional resources that you may find helpful include the following:

We hope this answers your questions. If you have other questions about our host adapters or other Total Phase products, feel free to email us at sales@totalphase.com. You can also request a demo that is specific for your application.

Request a Demo