# Adl bus library: bus access structure

**URL:** https://forum.sierrawireless.com/t/adl-bus-library-bus-access-structure/7315
**Category:** Open AT
**Created:** [July 15, 2014, 12:25pm UTC](https://forum.sierrawireless.com/t/adl-bus-library-bus-access-structure/7315 "2014-07-15T12:25:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ashishkamble](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@ashishkamble](https://forum.sierrawireless.com/u/ashishkamble)
#### Post date: [July 15, 2014, 12:25pm UTC](https://forum.sierrawireless.com/t/adl-bus-library-bus-access-structure/7315/1 "2014-07-15T12:25:29Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Ruudje87](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@Ruudje87](https://forum.sierrawireless.com/u/Ruudje87)
#### Post date: [October 2, 2014, 9:55am UTC](https://forum.sierrawireless.com/t/adl-bus-library-bus-access-structure/7315/2 "2014-10-02T09:55:38Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

### Author: ![oscar\_mezyk](https://avatars.discourse-cdn.com/v4/letter/o/d78d45/32.png) [@oscar\_mezyk](https://forum.sierrawireless.com/u/oscar_mezyk)
#### Post date: [November 5, 2014, 2:34pm UTC](https://forum.sierrawireless.com/t/adl-bus-library-bus-access-structure/7315/3 "2014-11-05T14:34:06Z")

</div>

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:

> [@](#):
>
> To write on to the I2C bus, the following API has to be used.  
> s8 adl\_busWrite (u8 Handle, adl\_busAccess\_t \* pAccessMode, u32 Length, void \*pDataToRead)  
> Parameters  
>  Handle: The handle returned during the subscription of the bus using adl\_busSubscribe () function.  
>  pAccessMode: This should be left NULL for I2C bus.  
>  Length : This is the number of bytes to be written into the I2C bus.  
>  pDatatoRead: This is the buffer to write on the bus.

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