
UEXT connector allow many and different devices to be attached to it.
To may they all work together without collisions I2C protocol is used to address them.
The protocol is like this:
<OLMX> <DEV-ID> <DEV-#> <COMMANDs> <ARGUMENTS>
<OLMX> – this is the unique OLIMEX I2C address which is 0x48 this address is used to talk to all Olimex UEXT modules.
<DEV-ID> – this is the ID of every UEXT module TYPE which is attached to the I2C bus, for instance if we want to talk to MOD-IO2 this ID is 0x02
<DEV-#> – as we can have many MOD-IO2 connected on the I2C but this is the MOD-IO2 address number which we talk to, each MOD-IO2 by default have address 0xA0, this address can be re-programmed to other value so many MOD-IO2 to be connected together.
<COMMANDs> – allow specific command to be sent to the UEXT module like switch relays, read GPIOs, read AINx etc.
Set-relay command is 0x40, Set-new-address command is 0xB0, read AIN0 is 0x10 read AIN7 is 0x17 and so on.
if we use I2CTOOL we can talk easily to MOD-IO2 connected to iMX233-OLinuXino, for instance to switch both relays ON we can do:
$ ./i2c-tool -w 0 0x48 4 0x02 0xA0 0x40 0x03
where -w means I2C write, 0 – this is I2C channel we write to channel 0, 0x48 is OLIMEX I2C address, 4 is number of bytes to follow, 0x02 is MOD-IO2 ID, 0xA0 is default MOD-IO2 address, 0x40 is set-relay command, 0x03 is set both relays
other useful commands are:
1. CHANGE DEVICE ADDRESS, MOD-IO2 have jumper when you connect it the MOD-IO2 address switch from the default 0xA0 to the temporary 0xF0 (to not mess with the other devices on the I2C bus) and you can assign any address to it wih the command:
$ ./i2c-tool -w 0 0x48 4 0x02 0xF0 0xB0 <new-address>
2. SET TRIS REGISTERS
./i2c-tool -w 0 0x48 4 0x02 0xA0 0x01 <data>
3. SET LAT REGISTERS
./i2c-tool -w 0 0x48 4 0x02 0xA0 0x02 <data>
4. GET PORT REGISTER
./i2c-tool -w 0 0x48 3 0x02 0xA0 0x03
./i2c-tool -r 0 0x48 1
5 SET PULLUPS
./i2c-tool -w 0 0x48 4 0x02 0xA0 0x04 <data>
6. GET ANALOG INPUTS
./i2c-tool -w 0 0x48 3 0x02 0xA0 [0x10|0x11|0x12|0x13|0x17]
./i2c-tool -r 0 0x48 2
where 0x10 – analog input 0
0x11 – analog input 1
0x12 – analog input 2
0x13 – analog input 3
0x17 – analog input 7
Recent Comments