[Tinyos-help] Connecting PCF8563 RTC to Iris
Michael Schippling
schip at santafe.edu
Thu Jul 30 09:44:44 PDT 2009
Is there a simple way to determine if a device
exists at a specific I2C slave address? At the
lowest level the master is just clocking and
reading a data line which could legitimately
be all FFFF's...
MS
Janos Sallai wrote:
> Andres,
>
>> I have read that I2CPacket.write(adr, len, data) returns always success.
>
> This is not true. Here's an excerpt from
> tos\chips\atm128\i2c\Atm128I2CMasterPacketP.nc:
>
> 179 async command error_t I2CPacket.write(i2c_flags_t flags, uint16_t
> addr, uint8_t len, uint8_t* data) {
> 180 atomic {
> 181 if (state == I2C_IDLE) {
> 182 state = I2C_BUSY;
> 183 }
> 184 else if (state == I2C_OFF) {
> 185 return EOFF;
> 186 }
> 187 else {
> 188 return EBUSY;
> 189 }
> ...
>
> That is, your consecutive calls to I2CPacket.write will fail without
> waiting for I2CPacket.writeDone in between.
>
> Janos
>
>
> On Thu, Jul 30, 2009 at 7:31 AM, Andres Vahter<andres.vahter at gmail.com> wrote:
>> On 29.07.2009, at 18:31, Janos Sallai wrote:
>>
>> Andres,
>>
>> I2CPacket.read and I2CPacket.write are split phase operations. You
>> have to wait for the corresponding readDone or writeDone events before
>> issuing the next read or write, otherwise the subsequent operations
>> may fail.
>>
>> Janos
>>
>>
>> Hi,
>> I have read that I2CPacket.write(adr, len, data) returns always success.
>> There is patch for
>> that: http://mail.millennium.berkeley.edu/pipermail/tinyos-devel/2009-July/003977.html
>> I tried it with copy-paste method (don't know how to apply it correctly).
>> And I'm still getting SUCCESS when I'm tryng to write to non existing I2C
>> device - I should get EINVAL with that patch - am I right?.
>> ---------------------------------------------------------
>> buffer[0] = 0x00;
>> buffer[1] = 0x00;
>> buffer[2] = 0xF;
>> buffer[3] = 0x00;
>>
>> if (call I2CPacket.write(I2C_START, 0x41, 1, buffer) == SUCCESS) {
>> call Leds.led2On();
>> }
>> ---------------------------------------------------------
>> It returns always success. I don't have device with address 0x41 connected.
>>
>> What about external pulldown, why is it changed
>> from
>> if (hasExternalPulldown)
>> to
>> if (!hasExternalPulldown)
>>
>> How is addressing managed? If I have a device with 8 bit address 0xA2 should
>> I use that address in I2CPacket.write or should I use 7 bit address 0xA2 >>
>> 1?
>> And last question: if I have device with I2C address 0xA2 and I want to
>> change register 0x02 value in that device to 0x0F - how should I do that, is
>> following code right?
>> buffer[0] = 0x02; // reg addr
>> buffer[1] = 0x0F; // value
>>
>> if (call I2CPacket.write(I2C_START, 0xA2, 2, buffer) == SUCCESS) {
>> }
>>
>> Andres Vahter
>>
>>
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
More information about the Tinyos-help
mailing list