[Tinyos-help] about I2C in tinyos 2.0
jianxin chen
jianxinchen06 at gmail.com
Wed Oct 8 03:06:55 PDT 2008
Dear all,
In my system a compass is added to MICAz node by I2C communication mode
in tinyos 2.0.
Now I want to obtain the compass output periodically.
The program follows, but I can not obtain the compass output.
In the configuration file
{
......
Compass.Resource -> ATM128I2CMasterC.Resource;
Compass. I2CPacket -> ATM128I2CMasterC.I2CPacket;
}
In the main fie we define
module Compass{
.....
Interface Resource;
Interface I2CPacket<TI2CBasicAddr>
}
In the Timer function we request the resource:
Timer.fire(){
Resource.request();
.....
}
In the resource granted function we read the compass output by I2C as
following
Resource.granted(){
if(call I2CPacket.write(I2C_START,C0,.....)==SUCCESS)
{
// delay(100);
if(call I2CPacket.write(I2C_START,C1,.....)==SUCCESS)
call I2CPacket.read(I2C_START,C1,.....);
}
Resource.release();
}
Even I add the delay(100), it still does not work. When I track the
program, and find the second ``call I2CPacket.write(I2C_START,C1,.....)`` is
not successful.
After careful analysis of the I2C driver, I found in the program
Atm128I2CMasterPacketP.nc, when the I2CPacket.write begins, the variable "
state" changes into
I2C_STARTING. When this function call I2C.sendCommand() function and
finishes, the variable state still is I2C_STARTING. Track the
I2C.sendCommand() in the HplAtm128I2CBusP file and found, there is only one
operation TWCR=current.
It appear weird that there is no event to change the state variabe
in Atm128I2CMasterPacketP.nc. It is evident, after the writing operation is
done, there should exist an operation to change the state. But I can not
find it.
Does anyone give me help?
Thanks a lot!
Jianxin Chen
.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20081008/3a3072ce/attachment.htm
More information about the Tinyos-help
mailing list