[Tinyos-devel] Proposal to change I2CPacket

Joe Polastre polastre at cs.berkeley.edu
Sat Jan 22 13:30:13 PST 2005


Correction
  event void readPacketDone(uint8_t length, uint8_t* data);
should be
  event void readPacketDone(uint8_t length, uint8_t* data, result_t
success);

For TinyOS 2.x, the result_t parameter in the "Done" events will become
error_t values, such that you can return EI2C_NACK for the error where the
slave device fails to respond with an ACK to the data transmitted.

-Joe

-----Original Message-----
From: tinyos-devel-bounces at Millennium.Berkeley.EDU
[mailto:tinyos-devel-bounces at Millennium.Berkeley.EDU] On Behalf Of Joe
Polastre
Sent: Saturday, January 22, 2005 1:23 PM
To: 'TinyOS-Devel list'
Subject: [Tinyos-devel] Proposal to change I2CPacket

I2CPacket currently violates some of the buffer passing and buffer location
"rules".

I would like to remove all buffers from I2CPacket and have the buffer passed
in as a parameter, and passed back to the app when finished.  This allows
data to be read from the bus of arbitrary length, dependent on the size of
the buffer the application passes in.  Otherwise, if I2CPacket maintains the
buffer, it is limited to its predefined size.

Also, we have a FLAGS parameter that should be removed and the underlying
implementation should conform to the I2C protocol rather than our current
(somewhat broken) implementation of it.

Current I2CPacket:
  command result_t readPacket(char length, char flags);
  command result_t writePacket(char length, char* data, char flags);

  event result_t readPacketDone(char length, char* data);
  event result_t writePacketDone(bool result);

Proposed new I2CPacket interface:
  command result_t readPacket(uint16_t addr, uint8_t length, uint8_t* data);
  command result_t writePacket(uint16_t addr, uint8_t length, uint8_t*
data);

  event void readPacketDone(uint8_t length, uint8_t* data);
  event void writePacketDone(uint8_t length, uint8_t* data, result_t
success);

The I2CPacket interface will be limited; it will only support single
commands that start and end with 'start' and 'stop' conditions with the
microcontroller in *master* mode, rather than supporting the full range of
're-start' and slave commands.  Those will be available to be implemented
through the HPL and those applications that need that functionality can
write it themselves as an HAL component, and exposed through interfaces like
I2CSlave.

If approved, I will update all code in the main tinyos repository; those who
use I2CPacket in contrib will need to update their code to reflect the
changes (although all uses of I2CPacket in contrib copy the I2CPacket to
their contrib directory and it is picked up by nesC by the compile path)

-Joe

_______________________________________________
Tinyos-devel mailing list
Tinyos-devel at Millennium.Berkeley.EDU
http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-devel



More information about the Tinyos-devel mailing list