[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/diku/evb13192/apps/TestRadioDriver TestRadioDriverM.nc, NONE, 1.1 TestRadioDriver.nc, NONE, 1.1 Makefile, NONE, 1.1 SingleTimer.nc, NONE, 1.1

Jan Flora janflora at users.sourceforge.net
Wed Aug 23 02:41:15 PDT 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/diku/evb13192/apps/TestRadioDriver
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv12501/apps/TestRadioDriver

Added Files:
	TestRadioDriverM.nc TestRadioDriver.nc Makefile SingleTimer.nc 
Log Message:
application updates

--- NEW FILE: TestRadioDriverM.nc ---
#include "PhyTypes.h"

module TestRadioDriverM
{
	provides {
		interface StdControl;
	}
	uses {
		interface PhyTransmit;
		interface PhyReceive;
		interface PhyAttributes;
		interface PhyEnergyDetect;
		interface LocalTime;
		interface Timer;
		interface Debug;
	}
}
implementation
{
	#define DBG_LEVEL 1
	#define DBG_MIN_LEVEL 0
	#include "Debug.h"
	
	uint8_t myTestFrame[19] = {0x23, 0x8C, 0x12, 0xDE, 0xFE, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF, 0x1F, 0x00, 0x01, 0x80};
//	uint8_t myTestFrame[125];
	uint8_t myTestFrameLength = 19;
	
	uint8_t rxBuf[126]; // Initial receive buffer.
 
 	txdata_t txBuf;
 
	task void receive();
	task void send();
	task void energy();
	
	/* **********************************************************************
	 * Setup/Init code
	 * *********************************************************************/

	/* Init */
	command result_t StdControl.init()
	{
		call PhyReceive.initRxBuffer(rxBuf);
		return SUCCESS;
	}

	/* start */
	command result_t StdControl.start()
	{
		uint8_t i;
		call PhyAttributes.setChannel(0);

		txBuf.frame = myTestFrame;
		txBuf.length = myTestFrameLength;
		txBuf.cca = TRUE;
		txBuf.immediateCommence = TRUE;
		txBuf.commenceTime = 0x0000FFFF;

		post energy();
		//call Timer.start(TIMER_ONE_SHOT, 1000);
		return SUCCESS;
	}

	/* stop - never called */
	command result_t StdControl.stop()
	{
		return SUCCESS;
	}

	/* **********************************************************************
	 * Timer/radio related code
	 * *********************************************************************/

	task void send()
	{
		call PhyTransmit.tx(&txBuf);
	}

/*	task void sendCca()
	{
		call PhyDriver.ccaSend(&txBuf, TRUE);
	}*/
	
	task void receive()
	{
/*		uint32_t test1,test2;
		uint32_t i = 0x2FFFFF;

		call PhyDriver.resetEventTime();
		call LocalTime.reset();
		test1 = call PhyDriver.getEventTime();
		test2 = call LocalTime.getTimeL();

		DBG_STRINT("Time1:",test1,1);
		DBG_STRINT("Time2:",test2,1);
		while(i--);
		
		test2 = call LocalTime.getTimeL();
		test1 = call PhyDriver.getEventTime();

		DBG_STRINT("Time1:",test1,1);
		DBG_STRINT("Time2:",test2,1);*/
		call PhyAttributes.setDefaultFilter();
		call PhyReceive.rxOn(0,TRUE);
	}

	task void energy()
	{
		call PhyEnergyDetect.ed();
	}

	async event void PhyEnergyDetect.edDone(phy_error_t error, uint8_t energy)
	{
		DBG_STRINT("Energy detection done. Power was:",energy,1);
	}
	
	async event void PhyTransmit.txDone(phy_error_t error)
	{
		if (error == PHY_SUCCESS) {
			DBG_STR("Transmission completed!",1);
		} else if (error == PHY_CCA_FAIL) {
			DBG_STR("Transmission failed. Channel was busy.",1);
		} else if (error == PHY_ACK_FAIL) {
			DBG_STR("Transmission failed. No ACK was received.",1);
		}
	}
	
	async event uint8_t *PhyReceive.dataReady(rxdata_t *rxPacket)
	{
		DBG_STR("Packet received",1);
		DBG_DUMP(rxPacket->frame, rxPacket->length,1);
		return rxPacket->frame;
	}

	/* We transmit a packet each time the timer fires */
	event result_t Timer.fired()
	{
		return SUCCESS;
	}
}

--- NEW FILE: TestRadioDriver.nc ---
includes mcuToRadioPorts;

configuration TestRadioDriver {
}
implementation {
	components Main,
	           TestRadioDriverM,
	           SingleTimer,
	           mc13192PhyDriverM,
	           mc13192PhyInitM,
	           //mc13192ControlM,
	           mc13192PhyInterruptM,
	           mc13192PhyTimerM,
	           //mc13192HardwareM,
	           LocalTimeM,
	           HPLTimer2M,
	           HPLSPIM as McuSPI,
	           ConsoleDebugM,
	           ConsoleC;

	Main.StdControl -> McuSPI.StdControl;
	Main.StdControl -> mc13192PhyInitM.StdControl;
	Main.StdControl -> mc13192PhyTimerM.StdControl;
	Main.StdControl -> ConsoleC.StdControl;
	Main.StdControl -> SingleTimer.StdControl;
	Main.StdControl -> HPLTimer2M.StdControl;
	Main.StdControl -> TestRadioDriverM.StdControl;

	TestRadioDriverM.Timer -> SingleTimer.Timer;
	TestRadioDriverM.PhyReceive -> mc13192PhyDriverM.PhyReceive;
	TestRadioDriverM.PhyTransmit -> mc13192PhyDriverM.PhyTransmit;
	TestRadioDriverM.PhyAttributes -> mc13192PhyDriverM.PhyAttributes;
	TestRadioDriverM.PhyEnergyDetect -> mc13192PhyDriverM.PhyEnergyDetect;
	TestRadioDriverM.LocalTime -> LocalTimeM.LocalTime;
	//LocalTimeM.HPLTimer -> HPLTimer2M.HPLTimer;

	mc13192PhyDriverM.Interrupt -> mc13192PhyInterruptM.Interrupt;
	mc13192PhyDriverM.Timer -> mc13192PhyTimerM.Timer;
	
	// Wire up the SPI.
	mc13192PhyInitM.SPI -> McuSPI.SPI;
	mc13192PhyDriverM.SPI -> McuSPI.SPI;
	mc13192PhyInterruptM.SPI -> McuSPI.SPI;
	mc13192PhyTimerM.SPI -> McuSPI.SPI;
	//mc13192HardwareM.SPI -> McuSPI.SPI;

	//mc13192ControlM.Regs -> mc13192HardwareM.Regs;

	// Wire debug module.
	ConsoleDebugM.ConsoleOut -> ConsoleC.ConsoleOut;
	mc13192PhyDriverM.Debug -> ConsoleDebugM.Debug;
	mc13192PhyInterruptM.Debug -> ConsoleDebugM.Debug;
	mc13192PhyTimerM.Debug -> ConsoleDebugM.Debug;
	TestRadioDriverM.Debug -> ConsoleDebugM.Debug;
}







--- NEW FILE: Makefile ---
# Makefile for TestRadioDriver application. 

COMPONENT=TestRadioDriver
include ../Makerules


--- NEW FILE: SingleTimer.nc ---
// $Id: SingleTimer.nc,v 1.1 2006/08/23 09:41:13 janflora Exp $

/*									tab:4
 * "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."
 *
 * Copyright (c) 2002-2003 Intel Corporation
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached INTEL-LICENSE     
 * file. If you do not find these files, copies can be found by writing to
 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
 * 94704.  Attention:  Intel License Inquiry.
 */
/*
 *
 * Authors:		Phil Levis
 * Date last modified:  7/30/03
 * Description:         This component provides a single timer, it is used in
 *                      the TinyOS tutorials to provide a Timer without
 *			requiring all of the mechanisms of parameterized
 *			interfaces.
 */

/**
 * @author Phil Levis
 */


configuration SingleTimer {
  provides interface Timer;
  provides interface StdControl;
}

implementation {
  components TimerC;
  
  Timer = TimerC.Timer[unique("Timer")];
  StdControl = TimerC;
}



More information about the Tinyos-contrib-commits mailing list