[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/rf230 FastSpiByte.nc, NONE, 1.1 HplRF230.nc, NONE, 1.1 RF230LayerC.nc, 1.7, 1.8 RF230LayerP.nc, 1.23, 1.24

Miklos Maroti mmaroti at users.sourceforge.net
Fri Mar 6 05:12:14 PST 2009


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv19683

Modified Files:
	RF230LayerC.nc RF230LayerP.nc 
Added Files:
	FastSpiByte.nc HplRF230.nc 
Log Message:
separate the FastSpiInterface from the HplRF230 interface

--- NEW FILE: FastSpiByte.nc ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

/**
 * This is a natural extension of the SpiByte interface which allows fast 
 * data transfers comparable to the SpiStream interface. Use may want to
 * use the following code sequence to write a buffer as fast as possible
 *
 *	call FastSpiByte.spiSplitWrite(data[0]); // the first byte
 *	for(i = 1; i < length; ++i) {
 *	   // finish the previous one and write the next one
 *	  call FastSpiByte.spiSplitReadWrite(data[i]);
 *	}
 *	call FastSpiByte.spiSlitRead(); // finish the last one
 */
interface FastSpiByte
{
	/**
	 * Starts a split-phase SPI data transfer with the given data.
	 * A spiSplitRead command must follow this command even if the
	 * result is unimportant. The SpiByte interface should be 
	 * extended with this protocol.
	 */
	async command void splitWrite(uint8_t data);

	/**
	 * Finishes the split-phase SPI data transfer by waiting till 
	 * the write command comletes and returning the received data.
	 */
	async command uint8_t splitRead();

	/**
	 * This command first reads the SPI register and then writes
	 * there the new data, then returns
	 */
	async command uint8_t splitReadWrite(uint8_t data);

	/**
	 * This is the standard SpiByte.write command but a little
	 * faster as we shuold not need to adjust the power state there.
	 */
	async command uint8_t write(uint8_t data);
}

--- NEW FILE: HplRF230.nc ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * 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 VANDERBILT UNIVERSITY 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 VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY 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 VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

interface HplRF230
{
	/**
	 * Calculates the crc. For some unknown reason the standard
	 * tinyos crcByte command swiches endianness.
	 */
	async command uint16_t crcByte(uint16_t crc, uint8_t data);
}

Index: RF230LayerC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/RF230LayerC.nc,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** RF230LayerC.nc	29 May 2008 18:57:53 -0000	1.7
--- RF230LayerC.nc	6 Mar 2009 13:12:11 -0000	1.8
***************
*** 60,64 ****
  	RF230LayerP.SELN -> HplRF230C.SELN;
  	RF230LayerP.SpiResource -> HplRF230C.SpiResource;
! 	RF230LayerP.SpiByte -> HplRF230C;
  	RF230LayerP.HplRF230 -> HplRF230C;
  
--- 60,64 ----
  	RF230LayerP.SELN -> HplRF230C.SELN;
  	RF230LayerP.SpiResource -> HplRF230C.SpiResource;
! 	RF230LayerP.FastSpiByte -> HplRF230C;
  	RF230LayerP.HplRF230 -> HplRF230C;
  

Index: RF230LayerP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/RF230LayerP.nc,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** RF230LayerP.nc	25 Feb 2009 23:27:59 -0000	1.23
--- RF230LayerP.nc	6 Mar 2009 13:12:11 -0000	1.24
***************
*** 46,50 ****
  		interface Resource as SpiResource;
  
! 		interface SpiByte;
  		interface HplRF230;
  
--- 46,50 ----
  		interface Resource as SpiResource;
  
! 		interface FastSpiByte;
  		interface HplRF230;
  
***************
*** 127,133 ****
  
  		call SELN.clr();
! 		call HplRF230.spiSplitWrite(RF230_CMD_REGISTER_WRITE | reg);
! 		call HplRF230.spiSplitReadWrite(value);
! 		call HplRF230.spiSplitRead();
  		call SELN.set();
  	}
--- 127,133 ----
  
  		call SELN.clr();
! 		call FastSpiByte.splitWrite(RF230_CMD_REGISTER_WRITE | reg);
! 		call FastSpiByte.splitReadWrite(value);
! 		call FastSpiByte.splitRead();
  		call SELN.set();
  	}
***************
*** 139,145 ****
  
  		call SELN.clr();
! 		call HplRF230.spiSplitWrite(RF230_CMD_REGISTER_READ | reg);
! 		call HplRF230.spiSplitReadWrite(0);
! 		reg = call HplRF230.spiSplitRead();
  		call SELN.set();
  
