Hi All,

I am attempting to use the I2CPacket interface to write from the
TelosB mote to a pressure sensor (Bosch SensorTec BMP085). However,
whenever I try to write to the BMP pressure sensor, the writeDone
event indicates that the write failed (error == fail).  Are there any
major flaws in my code? Am I forgetting to initialize some component,
request some resource, or configure some pins? I am new to TinyOS and
I would love some advice. The relevant part of my code is below (it is
a modified Oscilloscope file).  As it is right now, LEDs 1 and 2 turn
on, but not LED 0.

Also, is there any easy way to debug code for TinyOS or the TelosB
mote(other than using the three LEDs)?

Thanks,

Ed Sullivan



/*********OscilloscopeAppC.nc*********/
////////////////////////////////////////////////////////////////////////////////////

configuration OscilloscopeAppC { }
implementation
{
    components OscilloscopeC, MainC, LedsC, new TimerMilliC() as
Timer2, new Msp430I2CC();

    OscilloscopeC.Boot -> MainC;
    OscilloscopeC.Timer2 -> Timer2;
    OscilloscopeC.Leds -> LedsC;
    OscilloscopeC.I2CPacket -> Msp430I2CC;
    OscilloscopeC.Resource -> Msp430I2CC;
}





/***********OscilloscopeC.nc************/
//////////////////////////////////////////////////////////////////////////////////////////

#include "Timer.h"
#include "Oscilloscope.h"
#define BMP085_ADDR_WRITE  0x77
#define BMP085_ADDR_READ   0x77

module OscilloscopeC @safe()
{
  uses {
    interface Boot;
    interface Timer<TMilli> as Timer2;
    interface Leds;
    interface I2CPacket<TI2CBasicAddr>; // BMP085 uses 7-bit address option
    interface Resource;
  }
}

implementation
{

    event void Boot.booted() {
         call Leds.led0Off();
         call Resource.request();
    }



     event void Resource.granted() {
          call Leds.led0Off();
          call Leds.led1Off();
          call Leds.led2Off();
          call Timer2.startOneShot(15000);
     }



     event void Timer2.fired(){
          uint8_t addressCalibrate;
          uint8_t * bmp085_addr_ac1_msb_22;

          addressCalibrate = 0xAA;
          bmp085_addr_ac1_msb_22 = &addressCalibrate;

          if (call I2CPacket.write(I2C_START | I2C_STOP,
BMP085_ADDR_WRITE, 1, bmp085_addr_ac1_msb_22) != SUCCESS) {
               call Leds.led0On();
          }
     }




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

            if (error == FAIL) {
                 call Leds.led2On();
            }
     }


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





Thanks,
Ed


-- 
Edward Sullivan

[email protected]
NASA Ames Sustainability Base, Student Intern
WSBF-FM Clemson, Computer Engineer
Cell: (240) 383-0498
CUID: 749791137
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to