--- /dev/null
+COMPONENT=TestBasicMacC
+CFLAGS += -I%T/oski/services -I%T/oski/interfaces -I%T/oski/types -I%T/oski/impls
+include $(MAKERULES)
+
--- /dev/null
+/* 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.
+ */
+/**
+ *
+ **/
+
+includes Timer;
+includes TOSMsg;
+configuration TestBasicMacC {
+}
+implementation {
+ components Main, TestBasicMacM
+ , new AlarmMilliC() as SendTimer
+ , new OSKITimerMsC() as RxTimeoutTimer
+ , LedsC
+ , TDA5250RadioC
+ , RandomLfsrC
+ , UARTPhyM
+ , PacketSerializerM
+ , BasicMacM
+ ;
+
+ Main.SoftwareInit -> TDA5250RadioC.Init;
+ Main.SoftwareInit -> RandomLfsrC.Init;
+ Main.SoftwareInit -> LedsC.Init;
+ Main.SoftwareInit -> UARTPhyM.Init;
+ Main.SoftwareInit -> PacketSerializerM.Init;
+ Main.SoftwareInit -> BasicMacM.Init;
+ TestBasicMacM -> Main.Boot;
+
+ TestBasicMacM.Random -> RandomLfsrC.Random;
+ TestBasicMacM.SendTimer -> SendTimer;
+ TestBasicMacM.Leds -> LedsC;
+ TestBasicMacM.Send -> PacketSerializerM.Send;
+ TestBasicMacM.Receive -> PacketSerializerM.Receive;
+ TestBasicMacM.MacSplitControl -> BasicMacM.SplitControl;
+
+ PacketSerializerM.RadioByteComm -> BasicMacM.RadioByteComm;
+ PacketSerializerM.PhyPacketTx -> BasicMacM.PhyPacketTx;
+ PacketSerializerM.PhyPacketRx -> BasicMacM.PhyPacketRx;
+
+ BasicMacM.TDA5250Control -> TDA5250RadioC.TDA5250Control;
+ BasicMacM.TDA5250RadioByteComm -> UARTPhyM.SerializerRadioByteComm;
+ BasicMacM.TDA5250PhyPacketTx -> UARTPhyM.PhyPacketTx;
+ BasicMacM.TDA5250PhyPacketRx -> UARTPhyM.PhyPacketRx;
+ BasicMacM.RxTimeoutTimer -> RxTimeoutTimer;
+ BasicMacM.RadioSplitControl -> TDA5250RadioC.SplitControl;
+
+ UARTPhyM.RadioByteComm -> TDA5250RadioC.RadioByteComm;
+}
+
+
+
--- /dev/null
+// $Id$
+
+/* 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.
+ */
+
+module TestBasicMacM {
+ uses {
+ interface Boot;
+ interface SplitControl as MacSplitControl;
+ interface Alarm<TMilli, uint32_t> as SendTimer;
+ interface Leds;
+ interface Random;
+ interface Send;
+ interface Receive;
+ }
+}
+
+implementation {
+
+ #define TIMER_RATE 500
+ #define NUM_BYTES TOSH_DATA_LENGTH
+
+ message_t sendMsg;
+
+ event void Boot.booted() {
+ uint8_t i;
+ for(i=0; i<NUM_BYTES; i++)
+ sendMsg.data[i] = 0xF0;//call Random.rand16() / 2;
+ call MacSplitControl.start();
+ }
+
+ event void MacSplitControl.startDone(error_t error) {
+ call Send.send(&sendMsg, NUM_BYTES);
+ }
+
+ event void MacSplitControl.stopDone(error_t error) {
+ call SendTimer.stop();
+ }
+
+ async event void SendTimer.fired() {
+ call Send.send(&sendMsg, NUM_BYTES);
+ }
+
+ event void Send.sendDone(message_t* msg, error_t error) {
+ if(error == SUCCESS)
+ call Leds.led0Toggle();
+ else call Leds.led2Toggle();
+ call SendTimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) {
+ call Leds.led1Toggle();
+ return msg;
+ }
+}
+
+
--- /dev/null
+COMPONENT=TestTDA5250ControlC
+CFLAGS += -I%T/oski/services -I%T/oski/interfaces -I%T/oski/types -I%T/oski/impls
+include $(MAKERULES)
+
--- /dev/null
+/* 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.
+ */
+/**
+ *
+ **/
+
+includes Timer;
+configuration TestTDA5250ControlC {
+}
+implementation {
+ components Main, TestTDA5250ControlM
+ , new AlarmMilliC() as ModeTimer
+ , LedsC
+ , TDA5250RadioC
+ , RandomLfsrC
+ ;
+
+ Main.SoftwareInit -> TDA5250RadioC.Init;
+ Main.SoftwareInit -> RandomLfsrC.Init;
+ Main.SoftwareInit -> LedsC.Init;
+ TestTDA5250ControlM -> Main.Boot;
+
+ TestTDA5250ControlM.Random -> RandomLfsrC.Random;
+ TestTDA5250ControlM.ModeTimer -> ModeTimer;
+ TestTDA5250ControlM.Leds -> LedsC;
+ TestTDA5250ControlM.TDA5250Control -> TDA5250RadioC.TDA5250Control;
+ TestTDA5250ControlM.RadioSplitControl -> TDA5250RadioC.SplitControl;
+}
+
+
+
--- /dev/null
+// $Id$
+
+/* 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.
+ */
+
+module TestTDA5250ControlM {
+ uses {
+ interface Boot;
+ interface Alarm<TMilli, uint32_t> as ModeTimer;
+ interface Leds;
+ interface TDA5250Control;
+ interface Random;
+ interface SplitControl as RadioSplitControl;
+ }
+}
+
+implementation {
+
+ #define MODE_TIMER_RATE 500
+
+ uint8_t mode;
+
+ event void Boot.booted() {
+ atomic mode = 0;
+ call RadioSplitControl.start();
+ }
+
+ event void RadioSplitControl.startDone(error_t error) {
+ call ModeTimer.start(MODE_TIMER_RATE);
+ }
+
+ event void RadioSplitControl.stopDone(error_t error) {
+ call ModeTimer.stop();
+ }
+
+ /***********************************************************************
+ * Commands and events
+ ***********************************************************************/
+
+ async event void ModeTimer.fired() {
+ switch(mode) {
+ case 0:
+ call TDA5250Control.TimerMode(call Random.rand16() % MODE_TIMER_RATE/20,
+ call Random.rand16() % MODE_TIMER_RATE/20);
+ break;
+ case 1:
+ call TDA5250Control.SelfPollingMode(call Random.rand16() % MODE_TIMER_RATE/20,
+ call Random.rand16() % MODE_TIMER_RATE/20);
+ break;
+ case 2:
+ call TDA5250Control.RxMode();
+ break;
+ case 3:
+ call TDA5250Control.TxMode();
+ break;
+ case 4:
+ call TDA5250Control.SleepMode();
+ break;
+ case 5:
+ call TDA5250Control.CCAMode();
+ break;
+ }
+ }
+
+ async event void TDA5250Control.PWDDDInterrupt() {
+ //call TDA5250Control.RxMode();
+ }
+
+ async event void TDA5250Control.TimerModeDone(){
+ atomic mode = call Random.rand16() % 6;
+ call Leds.led0On();
+ call Leds.led1On();
+ call Leds.led2On();
+ call ModeTimer.start(call Random.rand16() % MODE_TIMER_RATE);
+ }
+ async event void TDA5250Control.SelfPollingModeDone(){
+ atomic mode = call Random.rand16() % 6;
+ call Leds.led0On();
+ call Leds.led1On();
+ call Leds.led2Off();
+ call ModeTimer.start(call Random.rand16() % MODE_TIMER_RATE);
+ }
+ async event void TDA5250Control.RxModeDone(){
+ atomic mode = call Random.rand16() % 6;
+ call Leds.led0On();
+ call Leds.led1Off();
+ call Leds.led2On();
+ call ModeTimer.start(call Random.rand16() % MODE_TIMER_RATE);
+ }
+ async event void TDA5250Control.TxModeDone(){
+ atomic mode = call Random.rand16() % 6;
+ call Leds.led0Off();
+ call Leds.led1On();
+ call Leds.led2On();
+ call ModeTimer.start(call Random.rand16() % MODE_TIMER_RATE);
+ }
+ async event void TDA5250Control.SleepModeDone(){
+ atomic mode = call Random.rand16() % 6;
+ call Leds.led0Off();
+ call Leds.led1Off();
+ call Leds.led2On();
+ call ModeTimer.start(call Random.rand16() % MODE_TIMER_RATE);
+ }
+ async event void TDA5250Control.CCAModeDone(){
+ atomic mode = call Random.rand16() % 6;
+ call Leds.led0On();
+ call Leds.led1Off();
+ call Leds.led2Off();
+ call ModeTimer.start(call Random.rand16() % MODE_TIMER_RATE);
+ }
+
+}
+
+
--- /dev/null
+COMPONENT=TestHPLTDA5250C
+CFLAGS += -I%T/oski/services -I%T/oski/interfaces -I%T/oski/types -I%T/oski/impls
+include $(MAKERULES)
+
--- /dev/null
+// $Id$
+
+/* 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.
+ */
+/**
+ *
+ **/
+
+includes Timer;
+configuration TestHPLTDA5250C {
+}
+implementation {
+ components Main
+ , TestHPLTDA5250M
+ , new AlarmMilliC() as ModeTimer
+ , LedsC
+ , TDA5250ConfigC
+ ;
+
+ TestHPLTDA5250M -> Main.Boot;
+
+ Main.SoftwareInit -> LedsC;
+ Main.SoftwareInit -> TDA5250ConfigC;
+
+ TestHPLTDA5250M.Resource -> TDA5250ConfigC.Resource;
+ TestHPLTDA5250M.ModeTimer -> ModeTimer;
+ TestHPLTDA5250M.Leds -> LedsC;
+ TestHPLTDA5250M.TDA5250Config -> TDA5250ConfigC;
+}
+
+
+
--- /dev/null
+/*
+ * Copyright (c) 2004, Technische Universitat Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitat Berlin nor the names
+ * of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * ========================================================================
+ */
+
+ /**
+ * TestTDA5250M Application
+ * Test Application for the HPL layer of the TDA5250 radio
+ *
+ * @author Kevin Klues (klues@tkn.tu-berlin.de)
+ */
+
+module TestHPLTDA5250M {
+ uses {
+ interface Boot;
+ interface Leds;
+ interface Alarm<TMilli, uint32_t> as ModeTimer;
+ interface TDA5250Config;
+ interface Resource;
+ }
+}
+
+implementation {
+
+ uint8_t mode;
+
+ event void Boot.booted() {
+ mode = 0;
+ call Resource.request();
+ }
+
+ event void Resource.granted() {
+ call TDA5250Config.reset();
+ call ModeTimer.start(50);
+ }
+
+ event void Resource.requested() {
+ call ModeTimer.stop();
+ call Resource.release();
+ call Resource.request();
+ }
+
+ /***********************************************************************
+ * Commands and events
+ ***********************************************************************/
+ async event void ModeTimer.fired() {
+ if(mode == 0) {
+ call TDA5250Config.SetRxMode();
+ mode = 1;
+ call Leds.led0Off();
+ call Leds.led1Off();
+ call Leds.led2Off();
+ }
+ else if(mode == 1) {
+ call TDA5250Config.SetTxMode();
+ mode = 2;
+ call Leds.led0Off();
+ call Leds.led1Off();
+ call Leds.led2On();
+ }
+ else if(mode == 2) {
+ call TDA5250Config.SetTimerMode(5, 5);
+ mode = 3;
+ call Leds.led0Off();
+ call Leds.led1On();
+ call Leds.led2Off();
+ }
+ else if(mode == 3) {
+ call TDA5250Config.SetSelfPollingMode(5, 5);
+ mode = 4;
+ call Leds.led0Off();
+ call Leds.led1On();
+ call Leds.led2On();
+ }
+ else {
+ call TDA5250Config.SetSlaveMode();
+ call TDA5250Config.SetSleepMode();
+ mode = 0;
+ call Leds.led0On();
+ call Leds.led1Off();
+ call Leds.led2Off();
+ }
+ call ModeTimer.start(50);
+ }
+
+ async event void TDA5250Config.PWDDDInterrupt() {
+ TOSH_TOGGLE_LED3_PIN();
+ }
+}
+
+
--- /dev/null
+COMPONENT=TestPacketSerializerC
+CFLAGS += -I%T/oski/services -I%T/oski/interfaces -I%T/oski/types -I%T/oski/impls
+include $(MAKERULES)
+
--- /dev/null
+/* 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.
+ */
+/**
+ *
+ **/
+
+includes Timer;
+includes TOSMsg;
+configuration TestPacketSerializerC {
+}
+implementation {
+ components Main, TestPacketSerializerM
+ , new AlarmMilliC() as TxTimer
+ , new AlarmMilliC() as RxTimer
+ , new AlarmMilliC() as CCATimer
+// , new AlarmMilliC() as TimerTimer
+ , new AlarmMilliC() as SelfPollingTimer
+// , new AlarmMilliC() as SleepTimer
+ , LedsC
+ , TDA5250RadioC
+ , RandomLfsrC
+ , UARTPhyM
+ , PacketSerializerM
+ ;
+
+ Main.SoftwareInit -> TDA5250RadioC.Init;
+ Main.SoftwareInit -> RandomLfsrC.Init;
+ Main.SoftwareInit -> LedsC.Init;
+ Main.SoftwareInit -> UARTPhyM.Init;
+ Main.SoftwareInit -> PacketSerializerM.Init;
+ TestPacketSerializerM -> Main.Boot;
+
+ TestPacketSerializerM.Random -> RandomLfsrC.Random;
+ TestPacketSerializerM.TxTimer -> TxTimer;
+ TestPacketSerializerM.RxTimer -> RxTimer;
+ TestPacketSerializerM.CCATimer -> CCATimer;
+// TestPacketSerializerM.TimerTimer -> TimerTimer;
+ TestPacketSerializerM.SelfPollingTimer -> SelfPollingTimer;
+// TestPacketSerializerM.SleepTimer -> SleepTimer;
+ TestPacketSerializerM.Leds -> LedsC;
+ TestPacketSerializerM.TDA5250Control -> TDA5250RadioC.TDA5250Control;
+ TestPacketSerializerM.RadioSplitControl -> TDA5250RadioC.SplitControl;
+ TestPacketSerializerM.Send -> PacketSerializerM.Send;
+ TestPacketSerializerM.Receive -> PacketSerializerM.Receive;
+
+ UARTPhyM.RadioByteComm -> TDA5250RadioC.RadioByteComm;
+
+ PacketSerializerM.RadioByteComm -> UARTPhyM.SerializerRadioByteComm;
+ PacketSerializerM.PhyPacketTx -> UARTPhyM.PhyPacketTx;
+ PacketSerializerM.PhyPacketRx -> UARTPhyM.PhyPacketRx;
+}
+
+
+
--- /dev/null
+// $Id$
+
+/* 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.
+ */
+
+module TestPacketSerializerM {
+ uses {
+ interface Boot;
+ interface Alarm<TMilli, uint32_t> as TxTimer;
+ interface Alarm<TMilli, uint32_t> as RxTimer;
+// interface Alarm<TMilli, uint32_t> as TimerTimer;
+ interface Alarm<TMilli, uint32_t> as CCATimer;
+ interface Alarm<TMilli, uint32_t> as SelfPollingTimer;
+// interface Alarm<TMilli, uint32_t> as SleepTimer;
+ interface Leds;
+ interface TDA5250Control;
+ interface Random;
+ interface SplitControl as RadioSplitControl;
+ interface Send;
+ interface Receive;
+ }
+}
+
+implementation {
+
+ #define TIMER_RATE 500
+ #define NUM_BYTES TOSH_DATA_LENGTH
+
+ uint8_t bytes_sent;
+ bool sending;
+ message_t sendMsg;
+
+ event void Boot.booted() {
+ uint8_t i;
+ bytes_sent = 0;
+ sending = FALSE;
+ for(i=0; i<NUM_BYTES; i++)
+ sendMsg.data[i] = 0x00;//call Random.rand16() / 2;
+ call RadioSplitControl.start();
+ }
+
+ event void RadioSplitControl.startDone(error_t error) {
+ call TxTimer.start(call Random.rand16() % TIMER_RATE);
+// call TimerTimer.start(call Random.rand16() % TIMER_RATE);
+ call SelfPollingTimer.start(call Random.rand16() % TIMER_RATE);
+ call RxTimer.start(call Random.rand16() % TIMER_RATE);
+ call CCATimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ event void RadioSplitControl.stopDone(error_t error) {
+ call TxTimer.stop();
+ }
+
+ /***********************************************************************
+ * Commands and events
+ ***********************************************************************/
+
+ async event void TxTimer.fired() {
+ atomic {
+ if(call TDA5250Control.TxMode() != FAIL) {
+ bytes_sent = 0;
+ sending = TRUE;
+ call Leds.led0On();
+ call Leds.led1On();
+ call Leds.led2On();
+ return;
+ }
+ }
+ call TxTimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ async event void RxTimer.fired() {
+ if(sending == FALSE)
+ if(call TDA5250Control.RxMode() != FAIL)
+ return;
+ call RxTimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ async event void CCATimer.fired() {
+ if(sending == FALSE)
+ if(call TDA5250Control.CCAMode() != FAIL)
+ return;
+ call CCATimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+// async event void TimerTimer.fired() {
+// if(sending == FALSE)
+// if(call TDA5250Control.TimerMode(call Random.rand16() % TIMER_RATE/20,
+// call Random.rand16() % TIMER_RATE/20) != FAIL)
+// return;
+// call TimerTimer.start(call Random.rand16() % TIMER_RATE);
+// }
+
+ async event void SelfPollingTimer.fired() {
+ if(sending == FALSE)
+ if(call TDA5250Control.SelfPollingMode(call Random.rand16() % TIMER_RATE/20,
+ call Random.rand16() % TIMER_RATE/20) != FAIL)
+ return;
+ call SelfPollingTimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+// async event void SleepTimer.fired() {
+// if(sending == FALSE)
+// if(call TDA5250Control.SleepMode() != FAIL)
+// return;
+// call SleepTimer.start(call Random.rand16() % TIMER_RATE);
+// }
+
+
+ async event void TDA5250Control.TxModeDone(){
+ call Send.send(&sendMsg, NUM_BYTES);
+ }
+
+ event void Send.sendDone(message_t* msg, error_t error) {
+ call TDA5250Control.SleepMode();
+ sending = FALSE;
+ call TxTimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len) {
+ TOSH_TOGGLE_LED3_PIN();
+ return msg;
+ }
+
+ async event void TDA5250Control.TimerModeDone(){
+// call TimerTimer.start(call Random.rand16() % TIMER_RATE);
+// call Leds.led0On();
+// call Leds.led1On();
+// call Leds.led2Off();
+ }
+ async event void TDA5250Control.SelfPollingModeDone(){
+ call SelfPollingTimer.start(call Random.rand16() % TIMER_RATE);
+ call Leds.led0On();
+ call Leds.led1Off();
+ call Leds.led2On();
+ }
+ async event void TDA5250Control.RxModeDone(){
+ call RxTimer.start(call Random.rand16() % TIMER_RATE);
+ call Leds.led0Off();
+ call Leds.led1On();
+ call Leds.led2On();
+ }
+ async event void TDA5250Control.SleepModeDone(){
+// call SleepTimer.start(call Random.rand16() % TIMER_RATE);
+ call Leds.led0Off();
+ call Leds.led1Off();
+ call Leds.led2On();
+ }
+ async event void TDA5250Control.CCAModeDone(){
+ call CCATimer.start(call Random.rand16() % TIMER_RATE);
+ call Leds.led0On();
+ call Leds.led1Off();
+ call Leds.led2Off();
+ }
+
+ async event void TDA5250Control.PWDDDInterrupt() {
+ }
+}
+
+
--- /dev/null
+COMPONENT=TestUARTPhyC
+CFLAGS += -I%T/oski/services -I%T/oski/interfaces -I%T/oski/types -I%T/oski/impls
+include $(MAKERULES)
+
--- /dev/null
+/* 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.
+ */
+/**
+ *
+ **/
+
+includes Timer;
+configuration TestUARTPhyC {
+}
+implementation {
+ components Main, TestUARTPhyM
+ , new AlarmMilliC() as TxTimer
+ , LedsC
+ , TDA5250RadioC
+ , RandomLfsrC
+ , UARTPhyM
+ ;
+
+ Main.SoftwareInit -> TDA5250RadioC.Init;
+ Main.SoftwareInit -> RandomLfsrC.Init;
+ Main.SoftwareInit -> LedsC.Init;
+ Main.SoftwareInit -> UARTPhyM.Init;
+ TestUARTPhyM -> Main.Boot;
+
+ TestUARTPhyM.Random -> RandomLfsrC.Random;
+ TestUARTPhyM.TxTimer -> TxTimer;
+ TestUARTPhyM.Leds -> LedsC;
+ TestUARTPhyM.TDA5250Control -> TDA5250RadioC.TDA5250Control;
+ TestUARTPhyM.RadioSplitControl -> TDA5250RadioC.SplitControl;
+ TestUARTPhyM.RadioByteComm -> UARTPhyM.SerializerRadioByteComm;
+ TestUARTPhyM.PhyPacketTx -> UARTPhyM.PhyPacketTx;
+ TestUARTPhyM.PhyPacketRx -> UARTPhyM.PhyPacketRx;
+
+ UARTPhyM.RadioByteComm -> TDA5250RadioC.RadioByteComm;
+}
+
+
+
--- /dev/null
+// $Id$
+
+/* 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.
+ */
+
+module TestUARTPhyM {
+ uses {
+ interface Boot;
+ interface Alarm<TMilli, uint32_t> as TxTimer;
+ interface Leds;
+ interface TDA5250Control;
+ interface Random;
+ interface SplitControl as RadioSplitControl;
+ interface PhyPacketTx;
+ interface PhyPacketRx;
+ interface RadioByteComm;
+ }
+}
+
+implementation {
+
+ #define TX_TIMER_RATE 500
+ #define NUM_BYTES 36
+
+ uint8_t bytes_sent;
+
+ event void Boot.booted() {
+ bytes_sent = 0;
+ call RadioSplitControl.start();
+ }
+
+ event void RadioSplitControl.startDone(error_t error) {
+ call TDA5250Control.TxMode();
+ }
+
+ event void RadioSplitControl.stopDone(error_t error) {
+ call TxTimer.stop();
+ }
+
+ /***********************************************************************
+ * Commands and events
+ ***********************************************************************/
+
+ async event void TxTimer.fired() {
+ call TDA5250Control.TxMode();
+ }
+
+ async event void TDA5250Control.TxModeDone(){
+ call PhyPacketTx.sendHeader(NUM_BYTES);
+ }
+
+ async event void PhyPacketTx.sendHeaderDone(error_t error) {
+ call RadioByteComm.txByte(call Random.rand16() / 2);
+ }
+
+ async event void RadioByteComm.txByteReady(error_t error) {
+ if(++bytes_sent < NUM_BYTES)
+ call RadioByteComm.txByte(call Random.rand16() / 2);
+ else {
+ bytes_sent = 0;
+ call PhyPacketTx.sendFooter();
+ }
+ }
+
+ async event void PhyPacketTx.sendFooterDone(error_t error) {
+ call TDA5250Control.SleepMode();
+ call TxTimer.start(call Random.rand16() % TX_TIMER_RATE);
+ call Leds.led0Toggle();
+ }
+
+ async event void PhyPacketRx.recvHeaderDone(uint8_t length_value) {}
+ async event void PhyPacketRx.recvFooterDone(bool error) {}
+ async event void RadioByteComm.rxByteReady(uint8_t data) {}
+
+ async event void TDA5250Control.PWDDDInterrupt() {
+ }
+ async event void TDA5250Control.TimerModeDone(){
+ }
+ async event void TDA5250Control.SelfPollingModeDone(){
+ }
+ async event void TDA5250Control.RxModeDone(){
+ }
+ async event void TDA5250Control.SleepModeDone(){
+ }
+ async event void TDA5250Control.CCAModeDone(){
+ }
+
+}
+
+
--- /dev/null
+COMPONENT=TestUARTPhyC
+CFLAGS += -I%T/oski/services -I%T/oski/interfaces -I%T/oski/types -I%T/oski/impls
+include $(MAKERULES)
+
--- /dev/null
+/* 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.
+ */
+/**
+ *
+ **/
+
+includes Timer;
+configuration TestUARTPhyC {
+}
+implementation {
+ components Main, TestUARTPhyM
+ , new AlarmMilliC() as TxTimer
+ , new AlarmMilliC() as RxTimer
+ , new AlarmMilliC() as CCATimer
+ , new AlarmMilliC() as TimerTimer
+// , new AlarmMilliC() as SelfPollingTimer
+// , new AlarmMilliC() as SleepTimer
+ , LedsC
+ , TDA5250RadioC
+ , RandomLfsrC
+ , UARTPhyM
+ ;
+
+ Main.SoftwareInit -> TDA5250RadioC.Init;
+ Main.SoftwareInit -> RandomLfsrC.Init;
+ Main.SoftwareInit -> LedsC.Init;
+ Main.SoftwareInit -> UARTPhyM.Init;
+ TestUARTPhyM -> Main.Boot;
+
+ TestUARTPhyM.Random -> RandomLfsrC.Random;
+ TestUARTPhyM.TxTimer -> TxTimer;
+ TestUARTPhyM.RxTimer -> RxTimer;
+ TestUARTPhyM.CCATimer -> CCATimer;
+ TestUARTPhyM.TimerTimer -> TimerTimer;
+// TestUARTPhyM.SelfPollingTimer -> SelfPollingTimer;
+// TestUARTPhyM.SleepTimer -> SleepTimer;
+ TestUARTPhyM.Leds -> LedsC;
+ TestUARTPhyM.TDA5250Control -> TDA5250RadioC.TDA5250Control;
+ TestUARTPhyM.RadioSplitControl -> TDA5250RadioC.SplitControl;
+ TestUARTPhyM.RadioByteComm -> UARTPhyM.SerializerRadioByteComm;
+ TestUARTPhyM.PhyPacketTx -> UARTPhyM.PhyPacketTx;
+ TestUARTPhyM.PhyPacketRx -> UARTPhyM.PhyPacketRx;
+
+ UARTPhyM.RadioByteComm -> TDA5250RadioC.RadioByteComm;
+}
+
+
+
--- /dev/null
+// $Id$
+
+/* 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.
+ */
+
+module TestUARTPhyM {
+ uses {
+ interface Boot;
+ interface Alarm<TMilli, uint32_t> as TxTimer;
+ interface Alarm<TMilli, uint32_t> as RxTimer;
+ interface Alarm<TMilli, uint32_t> as TimerTimer;
+ interface Alarm<TMilli, uint32_t> as CCATimer;
+// interface Alarm<TMilli, uint32_t> as SelfPollingTimer;
+// interface Alarm<TMilli, uint32_t> as SleepTimer;
+ interface Leds;
+ interface TDA5250Control;
+ interface Random;
+ interface SplitControl as RadioSplitControl;
+ interface PhyPacketTx;
+ interface PhyPacketRx;
+ interface RadioByteComm;
+ }
+}
+
+implementation {
+
+ #define TIMER_RATE 500
+ #define NUM_BYTES 36
+
+ uint8_t bytes_sent;
+ bool sending;
+
+ event void Boot.booted() {
+ bytes_sent = 0;
+ sending = FALSE;
+ call RadioSplitControl.start();
+ }
+
+ event void RadioSplitControl.startDone(error_t error) {
+ call TxTimer.start(call Random.rand16() % TIMER_RATE);
+ call TimerTimer.start(call Random.rand16() % TIMER_RATE);
+ call RxTimer.start(call Random.rand16() % TIMER_RATE);
+ call CCATimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ event void RadioSplitControl.stopDone(error_t error) {
+ call TxTimer.stop();
+ }
+
+ /***********************************************************************
+ * Commands and events
+ ***********************************************************************/
+
+ async event void TxTimer.fired() {
+ atomic {
+ if(call TDA5250Control.TxMode() != FAIL) {
+ bytes_sent = 0;
+ sending = TRUE;
+ call Leds.led0On();
+ call Leds.led1On();
+ call Leds.led2On();
+ return;
+ }
+ }
+ call TxTimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ async event void RxTimer.fired() {
+ if(sending == FALSE)
+ if(call TDA5250Control.RxMode() != FAIL)
+ return;
+ call RxTimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ async event void CCATimer.fired() {
+ if(sending == FALSE)
+ if(call TDA5250Control.CCAMode() != FAIL)
+ return;
+ call CCATimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ async event void TimerTimer.fired() {
+ if(sending == FALSE)
+ if(call TDA5250Control.TimerMode(call Random.rand16() % TIMER_RATE/20,
+ call Random.rand16() % TIMER_RATE/20) != FAIL)
+ return;
+ call TimerTimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+// async event void SelfPollingTimer.fired() {
+// if(sending == FALSE)
+// if(call TDA5250Control.SelfPollingMode(call Random.rand16() % TIMER_RATE/20,
+// call Random.rand16() % TIMER_RATE/20) != FAIL)
+// return;
+// call SelfPollingTimer.start(call Random.rand16() % TIMER_RATE);
+// }
+
+// async event void SleepTimer.fired() {
+// if(sending == FALSE)
+// if(call TDA5250Control.SleepMode() != FAIL)
+// return;
+// call SleepTimer.start(call Random.rand16() % TIMER_RATE);
+// }
+
+
+ async event void TDA5250Control.TxModeDone(){
+ call PhyPacketTx.sendHeader(NUM_BYTES);
+ }
+
+ async event void PhyPacketTx.sendHeaderDone(error_t error) {
+ call RadioByteComm.txByte(call Random.rand16() / 2);
+ }
+
+ async event void RadioByteComm.txByteReady(error_t error) {
+ if(++bytes_sent < NUM_BYTES)
+ call RadioByteComm.txByte(call Random.rand16() / 2);
+ else {
+ bytes_sent = 0;
+ call PhyPacketTx.sendFooter();
+ }
+ }
+
+ async event void PhyPacketTx.sendFooterDone(error_t error) {
+ call TDA5250Control.SleepMode();
+ sending = FALSE;
+ call TxTimer.start(call Random.rand16() % TIMER_RATE);
+ }
+
+ async event void TDA5250Control.TimerModeDone(){
+ call TimerTimer.start(call Random.rand16() % TIMER_RATE);
+ call Leds.led0On();
+ call Leds.led1On();
+ call Leds.led2Off();
+ }
+ async event void TDA5250Control.SelfPollingModeDone(){
+// call SelfPollingTimer.start(call Random.rand16() % TIMER_RATE);
+// call Leds.led0On();
+// call Leds.led1Off();
+// call Leds.led2On();
+ }
+ async event void TDA5250Control.RxModeDone(){
+ call RxTimer.start(call Random.rand16() % TIMER_RATE);
+ call Leds.led0Off();
+ call Leds.led1On();
+ call Leds.led2On();
+ }
+ async event void TDA5250Control.SleepModeDone(){
+// call SleepTimer.start(call Random.rand16() % TIMER_RATE);
+ call Leds.led0Off();
+ call Leds.led1Off();
+ call Leds.led2On();
+ }
+ async event void TDA5250Control.CCAModeDone(){
+ call CCATimer.start(call Random.rand16() % TIMER_RATE);
+ call Leds.led0On();
+ call Leds.led1Off();
+ call Leds.led2Off();
+ }
+
+ async event void TDA5250Control.PWDDDInterrupt() {
+ }
+ async event void PhyPacketRx.recvHeaderDone(uint8_t length_value) {}
+ async event void PhyPacketRx.recvFooterDone(bool error) {}
+ async event void RadioByteComm.rxByteReady(uint8_t data) {}
+
+}
+
+
--- /dev/null
+COMPONENT=TestTimerC
+CFLAGS += -I%T/oski/services -I%T/oski/interfaces -I%T/oski/types -I%T/oski/impls
+include $(MAKERULES)
+
--- /dev/null
+/* 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.
+ */
+/**
+ *
+ **/
+
+includes Timer;
+configuration TestTimerC {
+}
+implementation {
+ components Main, TestTimerM
+ , new AlarmMilliC() as Timer0
+ , new AlarmMilliC() as Timer1
+ , new AlarmMilliC() as Timer2
+ , new AlarmMilliC() as Timer3
+ , new AlarmMilliC() as Timer4
+ , new AlarmMilliC() as Timer5
+ , new AlarmMilliC() as Timer6
+ , new AlarmMilliC() as Timer7
+ , new AlarmMilliC() as Timer8
+ ;
+
+ TestTimerM -> Main.Boot;
+
+ TestTimerM.Timer0 -> Timer0;
+ TestTimerM.Timer1 -> Timer1;
+ TestTimerM.Timer2 -> Timer2;
+ TestTimerM.Timer3 -> Timer3;
+ TestTimerM.Timer4 -> Timer4;
+ TestTimerM.Timer5 -> Timer5;
+ TestTimerM.Timer6 -> Timer6;
+ TestTimerM.Timer7 -> Timer7;
+ TestTimerM.Timer8 -> Timer8;
+}
+
+
+
--- /dev/null
+// $Id$
+
+/* 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.
+ */
+
+module TestTimerM {
+ uses {
+ interface Boot;
+ interface Alarm<TMilli, uint32_t> as Timer0;
+ interface Alarm<TMilli, uint32_t> as Timer1;
+ interface Alarm<TMilli, uint32_t> as Timer2;
+ interface Alarm<TMilli, uint32_t> as Timer3;
+ interface Alarm<TMilli, uint32_t> as Timer4;
+ interface Alarm<TMilli, uint32_t> as Timer5;
+ interface Alarm<TMilli, uint32_t> as Timer6;
+ interface Alarm<TMilli, uint32_t> as Timer7;
+ interface Alarm<TMilli, uint32_t> as Timer8;
+ }
+}
+
+implementation {
+
+ #define DELAY 20
+
+ event void Boot.booted() {
+ call Timer0.start(DELAY);
+ }
+
+ /***********************************************************************
+ * Commands and events
+ ***********************************************************************/
+
+ async event void Timer0.fired() {
+ call Timer1.start(DELAY);
+ }
+ async event void Timer1.fired() {
+ call Timer2.start(DELAY);
+ }
+ async event void Timer2.fired() {
+ call Timer3.start(DELAY);
+ }
+ async event void Timer3.fired() {
+ call Timer4.start(DELAY);
+ }
+ async event void Timer4.fired() {
+ call Timer5.start(DELAY);
+ }
+ async event void Timer5.fired() {
+ call Timer6.start(DELAY);
+ }
+ async event void Timer6.fired() {
+ call Timer7.start(DELAY);
+ }
+ async event void Timer7.fired() {
+ call Timer8.start(DELAY);
+ }
+ async event void Timer8.fired() {
+ call Timer0.start(DELAY);
+ }
+
+}
+
+