[Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/iris/chips/rf230 HplRF2xx.h, NONE, 1.1 HplRF2xxC.nc, NONE, 1.1 HplRF2xxP.nc, NONE, 1.1 RadioAlarm.h, 1.1, 1.2 HplRF230.h, 1.7, NONE HplRF230C.nc, 1.8, NONE HplRF230P.nc, 1.3, NONE

Miklos Maroti mmaroti at users.sourceforge.net
Sun Mar 8 16:23:21 PDT 2009


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

Modified Files:
	RadioAlarm.h 
Added Files:
	HplRF2xx.h HplRF2xxC.nc HplRF2xxP.nc 
Removed Files:
	HplRF230.h HplRF230C.nc HplRF230P.nc 
Log Message:
rename everything to support the RF212 

--- NEW FILE: HplRF2xx.h ---
/*
 * 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
 */

#ifndef __HPLRF2XX_H__
#define __HPLRF2XX_H__

#include <RF2xx.h>
#include <util/crc16.h>

enum
{
	/**
	 * This is an RF230 chip
	 */
	RF2XX_CHIPSET = RF230_CHIPSET,

	/**
	 * This is the value of the TRX_CTRL_0 register
	 * which configures the output pin currents and the CLKM clock
	 */
	RF2XX_TRX_CTRL_0_VALUE = 0,

	/**
	 * This is the default value of the CCA_MODE field in the PHY_CC_CCA register
	 * which is used to configure the default mode of the clear channel assesment
	 */
	RF2XX_CCA_MODE_VALUE = RF2XX_CCA_MODE_3,

	/**
	 * This is the value of the CCA_THRES register that controls the
	 * energy levels used for clear channel assesment
	 */
	RF2XX_CCA_THRES_VALUE = 0xC7,
};

/* This is the default value of the TX_PWR field of the PHY_TX_PWR register. */
#ifndef RF230_DEF_RFPOWER
#define RF230_DEF_RFPOWER	0
#endif

#define RF2XX_DEF_RFPOWER	RF230_DEF_RFPOWER

/* This is the default value of the CHANNEL field of the PHY_CC_CCA register. */
#ifndef RF230_DEF_CHANNEL
#define RF230_DEF_CHANNEL	11
#endif

#define RF2XX_DEF_CHANNEL	RF230_DEF_CHANNEL

/*
 * This is the command used to calculate the CRC for the RF230 chip. 
 * TODO: Check why the default crcByte implementation is in a different endianness
 */
inline uint16_t RF2XX_CRCBYTE_COMMAND(uint16_t crc, uint8_t data)
{
	return _crc_ccitt_update(crc, data);
}

#endif//__HPLRF2XX_H__

--- NEW FILE: HplRF2xxC.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
 */

#include <RadioAlarm.h>

configuration HplRF2xxC
{
	provides
	{
		interface GeneralIO as SELN;
		interface Resource as SpiResource;
		interface FastSpiByte;

		interface GeneralIO as SLP_TR;
		interface GeneralIO as RSTN;

		interface GpioCapture as IRQ;
		interface Alarm<TRadio, uint16_t> as Alarm;
	}
}

implementation
{
	components HplRF2xxP;
	IRQ = HplRF2xxP.IRQ;

	HplRF2xxP.PortCLKM -> IO.PortD6;
	HplRF2xxP.PortIRQ -> IO.PortD4;
	
	components Atm128SpiC as SpiC;
	SpiResource = SpiC.Resource[unique("Atm128SpiC.Resource")];

	FastSpiByte = HplRF2xxP;

	components HplAtm128GeneralIOC as IO;
	SLP_TR = IO.PortB7;
	RSTN = IO.PortA6;
	SELN = IO.PortB0;

	components HplAtm128Timer1C as TimerC;
	HplRF2xxP.Capture -> TimerC.Capture;

	components new AlarmOne16C() as AlarmC;
	Alarm = AlarmC;

	components RealMainP;
	RealMainP.PlatformInit -> HplRF2xxP.PlatformInit;
}

--- NEW FILE: HplRF2xxP.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
 */

#include "Atm128Spi.h"

module HplRF2xxP
{
	provides
	{
		interface GpioCapture as IRQ;
		interface Init as PlatformInit;

		interface FastSpiByte;
	}

	uses
	{
		interface HplAtm128Capture<uint16_t> as Capture;
		interface GeneralIO as PortCLKM;
		interface GeneralIO as PortIRQ;
	}
}

implementation
{
	command error_t PlatformInit.init()
	{
		call PortCLKM.makeInput();
		call PortCLKM.clr();
		call PortIRQ.makeInput();
		call PortIRQ.clr();
		call Capture.stop();

		return SUCCESS;
	}

	async event void Capture.captured(uint16_t time)
	{
		time = call Capture.get();	// TODO: ask Cory why time is not the captured time
		signal IRQ.captured(time);
	}

	default async event void IRQ.captured(uint16_t time)
	{
	}

	async command error_t IRQ.captureRisingEdge()
	{
		call Capture.setEdge(TRUE);
		call Capture.reset();
		call Capture.start();
	
		return SUCCESS;
	}

	async command error_t IRQ.captureFallingEdge()
	{
		// falling edge comes when the IRQ_STATUS register of the RF230 is read
		return FAIL;	
	}

	async command void IRQ.disable()
	{
		call Capture.stop();
	}

	inline async command void FastSpiByte.splitWrite(uint8_t data)
	{
		// the SPI must have been started, so do not waste time here
		// SET_BIT(SPCR, SPE);

		SPDR = data;
	}

	inline async command uint8_t FastSpiByte.splitRead()
	{
	    while( !( SPSR & 0x80 ) )
			;
		return SPDR;
	}

	inline async command uint8_t FastSpiByte.splitReadWrite(uint8_t data)
	{
		uint8_t b;

	    while( !( SPSR & 0x80 ) )
			;
		b = SPDR;
		SPDR = data;

		return b;
	}

	inline async command uint8_t FastSpiByte.write(uint8_t data)
	{
		// the SPI must have been started, so do not waste time here
		// SET_BIT(SPCR, SPE);

		SPDR = data;
	    while( !( SPSR & 0x80 ) )
			;

		return SPDR;
	}
}

Index: RadioAlarm.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/platforms/iris/chips/rf230/RadioAlarm.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RadioAlarm.h	8 Mar 2009 22:03:15 -0000	1.1
--- RadioAlarm.h	8 Mar 2009 23:23:19 -0000	1.2
***************
*** 33,38 ****
  
  /**
!  * The number of radio alarm ticks per one microsecond (0.9216). We use integers 
!  * and no  parentheses just to make deputy happy.
   */
  #define RADIO_ALARM_MICROSEC	(7372800UL / MHZ / 32) * (1 << MICA_DIVIDE_ONE_FOR_32KHZ_LOG2) / 1000000UL
--- 33,38 ----
  
  /**
!  * The number of radio alarm ticks per one microsecond (0.9216). 
!  * We use integers and no parentheses just to make deputy happy.
   */
  #define RADIO_ALARM_MICROSEC	(7372800UL / MHZ / 32) * (1 << MICA_DIVIDE_ONE_FOR_32KHZ_LOG2) / 1000000UL

--- HplRF230.h DELETED ---

--- HplRF230C.nc DELETED ---

--- HplRF230P.nc DELETED ---



More information about the Tinyos-2-commits mailing list