I am working with an I2C device that will be used for lengthy write and read transactions. There are multiple masters on this bus, any of which could send and start a command, thus taking ownership of the bus.
I am looking at using the Aardvark I2C/SPI Host Adapter for this project. How would I “claim the bus” to prevent stops from occurring between write and read transactions? Which applications could work for me?
Response from Technical Support:Thanks for your question! We have two software applications that could serve your purpose: the Control Center Serial Software and Aardvark Software API. Both applications can be used to run commands with the “no-stop” feature.
The Control Center Serial Software is an easy-to-use application that provides access to all the features of the Aardvark adapter. You have the option to manually enter commands or run commands automatically by creating an XML batch script.
With the GUI dialogs, you can easily set commands. To set the no-stop feature, all you need to do is check the No Stop option as shown below.
For a complete example of executing the stop command, take a look at this article - In Batch Mode, How Do I Control Stop Bits when Sending Data to an I2C Device? It also provides an example of using batch scripts.
You can create batch scripts in XML, which can be saved and run when needed. A built-in help system describes each command via GUI, as well as functional examples of batch scripts that can be used as-is or modified as needed for your specifications.
For more information about Batch Scripts, please refer to Control Center Serial Software Series: XML Batch Scripting for Automated Tasks.
The Aardvark Software API library includes a command that combines write and read functions with the no-stop condition: aa_i2c_write_read.
This Master Write-Read command (also known as Master Register Read) is a combination of two I2C transactions. Using the AA_I2C_NO_STOP allows these two calls to operate as a single I2C transaction.
Using the stop flag results in a single I2C transaction:
[Start] [Device Addr][W] [Register Addr] [Start] [Device Addr][R] [data] ... [data] [Stop]
If the AA_I2C_NO_STOP was not used, there were would two separate I2C transactions:
[Start] [Device Addr][W] [Register Addr] [Stop][Start] [Device Addr][R] [data] ... [data] [Stop]
Using the API command aa_i2c_write_read() would be the easiest way to execute Master Register Read. This function writes a stream of bytes to the I2C slave device, which is followed by a read from the same slave device.
This is a combination of aa_i2c_write() and aa_i2c_read(), except that these functions are performed as a single operation. The AA_I2C_NO_STOP condition is taken care internally by the state machines; it does not need to be invoked.
The syntax:
int aa_i2c_write_read (Aardvark aardvark,aa_u16 slave_addr,
AardvarkI2cFlags flags,
aa_u16 out_num_bytes,
const aa_u08 * out_data,
aa_u16 * num_written,
aa_u16 in_num_bytes,
aa_u08 * in_data,
aa_u16 * num_read);
Here is an example of values to apply. In this case, the command is to read 5 bytes from the register address 0x11:
For more information, please refer the API Documentation section of the Aardvark I2C/SPI Host Adapter User Manual.
We hope this answers your questions. Additional resources that you may find helpful include the following:
If you want more information, feel free to contact us with your questions, or request a demo that applies to your application.