[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/telosb DS2411.nc, NONE, 1.1 DS2411C.nc, NONE, 1.1 DS2411M.nc, NONE, 1.1 DS2411Pin.nc, NONE, 1.1 DS2411PinC.nc, NONE, 1.1 DS2411PinM.nc, NONE, 1.1 README.DS2411, NONE, 1.1 SerialID.nc, 1.1, NONE SerialIDC.nc, 1.1, NONE SerialIDM.nc, 1.1, NONE

Cory Sharp cssharp at users.sourceforge.net
Sun Nov 7 16:24:14 PST 2004


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

Added Files:
	DS2411.nc DS2411C.nc DS2411M.nc DS2411Pin.nc DS2411PinC.nc 
	DS2411PinM.nc README.DS2411 
Removed Files:
	SerialID.nc SerialIDC.nc SerialIDM.nc 
Log Message:
Renamed SerialID to DS2411.  I've tried to structure the DS2411 implementation
to live within the tos/chips/ heirarchy.  A platform need only provide/implement
DS2411PinC and DS2411PinM that semantically twiddle the DS2411 IO pin to 
provide support for the DS2411 serial id.  See the readme for more details.


--- NEW FILE: DS2411.nc ---
//$Id: DS2411.nc,v 1.1 2004/11/08 00:24:12 cssharp Exp $

/* "Copyright (c) 2000-2003 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 Cory Sharp <cssharp at eecs.berkeley.edu>

interface DS2411
{
  command result_t init();

  command void copy_id( uint8_t* id ); // 6 bytes
  command uint8_t get_id_byte( uint8_t index );

  command uint8_t get_family();

  command uint8_t get_crc();
  command bool is_crc_okay();
}


--- NEW FILE: DS2411C.nc ---
//$Id: DS2411C.nc,v 1.1 2004/11/08 00:24:12 cssharp Exp $

/* "Copyright (c) 2000-2003 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 Cory Sharp <cssharp at eecs.berkeley.edu>

configuration DS2411C
{
  provides interface DS2411;
}
implementation
{
  components DS2411M, DS2411PinC;
  DS2411 = DS2411M;
  DS2411M.DS2411Pin -> DS2411PinC.DS2411Pin;
}


--- NEW FILE: DS2411M.nc ---
//$Id: DS2411M.nc,v 1.1 2004/11/08 00:24:12 cssharp Exp $

/* "Copyright (c) 2000-2003 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 Cory Sharp <cssharp at eecs.berkeley.edu>


/*

  The 1-wire timings suggested by the DS2411 data sheet are incorrect,
  incomplete, or unclear.  The timings provided the app note 522 work:

    http://www.maxim-ic.com/appnotes.cfm/appnote_number/522

*/

module DS2411M
{
  provides interface DS2411;
  uses interface DS2411Pin;
}
implementation
{
  uint8_t m_id[8];

  enum
  {
    STD_A = 6,
    STD_B = 64,
    STD_C = 60,
    STD_D = 10,
    STD_E = 9,
    STD_F = 55,
    STD_G = 0,
    STD_H = 480,
    STD_I = 90,
    STD_J = 220,
  };

  void init_pins()
  {
    TOSH_MAKE_ONEWIRE_INPUT();
    TOSH_CLR_ONEWIRE_PIN();
  }

  bool reset() // >= 960us
  {
    int present;
    call DS2411Pin.output_low();
    TOSH_uwait(STD_H); //t_RSTL
    call DS2411Pin.prepare_read();
    TOSH_uwait(STD_I);  //t_MSP
    present = call DS2411Pin.read();
    TOSH_uwait(STD_J);  //t_REC
    return (present == 0);
  }

  void write_bit_one() // >= 70us
  {
    call DS2411Pin.output_low();
    TOSH_uwait(STD_A);  //t_W1L
    call DS2411Pin.output_high();
    TOSH_uwait(STD_B);  //t_SLOT - t_W1L
  }

  void write_bit_zero() // >= 70us
  {
    call DS2411Pin.output_low();
    TOSH_uwait(STD_C);  //t_W0L
    call DS2411Pin.output_high();
    TOSH_uwait(STD_D);  //t_SLOT - t_W0L
  }

  void write_bit( int is_one ) // >= 70us
  {
    if(is_one)
      write_bit_one();
    else
      write_bit_zero();
  }

  bool read_bit() // >= 70us
  {
    int bit;
    call DS2411Pin.output_low();
    TOSH_uwait(STD_A);  //t_RL
    call DS2411Pin.prepare_read();
    TOSH_uwait(STD_E); //near-max t_MSR
    bit = call DS2411Pin.read();
    TOSH_uwait(STD_F);  //t_REC
    return bit;
  }

  void write_byte( uint8_t byte ) // >= 560us
  {
    uint8_t bit;
    for( bit=0x01; bit!=0; bit<<=1 )
      write_bit( byte & bit );
  }

  uint8_t read_byte() // >= 560us
  {
    uint8_t byte = 0;
    uint8_t bit;
    for( bit=0x01; bit!=0; bit<<=1 )
    {
      if( read_bit() )
	byte |= bit;
    }
    return byte;
  }




  uint8_t crc8_byte( uint8_t crc, uint8_t byte )
  {
    int i;
    crc ^= byte;
    for( i=0; i<8; i++ )
    {
      if( crc & 1 )
        crc = (crc >> 1) ^ 0x8c;
      else
        crc >>= 1;
    }
    return crc;
  }

  uint8_t crc8_bytes( uint8_t crc, uint8_t* bytes, uint8_t len )
  {
    uint8_t* end = bytes+len;
    while( bytes != end )
      crc = crc8_byte( crc, *bytes++ );
    return crc;
  }


  command result_t DS2411.init() // >= 6000us
  {
    int retry = 5;
    uint8_t id[8];

    bzero( m_id, 8 );
    call DS2411Pin.init();
    while( retry-- > 0 )
    {
      int crc = 0;
      if( reset() )
      {
	uint8_t* byte;

	write_byte(0x33); //read rom
	for( byte=id+7; byte!=id-1; byte-- )
	  crc = crc8_byte( crc, *byte=read_byte() );

	if( crc == 0 )
	{
	  memcpy( m_id, id, 8 );
	  return SUCCESS;
	}
      }
    }

    return FAIL;
  }

  command uint8_t DS2411.get_id_byte( uint8_t index )
  {
    return (index < 6) ? m_id[index+1] : 0;
  }

  command void DS2411.copy_id( uint8_t* id )
  {
    memcpy( id, m_id+1, 6 );
  }

  command uint8_t DS2411.get_family()
  {
    return m_id[7];
  }

  command uint8_t DS2411.get_crc()
  {
    return m_id[0];
  }

  uint8_t calc_crc()
  {
    return crc8_bytes( 0, m_id+1, 7 );
  }

  command bool DS2411.is_crc_okay()
  {
    return (call DS2411.get_crc() == calc_crc());
  }
}


--- NEW FILE: DS2411Pin.nc ---
//$Id: DS2411Pin.nc,v 1.1 2004/11/08 00:24:12 cssharp Exp $

/* "Copyright (c) 2000-2003 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 Cory Sharp <cssharp at eecs.berkeley.edu>

interface DS2411Pin
{
  command void init();
  command void output_low();
  command void output_high();
  command void prepare_read();
  command uint8_t read(); //zero=0, nonzero=1
}


--- NEW FILE: DS2411PinC.nc ---
//$Id: DS2411PinC.nc,v 1.1 2004/11/08 00:24:12 cssharp Exp $

/* "Copyright (c) 2000-2003 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 Cory Sharp <cssharp at eecs.berkeley.edu>

configuration DS2411PinC
{
  provides interface DS2411Pin;
}
implementation
{
  components DS2411PinM, MSP430GeneralIOC;

  DS2411Pin = DS2411PinM;
  DS2411PinM.MSP430Pin -> MSP430GeneralIOC.Port24;
}


--- NEW FILE: DS2411PinM.nc ---
//$Id: DS2411PinM.nc,v 1.1 2004/11/08 00:24:12 cssharp Exp $

/* "Copyright (c) 2000-2003 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 Cory Sharp <cssharp at eecs.berkeley.edu>

module DS2411PinM
{
  provides interface DS2411Pin;
  uses interface MSP430GeneralIO as MSP430Pin;
}
implementation
{
  command void DS2411Pin.init()
  {
    call MSP430Pin.selectIOFunc();
    call MSP430Pin.makeInput();
    call MSP430Pin.setLow();
  }

  command void DS2411Pin.output_low()
  {
    call MSP430Pin.makeOutput();
  }

  command void DS2411Pin.output_high()
  {
    call MSP430Pin.makeInput();
  }

  command void DS2411Pin.prepare_read()
  {
    call MSP430Pin.makeInput();
  }

  command uint8_t DS2411Pin.read()
  {
    return call MSP430Pin.getRaw();
  }
}


--- NEW FILE: README.DS2411 ---
$Id: README.DS2411,v 1.1 2004/11/08 00:24:12 cssharp Exp $

README for DS2411
Author/Contact: tinyos-help at millennium.berkeley.edu
@author Cory Sharp <cssharp at eecs.berkeley.edu>

Description:

The DS2411 is a serial ID that provides a distinct, unique 48-bit number.
It is intended to be used in conjunction with a 16-bit IEEE OUI to produce
a unique 64-bit mote identifier number.

The DS2411 uses the 1-Wire protocol.  This module has been abstracted to
live in the to-exist tos/chips/ heirarchy.  The following interfaces,
configuration, and implementation files are intended to live in
tos/chips/:

    DS2411.nc
    DS2411C.nc
    DS2411M.nc
    DS2411Pin.nc

DS2411 defines the interface to the chip, and DS2411M implements the
(hopefully) platform-independent chip-logic.  DS2411Pin defines a semantic
interface for iteracting with the DS2411 hardware IO pin.  DS2411C in part
wires to the DS2411PinC configuration presumably provided by the platform.  

The following configuration and module files must be provided by the
platform:

    DS2411PinC.nc
    DS2411PinM.nc

DS2411PinC and DS2411PinM implement the basic hardware semantics for
interacting with the DS2411 at the pin level.  The more complex DS2411
logic is built given this minimal platform specific implementation.


--- SerialID.nc DELETED ---

--- SerialIDC.nc DELETED ---

--- SerialIDM.nc DELETED ---



More information about the Tinyos-beta-commits mailing list