--- 139,145 ----
  
  		call SELN.clr();
! 		call FastSpiByte.splitWrite(RF230_CMD_REGISTER_READ | reg);
! 		call FastSpiByte.splitReadWrite(0);
! 		reg = call FastSpiByte.splitRead();
  		call SELN.set();
  
***************
*** 445,449 ****
  
  		call SELN.clr();
! 		call HplRF230.spiSplitWrite(RF230_CMD_FRAME_WRITE);
  
  		length = call RF230Config.getLength(msg);
--- 445,449 ----
  
  		call SELN.clr();
! 		call FastSpiByte.splitWrite(RF230_CMD_FRAME_WRITE);
  
  		length = call RF230Config.getLength(msg);
***************
*** 451,455 ****
  
  		// length | data[0] ... data[length-3] | automatically generated FCS
! 		call HplRF230.spiSplitReadWrite(length);
  
  		// the FCS is atomatically generated (2 bytes)
--- 451,455 ----
  
  		// length | data[0] ... data[length-3] | automatically generated FCS
! 		call FastSpiByte.splitReadWrite(length);
  
  		// the FCS is atomatically generated (2 bytes)
***************
*** 464,468 ****
  		// first upload the header to gain some time
  		do {
! 			call HplRF230.spiSplitReadWrite(*(data++));
  		}
  		while( --header != 0 );
--- 464,468 ----
  		// first upload the header to gain some time
  		do {
! 			call FastSpiByte.splitReadWrite(*(data++));
  		}
  		while( --header != 0 );
***************
*** 474,483 ****
  
  		do {
! 			call HplRF230.spiSplitReadWrite(*(data++));
  		}
  		while( --length != 0 );
  
  		// wait for the SPI transfer to finish
! 		call HplRF230.spiSplitRead();
  		call SELN.set();
  
--- 474,483 ----
  
  		do {
! 			call FastSpiByte.splitReadWrite(*(data++));
  		}
  		while( --length != 0 );
  
  		// wait for the SPI transfer to finish
! 		call FastSpiByte.splitRead();
  		call SELN.set();
  
***************
*** 553,560 ****
  
  		call SELN.clr();
! 		call HplRF230.spiWrite(RF230_CMD_FRAME_READ);
  
  		// read the length byte
! 		length = call HplRF230.spiWrite(0);
  
  		// if correct length
--- 553,560 ----
  
  		call SELN.clr();
! 		call FastSpiByte.write(RF230_CMD_FRAME_READ);
  
  		// read the length byte
! 		length = call FastSpiByte.write(0);
  
  		// if correct length
***************
*** 565,569 ****
  
  			// initiate the reading
! 			call HplRF230.spiSplitWrite(0);
  
  			call RF230Config.setLength(rxMsg, length);
--- 565,569 ----
  
  			// initiate the reading
! 			call FastSpiByte.splitWrite(0);
  
  			call RF230Config.setLength(rxMsg, length);
***************
*** 581,585 ****
  
  			do {
! 				crc = call HplRF230.crcByte(crc, *(data++) = call HplRF230.spiSplitReadWrite(0));
  			}
  			while( --read != 0  );
--- 581,585 ----
  
  			do {
! 				crc = call HplRF230.crcByte(crc, *(data++) = call FastSpiByte.splitReadWrite(0));
  			}
  			while( --read != 0  );
***************
*** 588,597 ****
  			{
  				while( length-- != 0 )
! 					crc = call HplRF230.crcByte(crc, *(data++) = call HplRF230.spiSplitReadWrite(0));
  
! 				crc = call HplRF230.crcByte(crc, call HplRF230.spiSplitReadWrite(0));
! 				crc = call HplRF230.crcByte(crc, call HplRF230.spiSplitReadWrite(0));
  
! 				call PacketLinkQuality.set(rxMsg, call HplRF230.spiSplitRead());
  			}
  			else
--- 588,597 ----
  			{
  				while( length-- != 0 )
! 					crc = call HplRF230.crcByte(crc, *(data++) = call FastSpiByte.splitReadWrite(0));
  
! 				crc = call HplRF230.crcByte(crc, call FastSpiByte.splitReadWrite(0));
! 				crc = call HplRF230.crcByte(crc, call FastSpiByte.splitReadWrite(0));
  
! 				call PacketLinkQuality.set(rxMsg, call FastSpiByte.splitRead());
  			}
  			else



More information about the Tinyos-2-commits mailing list