Quoting "R. Steve McKown" <[EMAIL PROTECTED]>:
If you want to post your code, I can take a look at it.
The code is yours, I have changed only the salve address and add the
address check reading three bit at a time with leds.
#include <I2C.h>
module SlaveI2CC {
uses {
interface Boot;
interface Resource;
interface I2CSlave<TI2CBasicAddr>;
interface Timer<TMilli>;
interface Leds;
}
}
implementation {
uint16_t SlaveInd;
enum {
OUR_ADDR = 0x18,
SPACE_SZ = 16
};
uint8_t space[SPACE_SZ];
int addr = 0;
norace error_t lastErr = FAIL;
inline void incAddr() { addr = (addr + 1) % SPACE_SZ; }
void localError(int e)
{
call Leds.led0Off();
call Leds.led1Off();
call Leds.led2Off();
}
event void Boot.booted()
{
call Timer.startPeriodic(1024);
if (call Resource.request() == SUCCESS)
return;
localError(1);
}
event void Timer.fired()
{
/*
if (!(I2CDCTL & I2CBB) && !(I2CDCTL & I2CBUSY)) {
// show when we're not busy
call Leds.led1Off();
call Leds.led2Off();
}
*/
call Leds.led0Off();
call Leds.led1Off();
call Leds.led2Off();
if ((I2COA & 1) == 1) call Leds.led0On();
if ((I2COA & 2) == 2) call Leds.led1On();
if ((I2COA & 4) == 4) call Leds.led2On();
/*
if ((I2COA & 8) == 8) call Leds.led0On();
if ((I2COA & 16) == 16) call Leds.led1On();
if ((I2COA & 32) == 32) call Leds.led2On();
if ((I2COA & 64) == 64) call Leds.led2On();
*/
}
event void Resource.granted()
{
if (call I2CSlave.listen(OUR_ADDR) == SUCCESS) {
// done in configure(). call Leds.led0On();
return;
}
localError(2);
}
async event uint8_t I2CSlave.writeByte()
{
uint8_t byte = space[addr];
call Leds.led2Off();
call Leds.led1On();
incAddr();
return byte;
}
async event void I2CSlave.readByte(uint8_t data)
{
call Leds.led1Off();
call Leds.led2On();
space[addr] = data;
incAddr();
}
}
-----------------------------------------------
-----------------------------------------------
module SlaveI2CConfC {
provides interface Msp430I2CConfigure;
}
implementation {
async command msp430_i2c_config_t* Msp430I2CConfigure.getConfig() {
static msp430_i2c_config_t testConfig = {
rxdmaen : 0,
txdmaen : 0,
xa : 0,
listen : 0,
i2cword : 0,
i2crm : 1,
i2cssel : 2,
i2cpsc : 0,
i2csclh : 3,
i2cscll : 3,
i2coa : 0x18, /* for slave, apparently must have it here? */
};
return &testConfig;
}
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help