naren0nindiatimes / tinyos-main

Automatically exported from code.google.com/p/tinyos-main
0 stars 0 forks source link

atm128 I2C driver sends slave address on non-start write packet #39

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use I2CPacket.write() to write write anything to the I2C bus; use a START 
condition but not a STOP condition
2. Use I2CPacket.write() a second time to keep writing to the same slave 
device; do not use START condition; may or may not use STOP condition

In the second write the slave address will be written again even though it does 
not have a START condition, which will cause the slave device to accept it as 
part of the data.

The problem seems to be in "tos/chips/atm128/Atm128FIF2CMasterPacketP.nc", 
inside of I2CPacket.write(), on line 248, it sends the slave address if it's 
not a I2C_START condition and length of packet is greater than 0:

241:      if (flags & I2C_START) {
242:        call I2C.setStart(TRUE);
243:    //  call WriteDebugLeds.led0On();
244:        state = I2C_STARTING;
245:      }
246:      else if (len > 0) {
247:        state = I2C_DATA;
248:        call I2C.write(((packetAddr & 0x7f) << 1) | ATM128_I2C_SLA_WRITE);
249:      }

I believe it should be something like this:

241:      if (flags & I2C_START) {
242:        call I2C.setStart(TRUE);
243:    //  call WriteDebugLeds.led0On();
244:        state = I2C_STARTING;
245:      }
246:      else if (len > 0) {
247:        state = I2C_DATA;
248:        call I2C.write(packetPtr[index]);
249:        index++;
250:      }

Original issue reported on code.google.com by anderson...@spensatech.com on 5 May 2011 at 5:31

GoogleCodeExporter commented 8 years ago

Original comment by philip.l...@gmail.com on 11 May 2011 at 11:29

GoogleCodeExporter commented 8 years ago
Fix applied.

Original comment by philip.l...@gmail.com on 26 May 2011 at 6:55

GoogleCodeExporter commented 8 years ago
Hi,phils

there's a typo in your commit 
(http://code.google.com/p/tinyos-main/source/diff?spec=svn5602&r=5602&format=sid
e&path=/trunk/tos/chips/atm128/i2c/Atm128I2CMasterPacketP.nc), line248 
"I2CWrite." should be "I2C.write", can you please fix it? thanks

Original comment by qy.n...@gmail.com on 19 Jun 2011 at 7:57

GoogleCodeExporter commented 8 years ago
Miklos -- looks like you fixed the I2CWrite problem.

Original comment by philip.l...@gmail.com on 21 Jun 2011 at 6:57