From 57ecb3ce42213a45b328c058169d2d8d07bd3b3c Mon Sep 17 00:00:00 2001 From: kristinwright Date: Sat, 5 Nov 2005 16:38:03 +0000 Subject: [PATCH] Initial revision --- apps/tests/TestSleep/Makefile | 3 + apps/tests/TestSleep/TestSleepC.nc | 44 +++++++++ apps/tests/TestSleep/TestSleepM.nc | 41 ++++++++ apps/tests/mica2/ADC/Makefile | 4 + apps/tests/mica2/ADC/TestADCC.nc | 70 ++++++++++++++ apps/tests/mica2/ADC/TestADCM.nc | 89 +++++++++++++++++ apps/tests/mica2/I2C/Makefile | 4 + apps/tests/mica2/I2C/TestI2CC.nc | 47 +++++++++ apps/tests/mica2/I2C/TestI2CM.nc | 100 +++++++++++++++++++ apps/tests/mica2/Radio/Makefile | 4 + apps/tests/mica2/Radio/TestRadioC.nc | 58 +++++++++++ apps/tests/mica2/Radio/TestRadioM.nc | 84 ++++++++++++++++ apps/tests/mica2/Timer/BlinkC.nc | 45 +++++++++ apps/tests/mica2/Timer/BlinkM.nc | 127 +++++++++++++++++++++++++ apps/tests/mica2/Timer/Makefile | 3 + apps/tests/mica2/mts300/Makefile | 5 + apps/tests/mica2/mts300/TestMts300C.nc | 55 +++++++++++ apps/tests/mica2/mts300/TestMts300P.nc | 79 +++++++++++++++ 18 files changed, 862 insertions(+) create mode 100644 apps/tests/TestSleep/Makefile create mode 100644 apps/tests/TestSleep/TestSleepC.nc create mode 100644 apps/tests/TestSleep/TestSleepM.nc create mode 100644 apps/tests/mica2/ADC/Makefile create mode 100644 apps/tests/mica2/ADC/TestADCC.nc create mode 100644 apps/tests/mica2/ADC/TestADCM.nc create mode 100644 apps/tests/mica2/I2C/Makefile create mode 100644 apps/tests/mica2/I2C/TestI2CC.nc create mode 100644 apps/tests/mica2/I2C/TestI2CM.nc create mode 100644 apps/tests/mica2/Radio/Makefile create mode 100644 apps/tests/mica2/Radio/TestRadioC.nc create mode 100644 apps/tests/mica2/Radio/TestRadioM.nc create mode 100644 apps/tests/mica2/Timer/BlinkC.nc create mode 100644 apps/tests/mica2/Timer/BlinkM.nc create mode 100644 apps/tests/mica2/Timer/Makefile create mode 100644 apps/tests/mica2/mts300/Makefile create mode 100644 apps/tests/mica2/mts300/TestMts300C.nc create mode 100644 apps/tests/mica2/mts300/TestMts300P.nc diff --git a/apps/tests/TestSleep/Makefile b/apps/tests/TestSleep/Makefile new file mode 100644 index 00000000..4129adb3 --- /dev/null +++ b/apps/tests/TestSleep/Makefile @@ -0,0 +1,3 @@ +COMPONENT=TestSleepC +include $(MAKERULES) + diff --git a/apps/tests/TestSleep/TestSleepC.nc b/apps/tests/TestSleep/TestSleepC.nc new file mode 100644 index 00000000..df397d54 --- /dev/null +++ b/apps/tests/TestSleep/TestSleepC.nc @@ -0,0 +1,44 @@ +/// $Id$ + +/** + * "Copyright (c) 2005 Crossbow Technology, Inc. + * 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 COPYRIGHT HOLDERS AND CONTRIBUTORS 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 COPYRIGHT HOLDERS AND CONTRIBUTORS HAVE BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * THE COPYRIGHT HOLDERS AND CONTRIBUTORS SPECIFICALLY DISCLAIM 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 COPYRIGHT HOLDERS AND CONTRIBUTORS HAVE NO OBLIGATION + * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + */ + +/// @author Martin Turon + +/** + * TestSleep simple puts the processor into sleep mode and stays there. + * The instananeous and average current should be ~20 uA on the ATmega128. + */ +configuration TestSleepC +{ +} +implementation +{ + components MainC, TestSleepM, + HplSleepC; // Low-level control just for test purposes + + TestSleepM -> MainC.Boot; + + TestSleepM.PowerManager -> HplSleepC; +} + diff --git a/apps/tests/TestSleep/TestSleepM.nc b/apps/tests/TestSleep/TestSleepM.nc new file mode 100644 index 00000000..aad43864 --- /dev/null +++ b/apps/tests/TestSleep/TestSleepM.nc @@ -0,0 +1,41 @@ +/// $Id$ + +/** + * "Copyright (c) 2005 Crossbow Technology, Inc. + * 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 COPYRIGHT HOLDERS AND CONTRIBUTORS 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 COPYRIGHT HOLDERS AND CONTRIBUTORS HAVE BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * THE COPYRIGHT HOLDERS AND CONTRIBUTORS SPECIFICALLY DISCLAIM 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 COPYRIGHT HOLDERS AND CONTRIBUTORS HAVE NO OBLIGATION + * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + */ + +/// @author Martin Turon + +module TestSleepM +{ + uses interface Boot; + + uses interface McuSleep as PowerManager; +} +implementation +{ + event void Boot.booted() + { + call PowerManager.enable(); + } +} + diff --git a/apps/tests/mica2/ADC/Makefile b/apps/tests/mica2/ADC/Makefile new file mode 100644 index 00000000..83ee403c --- /dev/null +++ b/apps/tests/mica2/ADC/Makefile @@ -0,0 +1,4 @@ +COMPONENT=TestADCC +CFLAGS += -I%T/lib/adc -I%T/oski/services -I%T/oski/interfaces -I%T/oski/types -I%T/oski/impls +include $(MAKERULES) + diff --git a/apps/tests/mica2/ADC/TestADCC.nc b/apps/tests/mica2/ADC/TestADCC.nc new file mode 100644 index 00000000..dd453f94 --- /dev/null +++ b/apps/tests/mica2/ADC/TestADCC.nc @@ -0,0 +1,70 @@ +// $Id$ + +/* tab:4 + * "Copyright (c) 2000-2005 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-2005 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. + * + * Copyright (c) 2004-2005 Crossbow Technology, Inc. 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 CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS 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 CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL 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 NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR + * MODIFICATIONS. + */ + +/** + * + * @author tinyos-help@millennium.berkeley.edu + * @author Hu Siquan + **/ + +configuration TestADCC +{ +} +implementation +{ + components Main, TestADCM, DemoSensorC, LedsC; + + TestADCM -> Main.Boot; + Main.SoftwareInit -> LedsC; + TestADCM.Leds -> LedsC; + TestADCM.SensorControl -> DemoSensorC; + TestADCM.AcquireData -> DemoSensorC; +} + diff --git a/apps/tests/mica2/ADC/TestADCM.nc b/apps/tests/mica2/ADC/TestADCM.nc new file mode 100644 index 00000000..5d678b96 --- /dev/null +++ b/apps/tests/mica2/ADC/TestADCM.nc @@ -0,0 +1,89 @@ +// $Id$ + +/* tab:4 + * "Copyright (c) 2000-2005 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. + * + * Copyright (c) 2004-2005 Crossbow Technology, Inc. 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 CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS 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 CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL 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 NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR + * MODIFICATIONS. + */ +/** + * + * @author Hu Siquan + * + * Implementation for TestADC application. + * Toggle the green LED when a dataReady event fires. + **/ + + +module TestADCM +{ + uses interface StdControl as SensorControl; + uses interface AcquireData; + uses interface Leds; + uses interface Boot; +} +implementation +{ + event void Boot.booted() + { + call Leds.led0Toggle(); + call SensorControl.start(); + call AcquireData.getData(); + } + + event void AcquireData.dataReady(uint16_t data) { + call SensorControl.stop(); + call Leds.led1Toggle(); + if (data & 1) + call Leds.led2On(); + else + call Leds.led2Off(); + } + + event void AcquireData.error(uint16_t info) { + call SensorControl.stop(); + } +} + diff --git a/apps/tests/mica2/I2C/Makefile b/apps/tests/mica2/I2C/Makefile new file mode 100644 index 00000000..e8079e1c --- /dev/null +++ b/apps/tests/mica2/I2C/Makefile @@ -0,0 +1,4 @@ +COMPONENT=TestI2CC +CFLAGS += -I%T/lib/oski +include $(MAKERULES) + diff --git a/apps/tests/mica2/I2C/TestI2CC.nc b/apps/tests/mica2/I2C/TestI2CC.nc new file mode 100644 index 00000000..49e4dde8 --- /dev/null +++ b/apps/tests/mica2/I2C/TestI2CC.nc @@ -0,0 +1,47 @@ +// $Id$ + +/** + * Copyright (c) 2004-2005 Crossbow Technology, Inc. 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 CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS 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 CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL 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 NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR + * MODIFICATIONS. + */ + +/// @author Martin Turon + +/** This version of TestI2C is designed to test the ATmega128 I2C subsystem. */ +configuration TestI2CC +{ +} +implementation +{ + components + MainC, TestI2CM, LedsC, + new OskiTimerMilliC() as Timer0, + HplI2CBusC as I2C; + //new HalI2CMasterC(0x58) as I2CPot; // ad5242 for mag on MTS310 + + TestI2CM -> MainC.Boot; + MainC.SoftwareInit -> LedsC; + + TestI2CM.Timer0 -> Timer0; + TestI2CM.Leds -> LedsC; + TestI2CM.I2C -> I2C; + I2C.Leds -> LedsC; +} + diff --git a/apps/tests/mica2/I2C/TestI2CM.nc b/apps/tests/mica2/I2C/TestI2CM.nc new file mode 100644 index 00000000..bca6c2c1 --- /dev/null +++ b/apps/tests/mica2/I2C/TestI2CM.nc @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2004-2005 Crossbow Technology, Inc. + * 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 (updated) modification history and the author appear in + * all copies of this source code. + * + * Permission is also granted to distribute this software under the + * standard BSD license as contained in the TinyOS distribution. + * + * 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 HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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. + * + * @author Martin Turon + * + * $Id$ + */ + +/** + * Implementation for TestI2C application: + * Yellow == Every timer, post task for I2C ping if not already running + * Red & GREEN == task started + * Red == Device ping FAIL + * Green == Device ping SUCCESS + * + * @version 2005/9/11 mturon Initial version + */ + +#define I2C_DEVICE I2C_MTS300_MIC + +#define I2C_MTS310_MAG 0x58 +#define I2C_MTS300_MIC 0x5A +#define I2C_MDA300_ADC 0x94 +#define I2C_MDA300_EE 0xAE + +includes Timer; + +module TestI2CM +{ + uses interface Timer as Timer0; + uses interface Leds; + uses interface Boot; + uses interface HplI2CBus as I2C; +} +implementation +{ + bool working; + + task void i2c_test() { + call Leds.led1On(); + call Leds.led0On(); + + if (call I2C.ping(I2C_DEVICE) == SUCCESS) { + call Leds.led0Off(); + } else { + call Leds.led1Off(); + } + + working = FALSE; + } + + void i2c_test_start() { + atomic { + if (!working) { + working = TRUE; + post i2c_test(); + } + } + } + + event void Boot.booted() { + working = FALSE; + call I2C.init(); + + call Timer0.startPeriodic( 10000 ); + + call Leds.led2On(); + i2c_test_start(); + } + + event void Timer0.fired() { + call Leds.led2Toggle(); + i2c_test_start(); + } + + async event void I2C.symbolSent() { } + +} + diff --git a/apps/tests/mica2/Radio/Makefile b/apps/tests/mica2/Radio/Makefile new file mode 100644 index 00000000..67dc77b4 --- /dev/null +++ b/apps/tests/mica2/Radio/Makefile @@ -0,0 +1,4 @@ +COMPONENT=TestRadioC +CFLAGS += -I%T/oski/services -I%T/oski/interfaces -I%T/oski/types -I%T/oski/impls +include $(MAKERULES) + diff --git a/apps/tests/mica2/Radio/TestRadioC.nc b/apps/tests/mica2/Radio/TestRadioC.nc new file mode 100644 index 00000000..809562dd --- /dev/null +++ b/apps/tests/mica2/Radio/TestRadioC.nc @@ -0,0 +1,58 @@ +// $Id$ + +/* tab:4 + * "Copyright (c) 2000-2005 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-2005 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. + */ + +/** + * Blink is a basic application that toggles the a mote LED periodically. + * It does so by starting a Timer that fires every second. It uses the + * OSKI TimerMilli service to achieve this goal. + * + * @author tinyos-help@millennium.berkeley.edu + **/ + +configuration TestRadioC +{ +} +implementation +{ + components Main, TestRadioM, new TimerMilli() as Timer0, LedsC, CSMARadioC; + + TestRadioM -> Main.Boot; + Main.SoftwareInit -> LedsC; + Main.SoftwareInit -> CSMARadioC; + + TestRadioM.SplitControl -> CSMARadioC; + TestRadioM.Send -> CSMARadioC; + TestRadioM.Receive -> CSMARadioC; + TestRadioM.Timer0 -> Timer0; + TestRadioM.Leds -> LedsC; + +} + diff --git a/apps/tests/mica2/Radio/TestRadioM.nc b/apps/tests/mica2/Radio/TestRadioM.nc new file mode 100644 index 00000000..3778ee0a --- /dev/null +++ b/apps/tests/mica2/Radio/TestRadioM.nc @@ -0,0 +1,84 @@ +// $Id$ + +/* tab:4 + * "Copyright (c) 2000-2005 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. + */ + +/** + * Implementation for TestRadio application. Toggle the red LED when a + * Timer fires. + **/ + +includes Timer; + +module TestRadioM +{ + uses interface Timer as Timer0; + uses interface SplitControl; + uses interface Send; + uses interface Receive; + uses interface Leds; + uses interface Boot; +} +implementation +{ + message_t msg; + + event void Boot.booted() + { + call SplitControl.start(); + } + + event void SplitControl.startDone(error_t error) { + call Timer0.startPeriodic( 1000 ); + } + + event void SplitControl.stopDone(error_t error) { + } + + event void Timer0.fired() + { + call Leds.led0Toggle(); + msg.header.addr = 0xffff; + msg.header.group = 0x42; + msg.data[0] = 0xaa; + msg.data[1] = 0xbb; + msg.header.length = 2; + if (call Send.send(&msg, 2) == SUCCESS) + call Leds.led1Toggle(); + } + + event void Send.sendDone(message_t* mmsg, error_t error) { + call Leds.led2Toggle(); + } + + event message_t* Receive.receive(message_t* mmsg, void* payload, uint8_t len) { + return mmsg; + } +} + diff --git a/apps/tests/mica2/Timer/BlinkC.nc b/apps/tests/mica2/Timer/BlinkC.nc new file mode 100644 index 00000000..e1cc8449 --- /dev/null +++ b/apps/tests/mica2/Timer/BlinkC.nc @@ -0,0 +1,45 @@ +// $Id$ + +/** + * Copyright (c) 2004-2005 Crossbow Technology, Inc. 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 CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS 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 CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL 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 NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR + * MODIFICATIONS. + */ + +/// @author Martin Turon + +/** This version of Blink is designed to test ATmega128 AVR timers. */ +configuration BlinkC +{ +} +implementation +{ + components MainC, new BlinkM(uint8_t), LedsC, HplTimerC; + + BlinkM.Boot -> MainC; + MainC.SoftwareInit -> LedsC; + BlinkM.Leds -> LedsC; + + BlinkM.Timer -> HplTimerC.Timer0; + BlinkM.Compare -> HplTimerC.Compare0; + + BlinkM.FastTimer -> HplTimerC.Timer1; + BlinkM.FastCompare -> HplTimerC.Compare1A; +} + diff --git a/apps/tests/mica2/Timer/BlinkM.nc b/apps/tests/mica2/Timer/BlinkM.nc new file mode 100644 index 00000000..47999db9 --- /dev/null +++ b/apps/tests/mica2/Timer/BlinkM.nc @@ -0,0 +1,127 @@ +// $Id$ + +/** + * Copyright (c) 2004-2005 Crossbow Technology, Inc. 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 CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS 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 CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL 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 NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR + * MODIFICATIONS. + */ + +/// @author Martin Turon + +#define SLOW_COMPARE 50 +#define SLOW_COMPARE_ON_CYCLE 320 +#define SLOW_OVERFLOW_CYCLES 500 + +#define FAST_COMPARE 16000 +#define FAST_COMPARE_ON_CYCLE 4 +#define FAST_OVERFLOW_CYCLES 5 + +#include + +/** + * This version of Blink is designed to test ATmega128 AVR timers. + */ +generic module BlinkM(typedef timer_size @integer()) +{ + uses interface HplTimer as Timer; + uses interface HplCompare as Compare; + uses interface HplTimer as FastTimer; + uses interface HplCompare as FastCompare; + uses interface Boot; + uses interface Leds; +} +implementation +{ + norace int scycle = SLOW_OVERFLOW_CYCLES; + norace int fcycle = FAST_OVERFLOW_CYCLES; + + void slow_timer_init() { + atomic { + CLR_BIT(ASSR, AS0); // set Timer/Counter0 to use 32,768khz crystal + + call Timer.setScale(ATM128_CLK8_DIVIDE_32); + call Compare.set(SLOW_COMPARE); // trigger compare in middle of range + call Compare.start(); + + call Timer.start(); + call Timer.set(0); // overflow after 256-6 = 250 cycles + } + } + + void fast_timer_init() { + + atomic { + call FastTimer.setScale(AVR_CLOCK_DIVIDE_8); + call FastCompare.set(FAST_COMPARE); // trigger compare mid pulse + call FastCompare.start(); + + call FastTimer.start(); + call FastTimer.set(0); // overflow after 256-6 = 250 cycles + } + } + + event void Boot.booted() { + slow_timer_init(); + fast_timer_init(); + + while(1) {} + } + + async event void Compare.fired() { + call Leds.led0On(); + call Compare.stop(); + } + + async event void Timer.overflow() { + call Timer.reset(); + + if (scycle == SLOW_COMPARE_ON_CYCLE) { + call Compare.reset(); + call Compare.start(); + } + + if (scycle++ > SLOW_OVERFLOW_CYCLES) { + scycle = 0; + call Leds.led0Off(); + } + } + + async event void FastCompare.fired() { + if (fcycle == FAST_COMPARE_ON_CYCLE) { + call Leds.led2On(); + call FastCompare.stop(); + } + } + + async event void FastTimer.overflow() { + call FastTimer.reset(); + + if (fcycle == FAST_COMPARE_ON_CYCLE) { + call FastCompare.reset(); + call FastCompare.start(); + } + + if (fcycle++ > FAST_OVERFLOW_CYCLES) { + fcycle = 0; + call Leds.led1Toggle(); // toggle overflow led + call Leds.led2Off(); // clear compare led + } + } +} + diff --git a/apps/tests/mica2/Timer/Makefile b/apps/tests/mica2/Timer/Makefile new file mode 100644 index 00000000..57038bd6 --- /dev/null +++ b/apps/tests/mica2/Timer/Makefile @@ -0,0 +1,3 @@ +COMPONENT=BlinkC +include $(MAKERULES) + diff --git a/apps/tests/mica2/mts300/Makefile b/apps/tests/mica2/mts300/Makefile new file mode 100644 index 00000000..ba11c404 --- /dev/null +++ b/apps/tests/mica2/mts300/Makefile @@ -0,0 +1,5 @@ +COMPONENT=TestMts300C +SENSORBOARD=mts300 +CFLAGS += -I%T/lib/oski +#CFLAGS += -I%T/sensorboards/mts300 +include $(MAKERULES) diff --git a/apps/tests/mica2/mts300/TestMts300C.nc b/apps/tests/mica2/mts300/TestMts300C.nc new file mode 100644 index 00000000..658fd862 --- /dev/null +++ b/apps/tests/mica2/mts300/TestMts300C.nc @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2004-2005 Crossbow Technology, Inc. + * 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 (updated) modification history and the author appear in + * all copies of this source code. + * + * Permission is also granted to distribute this software under the + * standard BSD license as contained in the TinyOS distribution. + * + * 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 HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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. + * + * @author Martin Turon + * + * $Id$ + */ + +/** + * This application tests the mts300 sensorboard. + * Specifically, this handles the thermistor and light sensors. + * + * @author Martin Turon + * @date October 19, 2005 + */ +configuration TestMts300C { +} +implementation +{ + components MainC, TestMts300P, LedsC, new OskiTimerMilliC(), + SensorMts300C; + + MainC.SoftwareInit -> LedsC; + MainC.SoftwareInit -> SensorMts300C; + + TestMts300P -> MainC.Boot; + TestMts300P.Leds -> LedsC; + TestMts300P.AppTimer -> OskiTimerMilliC; + + TestMts300P.SensorControl -> SensorMts300C; + TestMts300P.Temp -> SensorMts300C.Temp; + TestMts300P.Light -> SensorMts300C.Light; +} + diff --git a/apps/tests/mica2/mts300/TestMts300P.nc b/apps/tests/mica2/mts300/TestMts300P.nc new file mode 100644 index 00000000..65992a91 --- /dev/null +++ b/apps/tests/mica2/mts300/TestMts300P.nc @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2004-2005 Crossbow Technology, Inc. + * 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 (updated) modification history and the author appear in + * all copies of this source code. + * + * Permission is also granted to distribute this software under the + * standard BSD license as contained in the TinyOS distribution. + * + * 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 HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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. + * + * @author Martin Turon + * + * $Id$ + */ + +includes Timer; + +/** + * This application tests the mts300 sensorboard. + * Specifically, this handles the thermistor and light sensors. + * + * @author Martin Turon + * @date October 19, 2005 + */ +module TestMts300P +{ + uses { + interface Boot; + interface Leds; + interface Timer as AppTimer; + + interface StdControl as SensorControl; + interface AcquireData as Temp; + interface AcquireData as Light; + } +} +implementation +{ + event void Boot.booted() { + call Leds.led0On(); + call Leds.led1On(); // power led + call SensorControl.start(); + } + + event void AppTimer.fired() { + call Leds.led0Toggle(); // heartbeat indicator + call Light.getData(); + call Temp.getData(); + } + + event void Light.dataReady(uint16_t data) { + call Leds.led1Toggle(); + } + + event void Temp.dataReady(uint16_t data) { + call Leds.led2Toggle(); + } + + event void Light.error(uint16_t info) { + } + + event void Temp.error(uint16_t info) { + } +} + -- 2.39.2