Hi all,
I'm facing some problems in using the I2C bus of a telosb mote in TinyOS 2.
I request resource I2C bus and when granted event is signalled I call
an I2C write operation, after that I get the writeDone event, but with
error FAIL.
If I call another I2C write command, I don't get any writeDone signal back.
I have read previous posts about this but I have not understood how to
solve it.
I report here part of code that reproduce the problem.
Any suggestion?
Thanks
Matteo
------------------------------------------------------
#include "I2C.h"
configuration I2CappC{
}
implementation
{
components MainC, I2Capp, LedsC;
I2Capp -> MainC.Boot;
I2Capp.Leds -> LedsC;
components new TimerMilliC() as Timer;
I2Capp.Timer -> Timer;
components new Msp430I2CC();
I2Capp.I2CBasicAddr->Msp430I2CC;
I2Capp.Resource -> Msp430I2CC;
}
------------------------------------------------------
module I2Capp
{
uses interface I2CPacket<TI2CBasicAddr> as I2CBasicAddr;
uses interface Boot;
uses interface Leds;
uses interface Resource;
uses interface Timer<TMilli> as Timer;
}
implementation{
uint8_t buf = 0x0F;
event void Boot.booted(){
call Resource.request();
}
async event void I2CBasicAddr.writeDone(error_t error, uint16_t
addr, uint8_t length, uint8_t* data){
call Leds.led2Toggle();
call Timer.startOneShot(1024);
return;
}
async event void I2CBasicAddr.readDone(error_t error, uint16_t
addr, uint8_t length, uint8_t* data){
return;
}
event void Resource.granted(){
call Timer.startOneShot(1024);
return;
}
event void Timer.fired() {
if (call I2CBasicAddr.write(I2C_START|I2C_STOP, 126, 1, &buf)==SUCCESS)
call Leds.led1Toggle();
return;
}
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help