[Tinyos-help] I2C, T2 and micaz

Jordi Casals jordi.casals at gmail.com
Mon Feb 26 06:39:04 PST 2007


Hi,

I use T2 and a micaz platform and now I am trying to connect an I2C 
display to my micaz. I don't have the display yet, but I want to have my 
application ready as soon as possible. I would like to know if the 
writeDone event is signaled even there is no I2C device connected to my 
micaz. I don't know if I there is any problem... but Leds.set(0x02) is 
never called.

Thank you

______________________________________________________________
module RandomToI2CC{
    uses{
        interface Boot;
        interface Leds;
        interface Random;
        interface Resource;
        interface I2CPacket<TI2CBasicAddr> as I2C;
        interface Timer<TMilli> as Timer;
    }
}

implementation{
    uint8_t counter = 0;

    event void Boot.booted(){
        call Leds.set(0);
        call Timer.startPeriodic(TIMER_PERIOD);
    }
   
    event void Timer.fired(){
        if(!(call Resource.isOwner())){
            if(call Resource.request() == SUCCESS){
               
            }
        }
    }
   
    event void Resource.granted(){
        if(call I2C.write(I2C_START | I2C_STOP, 12, sizeof(uint8_t), 
&counter) == SUCCESS){
            call Leds.set(0x01);
        }else{
            call Leds.set(0xFF);
        }
    }
   
    async event void I2C.readDone(error_t error, uint16_t addr, uint8_t 
length, uint8_t* data){
       
    }
   
    async event void I2C.writeDone(error_t error, uint16_t addr, uint8_t 
length, uint8_t* data){
        if(call Resource.release() == SUCCESS){
            call Leds.set(0x04);
        }
        call Leds.set(0x02);
    }
}
______________________________________________________________

-- 
Jordi Casals



More information about the Tinyos-help mailing list