[Tinyos-commits] CVS: tinyos-1.x/tos/platform/telosb I2CPacketC.nc, NONE, 1.1 I2CPacketM.nc, NONE, 1.1

Joe Polastre jpolastre at users.sourceforge.net
Sun Jan 23 21:03:20 PST 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/platform/telosb
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30264

Added Files:
	I2CPacketC.nc I2CPacketM.nc 
Log Message:
initial checkin of platform independent I2CPacket component
I2CPacket is responsible for obtaining exclusive access of the I2C bus
(in the case of telosb, it is shared with SPI and UART)
starting the I2C component (MSP430I2CM in our case), running the operation,
and then stopping the I2C component (which restores the previous settings
for the USART, such as SPI configuration for the radio)

I2CPacketC currently exposes the MSP430I2CPacket interface, which
I propose to replace the existing (revision 1.3 2003/10/07) interface
to make the I2CPacket component compatable with DMA transfers and export
a more "master"-centric interface, since it is only used when the 
microcontroller is the master device s


--- NEW FILE: I2CPacketC.nc ---
// $Id: I2CPacketC.nc,v 1.1 2005/01/24 05:03:18 jpolastre Exp $
/*
 * "Copyright (c) 2000-2005 The Regents of the University  of California.
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 *
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 */

/**
 * @author Joe Polastre
 * Revision:  $Revision: 1.1 $
 *
 * Provides the ability to write or read a series of bytes to/from the
 * I2C bus.  
 **/
configuration I2CPacketC
{
  provides {
    interface StdControl;
    interface MSP430I2CPacket;
  }
}
implementation {
  components I2CPacketM, MSP430I2CC as XI2C, BusArbitrationC;

  StdControl = I2CPacketM;
  MSP430I2CPacket = I2CPacketM.I2CPacket;

  I2CPacketM.LPacket -> XI2C;
  I2CPacketM.LControl -> XI2C;

  I2CPacketM.BusArbitration -> BusArbitrationC.BusArbitration[unique("BusArbitration")];

}

--- NEW FILE: I2CPacketM.nc ---
// $Id: I2CPacketM.nc,v 1.1 2005/01/24 05:03:18 jpolastre Exp $
/*
 * "Copyright (c) 2000-2005 The Regents of the University  of California.
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 *
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 */

/**
 * @author Joe Polastre
 * Revision:  $Revision: 1.1 $
 *
 * Provides the ability to write or read a series of bytes to/from the
 * I2C bus.  
 **/
module I2CPacketM
{
  provides {
    interface MSP430I2CPacket as I2CPacket;
    interface StdControl;
  }
  uses {
    interface MSP430I2CPacket as LPacket;
    interface StdControl as LControl;
    interface BusArbitration;
  }
}

implementation
{
  command result_t StdControl.init() {
    call LControl.init();
    return SUCCESS;
  }

  command result_t StdControl.start() {
    return SUCCESS;
  }

  command result_t StdControl.stop() {
    return SUCCESS;
  }

  command result_t I2CPacket.readPacket(uint16_t _addr, uint8_t _length, uint8_t* _data) {
    // bus arbitration occurs here
    if (call BusArbitration.getBus() == SUCCESS) {
      if (call LControl.start())
	return call LPacket.readPacket(_addr, _length, _data);
    }
    return FAIL;
  }

  event void LPacket.readPacketDone(uint16_t _addr, uint8_t _length, uint8_t* _data, result_t _result) {
    call LControl.stop();
    call BusArbitration.releaseBus();
    signal I2CPacket.readPacketDone(_addr, _length, _data, _result);
  }

  command result_t I2CPacket.writePacket(uint16_t _addr, uint8_t _length, uint8_t* _data) {
    // bus arbitration occurs here
    if (call BusArbitration.getBus() == SUCCESS) {
      if (call LControl.start())
	return call LPacket.writePacket(_addr, _length, _data);
    }
    return FAIL;
  }

  event void LPacket.writePacketDone(uint16_t _addr, uint8_t _length, uint8_t* _data, result_t _result) {
    call LControl.stop();
    call BusArbitration.releaseBus();
    signal I2CPacket.writePacketDone(_addr, _length, _data, _result);
  }

  event result_t BusArbitration.busFree() { return SUCCESS; }
}



More information about the Tinyos-commits mailing list