[Tinyos-devel] More questions about using I2C on MicaZ / MTS300 (TinyOS 2)

Marina Kurmanova marina.kurmanova at gmail.com
Fri Jul 17 06:49:14 PDT 2009


Dear all,

I'm trying to use DS1921 i2c sensor with MICAz. As I met problems using it,
I tried to perform an example someone posted at the
http://mail.millennium.berkeley.edu/pipermail/tinyos-help/2007-January/021749.htmlthread.
The fact is there was no answer to the next question and it's just
what I need to solve:

1.) The I2CPacket.write seems to succeed (the leds 0 and 2 are lightened)
even if the I2C device is not connected (the Sensorboard is unplugged), is
this possible?

The code I use is:

#include <I2C.h>

module MicC {
 uses {
   interface Boot;
   interface Leds;
     interface GeneralIO as SoundPower;
   interface GeneralIO as SoundOutpt;
     interface Resource;
   interface I2CPacket<TI2CBasicAddr>;
 }
}
implementation {

 char Buffer[2];

 event void Boot.booted() {
     //call Leds.led2On();
     //call SoundPower.makeOutput();
     //call SoundOutpt.makeOutput();
     //call SoundPower.set();
     //call SoundOutpt.clr();
     call Resource.request();
 }
 event void Resource.granted() {
   Buffer[0] = 0x00;
   Buffer[1] = 0x40;

if (call I2CPacket.write(I2C_START | I2C_STOP, 0x5A, 2, &Buffer [0]) ==
SUCCESS) {

     call Leds.led0On();
   }
 }

async event void I2CPacket.readDone(error_t error, uint16_t addr, uint8_t
length, uint8_t* data) {

   call Leds.led1On();

 }

async event void I2CPacket.writeDone(error_t i2c_error, uint16_t addr,
uint8_t length, uint8_t* data) {
    error_t error = i2c_error;
    if (error == SUCCESS){
           call Leds.led2On();
    }
 }
}

Hope you can answer soon....

Marina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-devel/attachments/20090717/ad5272b6/attachment.htm 


More information about the Tinyos-devel mailing list