hello all
I am working for a project recently that uses temperature and vibration sensors 
with i2c interface. I am trying to connect lm75 temperature sensor to my iris 
node and read the temperature. the address of this device is 0x48 as listed at 
the data sheet. I wrote the following program:
BlinkToRadioAppC.nc 
#include <Timer.h>
#include "BlinkToRadio.h"

configuration BlinkToRadioAppC {
}
implementation {
  components MainC;
  components LedsC;
  components BlinkToRadioC as App;
   components new Atm128I2CMasterC();

  App.Boot -> MainC;
  App.Leds -> LedsC;
  App.Resource ->  Atm128I2CMasterC;
  App.I2CPacket -> Atm128I2CMasterC;
  
}

 BlinkToRadioC.nc
#include <Timer.h>
#include "BlinkToRadio.h"
#include <I2C.h>

module BlinkToRadioC {
  uses interface Boot;
  uses interface Leds;

  uses interface I2CPacket<TI2CBasicAddr>;
  uses interface Resource; //I2C bus resource

}
implementation {

  uint16_t counter;
 uint8_t a[2];
//a[0] = 0x00;
//a[1] = 0x00;

  void setLeds(uint8_t val) {
    if (val & 0x01)
      call Leds.led0On();
    else 
      call Leds.led0Off();
    if (val & 0x04)
      call Leds.led1On();
     else
      call Leds.led1Off();
    if (val & 0x08)
      call Leds.led2On();
    else
      call Leds.led2Off();
  }

  event void Boot.booted() {
  

            if(call Resource.request() == SUCCESS){
  }

}
// the begin of writing and reading from I2c
event void Resource.granted() {
      if (call I2CPacket.read(I2C_START | I2C_STOP, 0x48, 2, a) == SUCCESS) 
call 
Leds.led1Toggle()

    
  }
  async event void I2CPacket.readDone(error_t error, uint16_t addr, uint8_t 
length, uint8_t* data) {
call  Leds.led2Toggle();
call Resource.release();

  }
 async event void I2CPacket.writeDone(error_t error, uint16_t addr, uint8_t 
length,  uint8_t* data) {
   //call Leds.led2Toggle();

  }
}

I always get led 1 on so the resource request process is successful but led 2 
didnot become on so the read done event is never raised.
Is there a problem or some errors in my program that causes that to happen?
waiting for your response
thanks
Mohammed Tarek


      
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to