Adl bus library: bus access structure

Hi,

This is quite silly question to ask, but think its better to get it clear.

In the adl bus library, we use

s32 adl_busWrite ( s32 Handle, adl_busAccess_t * pAccessMode, u32 Length, void * pDataToWrite );

and

s32 adl_busRead ( s32 Handle, adl_busAccess_t * pAccessMode, u32 Length, void * pDataToRead );

apis to write or read from I2C or SPI device registers.

In the above apis the second parameter is " adl_busAccess_t * pAccessMode".

I always set it to
adl_busAccess_t i2cAccess = { 0, 0 };

In this bus access structure the 1st variable is Address and second one OPCODE

can anyone please explain me its significance, with short example.

From the Open AT Tutorial - Rev1.0 pdf:

Handle: Handle returned by the adl_busSubscribe function. pAccessMode: Bus access mode, defined according to the following type:

typedef struct 
{ u32 Address;                          
u32 Opcode; 
} adl_busAccess_t;

This parameter is processed differently according to the bus types:

Address: This is usable for both SPI and I2C buses. The address parameter allows 32 bits to be sent on the bus, before the read and the write process is started. The number of bits to send is set by the ADL_BUS_CMD_SET_ADD_SIZE IOCtl command. If less than 32 bits are required to be sent; only the most significant bits are sent on the bus.

Opcode: This parameter can be used only over the SPI bus. The Opcode parameter allows sending 32 bits over the bus before the read or the write process. The number of bits to send is set by the ADL_BUS_CMD_SET_OP_SIZE IOCtl command. If less than 32 bits are required to be sent; only the most significant bits are sent on the bus. Usable only for SPI bus (ignored for I2C bus).

For example: If “BBB” has to be sent over the bus the Opcode parameter has to be set to 0xBBB00000 value, and the OpcodeLength parameter has to be set to 12.

I hope that may help you in any way

It’s not that clear - I have recently tried to get some underestanding of this parameter. OpenAT Guide is really misleading.

First: note the difference between SPI and I2C -> in I2C you must have an address in transmission. In SPI - you don’t have to.

Since for I2C you set address size & the address itself in the adl_busI2CSettings_t structure it is already setup for the transmission. The adl_busAccess_t is something different and used only for SPI - these are additional address and opcode information that are used for some arbitrary master-slave protocol.

Moreover, there is an App Note “Bus Services Application Note” where it is stated both for Write&Read:

So as you can see the OpenATmanual can really do a mess in your mind …
regards
oscar