From 246e79f8111758ae811d802c42c74765b7fa4426 Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Wed, 2 Dec 2009 16:37:00 -0700 Subject: [PATCH] Remove sensors code from tmirws platform. The sensors code is not stable enough for inclusion into core tinyos, nor is there yet a clean separation between platform code and application code. The sensors code removed here was imported with its history into the RWS application repository. --- tos/platforms/tmirws/.platform | 1 - tos/platforms/tmirws/sensors/AeroVane.h | 56 ---- tos/platforms/tmirws/sensors/AeroVaneC.nc | 51 ---- tos/platforms/tmirws/sensors/AeroVaneP.nc | 111 -------- tos/platforms/tmirws/sensors/AeroVaneReadC.nc | 61 ----- tos/platforms/tmirws/sensors/AeroVaneReadP.nc | 119 --------- tos/platforms/tmirws/sensors/Anemometer.h | 45 ---- tos/platforms/tmirws/sensors/AnemometerC.nc | 51 ---- tos/platforms/tmirws/sensors/AnemometerP.nc | 111 -------- .../tmirws/sensors/AnemometerReadC.nc | 54 ---- .../tmirws/sensors/AnemometerReadP.nc | 91 ------- tos/platforms/tmirws/sensors/Average.nc | 56 ---- tos/platforms/tmirws/sensors/AverageAngleC.nc | 104 -------- tos/platforms/tmirws/sensors/AveragePolarC.nc | 52 ---- tos/platforms/tmirws/sensors/AveragePolarP.nc | 76 ------ tos/platforms/tmirws/sensors/AverageU16C.nc | 77 ------ tos/platforms/tmirws/sensors/BatteryAdcC.nc | 61 ----- tos/platforms/tmirws/sensors/BatteryAdcP.nc | 70 ----- .../tmirws/sensors/HalAnemometerC.nc | 60 ----- .../tmirws/sensors/HalAnemometerP.nc | 110 -------- tos/platforms/tmirws/sensors/HalOwwVaneC.nc | 47 ---- tos/platforms/tmirws/sensors/HalOwwVaneP.nc | 63 ----- tos/platforms/tmirws/sensors/HalWindVaneC.nc | 56 ---- tos/platforms/tmirws/sensors/HalWindVaneP.nc | 56 ---- tos/platforms/tmirws/sensors/MultiSampleC.nc | 54 ---- tos/platforms/tmirws/sensors/MultiSampleP.nc | 88 ------- .../tmirws/sensors/PyranometerAdcC.nc | 61 ----- .../tmirws/sensors/PyranometerAdcP.nc | 67 ----- tos/platforms/tmirws/sensors/WindVane.h | 52 ---- tos/platforms/tmirws/sensors/WindVaneAdcC.nc | 67 ----- tos/platforms/tmirws/sensors/WindVaneAdcP.nc | 71 ------ tos/platforms/tmirws/sensors/WindVaneC.nc | 57 ----- tos/platforms/tmirws/sensors/WindVaneP.nc | 241 ------------------ tos/platforms/tmirws/sensors/WindVaneReadC.nc | 58 ----- tos/platforms/tmirws/sensors/WindVaneReadP.nc | 159 ------------ 35 files changed, 2614 deletions(-) delete mode 100644 tos/platforms/tmirws/sensors/AeroVane.h delete mode 100644 tos/platforms/tmirws/sensors/AeroVaneC.nc delete mode 100644 tos/platforms/tmirws/sensors/AeroVaneP.nc delete mode 100644 tos/platforms/tmirws/sensors/AeroVaneReadC.nc delete mode 100644 tos/platforms/tmirws/sensors/AeroVaneReadP.nc delete mode 100644 tos/platforms/tmirws/sensors/Anemometer.h delete mode 100644 tos/platforms/tmirws/sensors/AnemometerC.nc delete mode 100644 tos/platforms/tmirws/sensors/AnemometerP.nc delete mode 100644 tos/platforms/tmirws/sensors/AnemometerReadC.nc delete mode 100644 tos/platforms/tmirws/sensors/AnemometerReadP.nc delete mode 100644 tos/platforms/tmirws/sensors/Average.nc delete mode 100644 tos/platforms/tmirws/sensors/AverageAngleC.nc delete mode 100644 tos/platforms/tmirws/sensors/AveragePolarC.nc delete mode 100644 tos/platforms/tmirws/sensors/AveragePolarP.nc delete mode 100644 tos/platforms/tmirws/sensors/AverageU16C.nc delete mode 100644 tos/platforms/tmirws/sensors/BatteryAdcC.nc delete mode 100644 tos/platforms/tmirws/sensors/BatteryAdcP.nc delete mode 100644 tos/platforms/tmirws/sensors/HalAnemometerC.nc delete mode 100644 tos/platforms/tmirws/sensors/HalAnemometerP.nc delete mode 100644 tos/platforms/tmirws/sensors/HalOwwVaneC.nc delete mode 100644 tos/platforms/tmirws/sensors/HalOwwVaneP.nc delete mode 100644 tos/platforms/tmirws/sensors/HalWindVaneC.nc delete mode 100644 tos/platforms/tmirws/sensors/HalWindVaneP.nc delete mode 100644 tos/platforms/tmirws/sensors/MultiSampleC.nc delete mode 100644 tos/platforms/tmirws/sensors/MultiSampleP.nc delete mode 100644 tos/platforms/tmirws/sensors/PyranometerAdcC.nc delete mode 100644 tos/platforms/tmirws/sensors/PyranometerAdcP.nc delete mode 100644 tos/platforms/tmirws/sensors/WindVane.h delete mode 100644 tos/platforms/tmirws/sensors/WindVaneAdcC.nc delete mode 100644 tos/platforms/tmirws/sensors/WindVaneAdcP.nc delete mode 100644 tos/platforms/tmirws/sensors/WindVaneC.nc delete mode 100644 tos/platforms/tmirws/sensors/WindVaneP.nc delete mode 100644 tos/platforms/tmirws/sensors/WindVaneReadC.nc delete mode 100644 tos/platforms/tmirws/sensors/WindVaneReadP.nc diff --git a/tos/platforms/tmirws/.platform b/tos/platforms/tmirws/.platform index 74e9bdf2..a9b12e73 100755 --- a/tos/platforms/tmirws/.platform +++ b/tos/platforms/tmirws/.platform @@ -8,7 +8,6 @@ push( @includes, qw( %T/platforms/tmirws/chips/scp1000 %T/platforms/tmirws/chips/sht11 %T/platforms/tmirws/chips/oww - %T/platforms/tmirws/sensors %T/platforms/tmicore %T/platforms/tmicore/chips/bq2403x %T/platforms/tmicore/chips/cp210x diff --git a/tos/platforms/tmirws/sensors/AeroVane.h b/tos/platforms/tmirws/sensors/AeroVane.h deleted file mode 100644 index 9c02b5c3..00000000 --- a/tos/platforms/tmirws/sensors/AeroVane.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Anemometer definitions - * - * @author R. Steve McKown - */ - -#ifndef AEROVANE_H -#define AEROVANE_H - -enum { - AEROVANE_VECTOR_NULL = 65535U, /* Null vector has this value as dir */ -}; - -typedef struct { - uint16_t dir; /* Vane position. 0...1023; 360 degrees = 1024 */ - uint16_t speed; /* Anemometer revolutions over reading period. */ -} aerovector_t; - -typedef struct { - aerovector_t avg; /* average wind vector, taking into acct dir & speed */ - uint8_t ccw; /* most counter-clockwise vane position seen */ - uint8_t cw; /* most clockwise vane position seen */ - uint8_t min; /* minimum speed seen */ - uint8_t max; /* max speed seen */ -} aerovane_t; - -#endif diff --git a/tos/platforms/tmirws/sensors/AeroVaneC.nc b/tos/platforms/tmirws/sensors/AeroVaneC.nc deleted file mode 100644 index 020b1369..00000000 --- a/tos/platforms/tmirws/sensors/AeroVaneC.nc +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Aerovane sensor, measuring wind speed and direction - * - * @author R. Steve McKown - */ - -#include "AeroVane.h" - -configuration AeroVaneC { - provides interface ReadRef; -} -implementation { - components AeroVaneP; - ReadRef = AeroVaneP; - - components SoftwareRtcC as RtcC; - AeroVaneP.Second -> RtcC; - - components HalAeroVaneC; - AeroVaneP.CPSA -> HalAeroVaneC.CPSA; - AeroVaneP.CPSB -> HalAeroVaneC.CPSB; -} diff --git a/tos/platforms/tmirws/sensors/AeroVaneP.nc b/tos/platforms/tmirws/sensors/AeroVaneP.nc deleted file mode 100644 index 7c127267..00000000 --- a/tos/platforms/tmirws/sensors/AeroVaneP.nc +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Aerovane sensor, measuring wind speed and direction - * - * @author R. Steve McKown - */ - -#include "AeroVane.h" - -module AeroVaneP { - provides interface ReadRef; - uses { - interface Tick as Second; - interface AsyncGet as CPSA; - interface AsyncGet as CPSB; - } -} -implementation { - aerovane_t* m_data; - uint8_t minSpeed = 255; - uint8_t maxSpeed; - - - /*** Support functions ***/ - - - /* Convert counts per second to mph */ - uint8_t toMph(uint8_t cps) - { - return 2.25 * cps + 0.5; - } - - - /*** Method implementations ***/ - - - async event void Second.fired() - { - uint8_t speed = call CPSA.get(); - - if (speed < minSpeed) - minSpeed = speed; - if (speed > maxSpeed) - maxSpeed = speed; - } - - task void readSpeed(); - - command error_t ReadRef.read(aerovane_t* data) - { - if (!data) - return EINVAL; - else if (m_data) - return EBUSY; - else { - m_data = data; - post readSpeed(); - return SUCCESS; - } - } - - void signalDone(error_t); - - task void readSpeed() - { - atomic { - m_data->min = toMph(minSpeed); - m_data->avg = toMph(call CPSB.get()); - m_data->max = toMph(maxSpeed); - minSpeed = 255; - maxSpeed = 0; - } - signalDone(SUCCESS); - } - - void signalDone(error_t error) - { - aerovane_t* tmp = m_data; - - m_data = 0; - signal ReadRef.readDone(error, tmp); - } -} diff --git a/tos/platforms/tmirws/sensors/AeroVaneReadC.nc b/tos/platforms/tmirws/sensors/AeroVaneReadC.nc deleted file mode 100644 index 8475bdac..00000000 --- a/tos/platforms/tmirws/sensors/AeroVaneReadC.nc +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Reads the physical sensors and notifies every read period an aerovane average - * vector. - * - * @author R. Steve McKown - */ - -#include "AeroVane.h" - -configuration AeroVaneReadC { - provides interface Notify; -} -implementation { - components new AeroVaneReadP(900); /* 28800 clocks on 32768 Hz crystal */ - Notify = AeroVaneReadP; - - components new TimerMilliC(); - AeroVaneReadP.Timer -> TimerMilliC; - - components WindVaneReadC; - AeroVaneReadP.Read -> WindVaneReadC; - - components AnemometerReadC; - AeroVaneReadP.AnemometerControl -> AnemometerReadC.StdControl; - AeroVaneReadP.Revolutions -> AnemometerReadC; - - components new AverageAngleC(); - AeroVaneReadP.Average -> AverageAngleC; - - components new StateC(); - AeroVaneReadP.State -> StateC; -} diff --git a/tos/platforms/tmirws/sensors/AeroVaneReadP.nc b/tos/platforms/tmirws/sensors/AeroVaneReadP.nc deleted file mode 100644 index 71d04b08..00000000 --- a/tos/platforms/tmirws/sensors/AeroVaneReadP.nc +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Reads the physical sensors and notifies every read period an aerovane average - * vector. - * - * @author R. Steve McKown - */ - -#include "AeroVane.h" - -generic module AeroVaneReadP(uint16_t period) { - provides interface Notify; - uses { - interface Timer; - interface Read; - interface StdControl as AnemometerControl; - interface Get as Revolutions; - interface Average; - interface State; - } -} -implementation { - enum { - S_IDLE, - S_RUN, - - PHYS_PER_READ = 4, /* # of physical reads per reading */ - }; - - uint8_t m_count; - uint16_t m_speed; - - inline void init() - { - m_count = 0; - call Average.reset(); - } - - command error_t Notify.enable() - { - if (call State.requestState(S_RUN) != SUCCESS) - return EBUSY; - - init(); - call AnemometerControl.start(); - /* FIXME: How to get first Timer.fired() synced with top of hour? */ - call Timer.startPeriodic(period); - return SUCCESS; - } - - command error_t Notify.disable() - { - call State.toIdle(); - call Timer.stop(); - call AnemometerControl.stop(); - return SUCCESS; - } - - event void Timer.fired() - { - if (++m_count == PHYS_PER_READ) { - /* Get anemometer revolutions for the period */ - m_speed = call Revolutions.get(); - } - - if (!(call State.isIdle())) { - /* Avoid notifying if the user has disabled */ - call Read.read(); - } - } - - event void Read.readDone(error_t error, uint16_t result) - { - if (error == SUCCESS) - call Average.submit(result); - - if (m_count == PHYS_PER_READ) { - if (call State.isIdle()) { - /* Avoid notifying if the user has disabled */ - init(); - } else { - aerovector_t vector; - - vector.dir = call Average.average(); - vector.speed = m_speed; - init(); - signal Notify.notify(vector); - } - } - } -} diff --git a/tos/platforms/tmirws/sensors/Anemometer.h b/tos/platforms/tmirws/sensors/Anemometer.h deleted file mode 100644 index 936a4445..00000000 --- a/tos/platforms/tmirws/sensors/Anemometer.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Anemometer definitions - * - * @author R. Steve McKown - */ - -#ifndef ANEMOMETER_H -#define ANEMOMETER_H - -typedef struct { - uint8_t min; - uint8_t avg; - uint8_t max; -} anemometer_t; - -#endif diff --git a/tos/platforms/tmirws/sensors/AnemometerC.nc b/tos/platforms/tmirws/sensors/AnemometerC.nc deleted file mode 100644 index b141ca78..00000000 --- a/tos/platforms/tmirws/sensors/AnemometerC.nc +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Anemometer sensor, measuring wind speed - * - * @author R. Steve McKown - */ - -#include "Anemometer.h" - -configuration AnemometerC { - provides interface ReadRef; -} -implementation { - components AnemometerP; - ReadRef = AnemometerP; - - components SoftwareRtcC as RtcC; - AnemometerP.Second -> RtcC; - - components HalAnemometerC; - AnemometerP.CPSA -> HalAnemometerC.CPSA; - AnemometerP.CPSB -> HalAnemometerC.CPSB; -} diff --git a/tos/platforms/tmirws/sensors/AnemometerP.nc b/tos/platforms/tmirws/sensors/AnemometerP.nc deleted file mode 100644 index dfb1bae6..00000000 --- a/tos/platforms/tmirws/sensors/AnemometerP.nc +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Anemometer sensor, measuring wind speed - * - * @author R. Steve McKown - */ - -#include "Anemometer.h" - -module AnemometerP { - provides interface ReadRef; - uses { - interface Tick as Second; - interface AsyncGet as CPSA; - interface AsyncGet as CPSB; - } -} -implementation { - anemometer_t* m_data; - uint8_t minSpeed = 255; - uint8_t maxSpeed; - - - /*** Support functions ***/ - - - /* Convert counts per second to mph */ - uint8_t toMph(uint8_t cps) - { - return 2.25 * cps + 0.5; - } - - - /*** Method implementations ***/ - - - async event void Second.fired() - { - uint8_t speed = call CPSA.get(); - - if (speed < minSpeed) - minSpeed = speed; - if (speed > maxSpeed) - maxSpeed = speed; - } - - task void readSpeed(); - - command error_t ReadRef.read(anemometer_t* data) - { - if (!data) - return EINVAL; - else if (m_data) - return EBUSY; - else { - m_data = data; - post readSpeed(); - return SUCCESS; - } - } - - void signalDone(error_t); - - task void readSpeed() - { - atomic { - m_data->min = toMph(minSpeed); - m_data->avg = toMph(call CPSB.get()); - m_data->max = toMph(maxSpeed); - minSpeed = 255; - maxSpeed = 0; - } - signalDone(SUCCESS); - } - - void signalDone(error_t error) - { - anemometer_t* tmp = m_data; - - m_data = 0; - signal ReadRef.readDone(error, tmp); - } -} diff --git a/tos/platforms/tmirws/sensors/AnemometerReadC.nc b/tos/platforms/tmirws/sensors/AnemometerReadC.nc deleted file mode 100644 index 22e291b2..00000000 --- a/tos/platforms/tmirws/sensors/AnemometerReadC.nc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Returns the number of anemometer revolutions since the last read. - * - * @author R. Steve McKown - */ - -#include "Anemometer.h" - -configuration AnemometerReadC { - provides { - interface StdControl; - interface Get as Revolutions; - } -} -implementation { - components AnemometerReadP; - StdControl = AnemometerReadP; - Revolutions = AnemometerReadP; - - components MainC; - MainC.SoftwareInit -> AnemometerReadP.Init; - - components Msp430CounterMicroC; - AnemometerReadP.SpinCounter -> Msp430CounterMicroC; -} diff --git a/tos/platforms/tmirws/sensors/AnemometerReadP.nc b/tos/platforms/tmirws/sensors/AnemometerReadP.nc deleted file mode 100644 index ef8a5e83..00000000 --- a/tos/platforms/tmirws/sensors/AnemometerReadP.nc +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Returns the number of anemometer revolutions since the last read. - * - * @author R. Steve McKown - */ - -#include "Anemometer.h" - -module AnemometerReadP { - provides { - interface Init; - interface StdControl; - interface Get as Revolutions; - } - uses - interface Counter as SpinCounter; -} -implementation { - uint16_t m_count; - - command error_t Init.init() - { - atomic { - /* Initialize Timer A, clock source is IO pin P1.0. SpinCounter's clock - * is Timer A. - */ - TACTL = 0; - TACTL = TACLR | ID_0 | TASSEL_0; - P1SEL |= 1; - } - return SUCCESS; - } - - command error_t StdControl.start() - { - atomic { - TACTL |= MC_2; - m_count = call SpinCounter.get(); - } - return SUCCESS; - } - - command error_t StdControl.stop() - { - atomic TACTL &= ~(MC1|MC0); - } - - command uint16_t Revolutions.get() - { - atomic { - uint16_t newCount; - uint16_t speed; - - newCount = call SpinCounter.get(); - speed = newCount - m_count; - m_count = newCount; - return speed; - } - } - - async event void SpinCounter.overflow() {} -} diff --git a/tos/platforms/tmirws/sensors/Average.nc b/tos/platforms/tmirws/sensors/Average.nc deleted file mode 100644 index d9ed12c3..00000000 --- a/tos/platforms/tmirws/sensors/Average.nc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * An interface used by averagers. - * - * @author R. Steve McKown - */ - -interface Average { - /* Reset the averager. Any samples submitted since the last average was - * signalled, or all samples submitted if average was not signalled, are - * discarded. - */ - command void reset(); - - /* Submit a value to the averager, to be averaged into the next average. */ - command void submit(val_t value); - - /* Return the number of values submitted since the last - * reset() or average(). - */ - command uint16_t count(); - - /* Ask for the average of the values submitted since the last - * reset() or average(). average() - * also performs a reset(). - */ - command val_t average(); -} diff --git a/tos/platforms/tmirws/sensors/AverageAngleC.nc b/tos/platforms/tmirws/sensors/AverageAngleC.nc deleted file mode 100644 index 65565b2a..00000000 --- a/tos/platforms/tmirws/sensors/AverageAngleC.nc +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Average angles representing positions on a circle. 360 degrees represented - * as a 10 bit unsigned value. - * - * @author R. Steve McKown - */ - -#include "AeroVane.h" /* For AEROVANE_VECTOR_NULL */ - -generic module AverageAngleC() { - provides interface Average; -} -implementation { - uint8_t m_count; - int16_t m_angle; - uint16_t m_lastAngle; - - inline void init() - { - m_count = 0; - m_angle = 0; - } - - command void Average.reset() - { - init(); - } - - int distance(int angle1, int angle2) - { - int d = angle2 - angle1; - - if (d <= -512) - d += 1024; - else if (d > 512) - d -= 1024; - return d; - } - - command void Average.submit(uint16_t angle) - { - if (m_count++ == 0) - m_lastAngle = angle; - else - m_lastAngle += distance(m_lastAngle, angle); - m_angle += m_lastAngle; - } - - command uint16_t Average.average() - { - uint16_t angle; - - if (m_count == 0) - angle = AEROVANE_VECTOR_NULL; - else { - angle = m_angle; - - if (angle > 0) - angle = (angle + (m_count / 2)) / m_count; - else if (angle < 0) { - angle = (angle - (m_count / 2)) / m_count; - while (angle < 0) - angle += 1024; - } - angle &= 0x03ff; /* %= 1024 */ - } - init(); - return angle; - } - - command uint16_t Average.count() - { - return m_count; - } -} diff --git a/tos/platforms/tmirws/sensors/AveragePolarC.nc b/tos/platforms/tmirws/sensors/AveragePolarC.nc deleted file mode 100644 index 982056d0..00000000 --- a/tos/platforms/tmirws/sensors/AveragePolarC.nc +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Average vectors in polar coordinate space. This is not a true vector - * average, but instead creates an resultant polar coordinate that has an - * independent average of theta and magnitude (speed). - * - * @author R. Steve McKown - */ - -#include "AeroVane.h" - -generic configuration AveragePolarC(uint16_t samples) { - provides interface Average; -} -implementation { - components new AveragePolarP(samples) as AverageP; - Average = AverageP; - - components new AverageAngleC(samples); - AverageP.AverageAngle -> AverageAngleC.Average; - - components new AveragePolarC(samples); - AverageP.AverageSpeed -> AverageU16C.Average; -} diff --git a/tos/platforms/tmirws/sensors/AveragePolarP.nc b/tos/platforms/tmirws/sensors/AveragePolarP.nc deleted file mode 100644 index 4031078d..00000000 --- a/tos/platforms/tmirws/sensors/AveragePolarP.nc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Average vectors in polar coordinate space. This is not a true vector - * average, but instead creates an resultant polar coordinate that has an - * independent average of theta and magnitude (speed). - * - * @author R. Steve McKown - */ - -#include "AeroVane.h" - -generic module AveragePolarC(uint16_t samples) { - provides interface Average; - uses { - interface Average as AverageAngle; - interface Average as AverageSpeed; - } -} -implementation { - int m_count; - - command void Average.reset() - { - AverageAngle.init(); - AverageSpeed.init(); - } - - command uint16_t Average.submit(aerovector_t vector) - { - call AverageAngle.submit(vector.dir); - call AverageSpeed.submit(vector.speed); - } - - command aerovector_t Average.average() - { - aerovector_t vector; - - vector.dir = call AverageAngle.average(); - vector.speed = call AverageSpeed.average(); - init(); - return vector; - } - - command uint16_t Average.count() - { - return call AverageAngle.count(); - } -} diff --git a/tos/platforms/tmirws/sensors/AverageU16C.nc b/tos/platforms/tmirws/sensors/AverageU16C.nc deleted file mode 100644 index 08856141..00000000 --- a/tos/platforms/tmirws/sensors/AverageU16C.nc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Average scalar values. - * - * @author R. Steve McKown - */ - -#include "AeroVane.h" - -generic module AverageU16() { - provides interface Average; -} -implementation { - uint16_t m_count; - uint16_t m_value; - - inline void init() - { - m_count = 0; - m_value = 0; - } - - command void Average.reset() - { - init(); - } - - command Average.submit(uint16_t value) - { - m_count++; - m_value += value; - } - - command uint16_t Average.average() - { - uint16_t value = 0; - - if (m_count) { - value = (m_value + (m_count / 2)) / m_count; - init(); - } - return value; - } - - command uint16_t Average.count() - { - return m_count; - } -} diff --git a/tos/platforms/tmirws/sensors/BatteryAdcC.nc b/tos/platforms/tmirws/sensors/BatteryAdcC.nc deleted file mode 100644 index 472f9ec7..00000000 --- a/tos/platforms/tmirws/sensors/BatteryAdcC.nc +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Reads the ADC pin connected to the LiPoly battery. The connection is made - * via a resistor divider where the battery voltage is 3x that read by the ADC. - * Therefore, BattV = ADC / 4096 * 1.5 * 3. - * - * @author R. Steve McKown - */ - -generic configuration BatteryAdcC() { - provides interface Read; - provides interface ReadStream; - - provides interface Resource; - provides interface ReadNow; -} -implementation { - components new AdcReadClientC(); - Read = AdcReadClientC; - - components new AdcReadStreamClientC(); - ReadStream = AdcReadStreamClientC; - - components BatteryAdcP; - AdcReadClientC.AdcConfigure -> BatteryAdcP; - AdcReadStreamClientC.AdcConfigure -> BatteryAdcP; - - components new AdcReadNowClientC(); - Resource = AdcReadNowClientC; - ReadNow = AdcReadNowClientC; - - AdcReadNowClientC.AdcConfigure -> BatteryAdcP; -} diff --git a/tos/platforms/tmirws/sensors/BatteryAdcP.nc b/tos/platforms/tmirws/sensors/BatteryAdcP.nc deleted file mode 100644 index a80362ba..00000000 --- a/tos/platforms/tmirws/sensors/BatteryAdcP.nc +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Battery ADC reading. - * - * @author R. Steve McKown - */ - -#include "Msp430Adc12.h" - -module BatteryAdcP { - provides interface AdcConfigure; -} -implementation { - /* TODO: The internal references are unsable, varying by more than 0.1V and - * jumping around. The external reference of 2.50V seems stable. - */ - const msp430adc12_channel_config_t config = { - inch: INPUT_CHANNEL_A0, -#if 0 /* internal references unstable */ - sref: REFERENCE_VREFplus_AVss, - ref2_5v: REFVOLT_LEVEL_1_5, /* REFVOLT_LEVEL_2_5, */ -#else /* external reference is stable */ - sref: REFERENCE_VeREFplus_AVss, - ref2_5v: REFVOLT_LEVEL_1_5, -#endif -#if 0 /* clock source doesn't seem to affect stability */ - adc12ssel: SHT_SOURCE_ADC12OSC, - adc12div: SHT_CLOCK_DIV_8, -#else - adc12ssel: SHT_SOURCE_ACLK, - adc12div: SHT_CLOCK_DIV_1, -#endif - sht: SAMPLE_HOLD_8_CYCLES, - sampcon_ssel: SAMPCON_SOURCE_ACLK, - sampcon_id: SAMPCON_CLOCK_DIV_1 - }; - - async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration() - { - return &config; - } -} diff --git a/tos/platforms/tmirws/sensors/HalAnemometerC.nc b/tos/platforms/tmirws/sensors/HalAnemometerC.nc deleted file mode 100644 index f5ada625..00000000 --- a/tos/platforms/tmirws/sensors/HalAnemometerC.nc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * HAL layer for the Anemometer sensor. CPSA and CPSB are independent services - * that each provide a counts per second value via its get() command that - * represents the average CPS since the last call to its get() command. The - * first call to CPSx.get() uses the initialization of the HalAnemometerP - * component during MainC.SoftwareInit as the start time for calculating the - * counts per second value. - * - * @author R. Steve McKown - */ - -#include "Anemometer.h" - -configuration HalAnemometerC { - provides interface AsyncGet as CPSA; - provides interface AsyncGet as CPSB; -} -implementation { - components HalAnemometerP; - CPSA = HalAnemometerP.CPSA; - CPSB = HalAnemometerP.CPSB; - - components MainC; - MainC.SoftwareInit -> HalAnemometerP.Init; - - components Counter32khz32C; - HalAnemometerP.TimeCounter -> Counter32khz32C; - - components Msp430CounterMicroC; - HalAnemometerP.SpinCounter -> Msp430CounterMicroC; -} diff --git a/tos/platforms/tmirws/sensors/HalAnemometerP.nc b/tos/platforms/tmirws/sensors/HalAnemometerP.nc deleted file mode 100644 index 89e5928a..00000000 --- a/tos/platforms/tmirws/sensors/HalAnemometerP.nc +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * HAL layer for the Anemometer sensor. - * - * @author R. Steve McKown - */ - -#include "Anemometer.h" - -module HalAnemometerP { - provides { - interface Init; - interface AsyncGet as CPSA; - interface AsyncGet as CPSB; - } - uses { - interface Counter as TimeCounter; - interface Counter as SpinCounter; - } -} -implementation { - uint32_t prevATime; - uint16_t prevASpin; - uint32_t prevBTime; - uint16_t prevBSpin; - - command error_t Init.init() - { - atomic { - /* Initialize Timer A, clock source is io pin P1.0. Timer A provides the - * clock for the SpinCounter component. - */ - TACTL = 0; - TACTL = TACLR | MC_2 | ID_0 | TASSEL_0; - P1SEL |= 1; - } - prevATime = call TimeCounter.get(); - prevASpin = call SpinCounter.get(); - prevBTime = prevATime; - prevBSpin = prevASpin; - return SUCCESS; - } - - async command uint8_t CPSA.get() - { - uint32_t currTime; - uint16_t currSpin; - uint32_t deltaT; - uint8_t cps; - - atomic { - currTime = call TimeCounter.get(); - currSpin = call SpinCounter.get(); - } - deltaT = (currTime - prevATime); - cps = ((uint32_t)(currSpin - prevASpin) * 32768U + (deltaT >> 1)) / deltaT; - prevATime = currTime; - prevASpin = currSpin; - return cps; - } - - async command uint8_t CPSB.get() - { - uint32_t currTime; - uint16_t currSpin; - uint32_t deltaT; - uint8_t cps; - - atomic { - currTime = call TimeCounter.get(); - currSpin = call SpinCounter.get(); - } - deltaT = (currTime - prevBTime); - cps = ((uint32_t)(currSpin - prevBSpin) * 32768U + (deltaT >> 1)) / deltaT; - prevBTime = currTime; - prevBSpin = currSpin; - return cps; - } - - async event void TimeCounter.overflow() {} - async event void SpinCounter.overflow() {} -} diff --git a/tos/platforms/tmirws/sensors/HalOwwVaneC.nc b/tos/platforms/tmirws/sensors/HalOwwVaneC.nc deleted file mode 100644 index a40c2ed8..00000000 --- a/tos/platforms/tmirws/sensors/HalOwwVaneC.nc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * HAL/HPL layers for the OwwVane sensor. - * - * @author R. Steve McKown - */ - -#include "OwwVane.h" - -configuration HalOwwVaneC { - provides interface AsyncGet; -} -implementation { - components HalOwwVaneP; - AsyncGet = HalOwwVaneP; - - components MainC; - MainC.SoftwareInit -> HalOwwVaneP.Init; -} diff --git a/tos/platforms/tmirws/sensors/HalOwwVaneP.nc b/tos/platforms/tmirws/sensors/HalOwwVaneP.nc deleted file mode 100644 index 4b0fa5cf..00000000 --- a/tos/platforms/tmirws/sensors/HalOwwVaneP.nc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * HAL/HPL layers for the OwwVane sensor. - * - * @author R. Steve McKown - */ - -#include "OwwVane.h" - -module HalOwwVaneP { - provides { - interface Init; - interface AsyncGet as Vane; - } -} -implementation { -#define WIND_IN (*TCAST(volatile uint8_t* ONE, P5IN_)) -#define WIND_DIR (*TCAST(volatile uint8_t* ONE, P5DIR_)) -#define WIND_SEL (*TCAST(volatile uint8_t* ONE, P5SEL_)) -#define WIND_REN (*TCAST(volatile uint8_t* ONE, P5REN_)) - - command error_t Init.init() - { - /* Initialize the port providing wind direction information */ - WIND_DIR = 0; - WIND_SEL = 0; - WIND_REN = 0; - return SUCCESS; - } - - async command uint8_t Vane.get() - { - atomic return ~WIND_IN; - } -} diff --git a/tos/platforms/tmirws/sensors/HalWindVaneC.nc b/tos/platforms/tmirws/sensors/HalWindVaneC.nc deleted file mode 100644 index 46508dbf..00000000 --- a/tos/platforms/tmirws/sensors/HalWindVaneC.nc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * HAL layer for the wind vane sensor provides a power control. - * - * @author R. Steve McKown - */ - -configuration HalWindVaneC { - provides { - interface GeneralIO as WPower; - interface GeneralIO as WDead; - } -} -implementation { - components new Msp430GpioC() as WPowerM; - components new Msp430GpioC() as WDeadM; - WPower = WPowerM; - WDead = WDeadM; - - components HplMsp430GeneralIOC; - WPowerM -> HplMsp430GeneralIOC.Port57; - WDeadM -> HplMsp430GeneralIOC.Port56; - - components MainC, HalWindVaneP; - MainC.SoftwareInit -> HalWindVaneP; - HalWindVaneP.WPower -> HplMsp430GeneralIOC.Port57; - HalWindVaneP.WDead -> HplMsp430GeneralIOC.Port56; -} diff --git a/tos/platforms/tmirws/sensors/HalWindVaneP.nc b/tos/platforms/tmirws/sensors/HalWindVaneP.nc deleted file mode 100644 index a0a604f0..00000000 --- a/tos/platforms/tmirws/sensors/HalWindVaneP.nc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * HAL layer for the wind vane sensor provides a power control. - * - * @author R. Steve McKown - */ - -module HalWindVaneP { - provides interface Init; - uses { - interface HplMsp430GeneralIO as WPower; - interface HplMsp430GeneralIO as WDead; - } -} -implementation { - command error_t Init.init() - { - call WPower.makeOutput(); - call WPower.clr(); - call WPower.disableRen(); - - call WDead.makeInput(); - call WDead.set(); - call WDead.disableRen(); - - return SUCCESS; - } -} diff --git a/tos/platforms/tmirws/sensors/MultiSampleC.nc b/tos/platforms/tmirws/sensors/MultiSampleC.nc deleted file mode 100644 index ac9c3c4c..00000000 --- a/tos/platforms/tmirws/sensors/MultiSampleC.nc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * A generic component that multiply samples via the ADC, returning an array - * of ADC results. - * - * @author R. Steve McKown - */ - -#include - -generic configuration MultiSampleC(uint16_t count) { - provides { - interface Get as Count; - interface ReadRef; - } - uses interface AdcConfigure; -} -implementation { - components new MultiSampleP(count); - Count = MultiSampleP; - ReadRef = MultiSampleP; - - components new AdcReadStreamClientC(); - AdcConfigure = AdcReadStreamClientC; - MultiSampleP.ReadStream -> AdcReadStreamClientC; -} diff --git a/tos/platforms/tmirws/sensors/MultiSampleP.nc b/tos/platforms/tmirws/sensors/MultiSampleP.nc deleted file mode 100644 index 79714ad8..00000000 --- a/tos/platforms/tmirws/sensors/MultiSampleP.nc +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * A generic component that multiply samples via the ADC, returning an array - * of ADC results. - * - * @author R. Steve McKown - */ - -generic module MultiSampleP(uint16_t count) @safe() -{ - provides { - interface Get as Count; - interface ReadRef; - } - uses interface ReadStream; -} -implementation -{ - uint16_t* m_array; - - command uint16_t Count.get() - { - return count; - } - - command error_t ReadRef.read(uint16_t* array) - { - if (m_array) - return EBUSY; - - m_array = array; - if (call ReadStream.postBuffer(m_array, count) != SUCCESS || - call ReadStream.read(0) != SUCCESS) { - m_array = NULL; - return FAIL; - } - return SUCCESS; - } - - void signalReadDone(error_t error) - { - uint16_t* tmp = m_array; - - m_array = NULL; - signal ReadRef.readDone(error, tmp); - } - - event void ReadStream.bufferDone(error_t error, uint16_t* buf, - uint16_t _count) - { - /* FIXME: count comes back as zero, so ignore it. Up to 16 reads work. */ - if (error != SUCCESS /*|| _count != count*/) - signalReadDone(FAIL); - } - - event void ReadStream.readDone(error_t error, uint32_t usActualPeriod) - { - signalReadDone(error); - } -} diff --git a/tos/platforms/tmirws/sensors/PyranometerAdcC.nc b/tos/platforms/tmirws/sensors/PyranometerAdcC.nc deleted file mode 100644 index 061c3020..00000000 --- a/tos/platforms/tmirws/sensors/PyranometerAdcC.nc +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Reads the ADC pin connected to the LiPoly battery. The connection is made - * via a resistor divider where the battery voltage is 3x that read by the ADC. - * Therefore, PyranometerV = ADC / 4096 * 1.5 * 3. - * - * @author R. Steve McKown - */ - -generic configuration PyranometerAdcC() { - provides interface Read; - provides interface ReadStream; - - provides interface Resource; - provides interface ReadNow; -} -implementation { - components new AdcReadClientC(); - Read = AdcReadClientC; - - components new AdcReadStreamClientC(); - ReadStream = AdcReadStreamClientC; - - components PyranometerAdcP; - AdcReadClientC.AdcConfigure -> PyranometerAdcP; - AdcReadStreamClientC.AdcConfigure -> PyranometerAdcP; - - components new AdcReadNowClientC(); - Resource = AdcReadNowClientC; - ReadNow = AdcReadNowClientC; - - AdcReadNowClientC.AdcConfigure -> PyranometerAdcP; -} diff --git a/tos/platforms/tmirws/sensors/PyranometerAdcP.nc b/tos/platforms/tmirws/sensors/PyranometerAdcP.nc deleted file mode 100644 index b3e95687..00000000 --- a/tos/platforms/tmirws/sensors/PyranometerAdcP.nc +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Pyranometerery ADC reading. - * - * @author R. Steve McKown - */ - -#include "Msp430Adc12.h" - -module PyranometerAdcP { - provides interface AdcConfigure; -} -implementation { - const msp430adc12_channel_config_t config = { - inch: INPUT_CHANNEL_A3, -#if 0 /* internal references unstable */ - sref: REFERENCE_VREFplus_AVss, - ref2_5v: REFVOLT_LEVEL_1_5, /* REFVOLT_LEVEL_2_5, */ -#else /* external reference is stable */ - sref: REFERENCE_VeREFplus_AVss, - ref2_5v: REFVOLT_LEVEL_1_5, -#endif -#if 0 /* stability affected by clock source? */ - adc12ssel: SHT_SOURCE_ADC12OSC, - adc12div: SHT_CLOCK_DIV_8, -#else - adc12ssel: SHT_SOURCE_ACLK, - adc12div: SHT_CLOCK_DIV_1, -#endif - sht: SAMPLE_HOLD_8_CYCLES, - sampcon_ssel: SAMPCON_SOURCE_ACLK, - sampcon_id: SAMPCON_CLOCK_DIV_1 - }; - - async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration() - { - return &config; - } -} diff --git a/tos/platforms/tmirws/sensors/WindVane.h b/tos/platforms/tmirws/sensors/WindVane.h deleted file mode 100644 index 70c51ef6..00000000 --- a/tos/platforms/tmirws/sensors/WindVane.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Wind Vane (direction) definitions - * - * @author R. Steve McKown - */ - -#ifndef WIND_VANE_H -#define WIND_VANE_H - -#define WINDVANE_OVERFLOW 255 -#define WINDVANE_NO_HEADING 254 - -/* Units are degrees/2, so 90 degrees is 45 units. This allows a full - * circle of degrees to be represented in a single byte. Resolution reduction - * is not a problem, as the OWW's native resolution is 22.5 degrees. - */ -typedef struct { - uint8_t left; - uint8_t avg; - uint8_t right; -} wind_vane_t; - -#endif diff --git a/tos/platforms/tmirws/sensors/WindVaneAdcC.nc b/tos/platforms/tmirws/sensors/WindVaneAdcC.nc deleted file mode 100644 index a659995b..00000000 --- a/tos/platforms/tmirws/sensors/WindVaneAdcC.nc +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Reads the ADC pin connected to the Davis Instruments anemometer. The - * connection is made via a resistor divider. The voltage seen by the ADC - * is related to VREF, the maximum voltage presented to the ADC. - * 0V or VREF means North - * VREF*1/4 means East - * VREF*2/4 means South - * VREF*3/4 means West - * - * We assume a 12-bit ADC, so VREF reads as 4095 and 0V reads as 0. - * - * @author R. Steve McKown - */ - -generic configuration WindVaneAdcC() { - provides interface Read; - provides interface ReadStream; - - provides interface Resource; - provides interface ReadNow; -} -implementation { - components new AdcReadClientC(); - Read = AdcReadClientC; - - components new AdcReadStreamClientC(); - ReadStream = AdcReadStreamClientC; - - components WindVaneAdcP; - AdcReadClientC.AdcConfigure -> WindVaneAdcP; - AdcReadStreamClientC.AdcConfigure -> WindVaneAdcP; - - components new AdcReadNowClientC(); - Resource = AdcReadNowClientC; - ReadNow = AdcReadNowClientC; - - AdcReadNowClientC.AdcConfigure -> WindVaneAdcP; -} diff --git a/tos/platforms/tmirws/sensors/WindVaneAdcP.nc b/tos/platforms/tmirws/sensors/WindVaneAdcP.nc deleted file mode 100644 index 67f019df..00000000 --- a/tos/platforms/tmirws/sensors/WindVaneAdcP.nc +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Reads the ADC pin connected to the Davis Instruments anemometer. The - * connection is made via a resistor divider. The voltage seen by the ADC - * is related to VREF, the maximum voltage presented to the ADC. - * 0V or VREF means North - * VREF*1/4 means East - * VREF*2/4 means South - * VREF*3/4 means West - * - * We assume a 12-bit ADC, so VREF reads as 4095 and 0V reads as 0. - * - * @author R. Steve McKown - */ - -#include "Msp430Adc12.h" - -module WindVaneAdcP { - provides interface AdcConfigure; -} -implementation { - /* We use the external reference because it is probably more accurate (see - * the circuit), and there is no arbitration for the voltage reference. With - * the external reference, we can ReadStream 4 data points in 420 us. Using - * the internal reference, this time increases significantly to over 18 ms. - */ - const msp430adc12_channel_config_t config = { - inch: INPUT_CHANNEL_A2, - sref: REFERENCE_VeREFplus_AVss, - ref2_5v: REFVOLT_LEVEL_1_5, /* doesn't matter since external ref used */ - adc12ssel: SHT_SOURCE_ADC12OSC, - adc12div: SHT_CLOCK_DIV_8, - sht: SAMPLE_HOLD_8_CYCLES, - sampcon_ssel: SAMPCON_SOURCE_ACLK, - sampcon_id: SAMPCON_CLOCK_DIV_1 - }; - - async command const msp430adc12_channel_config_t* - AdcConfigure.getConfiguration() - { - return &config; - } -} diff --git a/tos/platforms/tmirws/sensors/WindVaneC.nc b/tos/platforms/tmirws/sensors/WindVaneC.nc deleted file mode 100644 index b4937fd1..00000000 --- a/tos/platforms/tmirws/sensors/WindVaneC.nc +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * WindVane sensor. The compass is a number of sectors, 0...(sectors - 1). - * Sector zero is North, and sectors/2 is South. Like any compass, the heading - * increases as one traverses the compass clockwise. The number of sectors are - * contrained by the uint8_t data members of wind_vane_t to no more than 255. - * - * @author R. Steve McKown - */ - -#include "WindVane.h" - -generic configuration WindVaneC(uint8_t sectors) { - provides { - interface Get as Sectors; - interface ReadRef; - } -} -implementation { - components new WindVaneP(sectors); - Sectors = WindVaneP; - ReadRef = WindVaneP; - - components SoftwareRtcC as RtcC; - WindVaneP.Second -> RtcC; - - components WindVaneReadC; - WindVaneP.Vane -> WindVaneReadC.Read; -} diff --git a/tos/platforms/tmirws/sensors/WindVaneP.nc b/tos/platforms/tmirws/sensors/WindVaneP.nc deleted file mode 100644 index 8557c8cc..00000000 --- a/tos/platforms/tmirws/sensors/WindVaneP.nc +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * WindVane sensor. The compass is a number of sectors, 0...(sectors - 1). - * Sector zero is North, and sectors/2 is South. Like any compass, the heading - * increases as one traverses the compass clockwise. The number of sectors are - * contrained by the uint8_t data members of wind_vane_t to no more than 255. - * - * @author R. Steve McKown - */ - -#include "WindVane.h" - -generic module WindVaneP(uint8_t sectors) { - provides { - interface Get as Sectors; - interface ReadRef; - } - uses { - interface Read as Vane; - interface Tick as Second; - } -} -implementation { - uint8_t m_compass[sectors]; - bool m_overflow; - wind_vane_t* m_data; - - - /*** Support functions ***/ - - - /* Convert a sector number into a degree heading. We use the degree value - * that is in the center of the sector to represent that sector. For example, - * with 32 sectors, each sector is 11.25 degrees. Sector 4 represents all - * degree headings between 39.375 and 50.624 and is represented on the whole - * the degree heading of 45 degrees. - */ - uint16_t sectorToDegree(uint8_t sector) - { - return (360.0 / sectors) * sector; - } - - /* Convert a degree heading into a sector */ - uint8_t degreeToSector(uint16_t degree) - { - return ((degree * sectors + 180) / 360) % sectors; - } - - /* Return the # of sectors clockwise along the compass from start to end. */ - uint8_t distance(uint8_t start, uint8_t end) - { - return (end > start) ? end - start : (end + sectors) - start; - } - - /* circularly examine compass, starting with pos + 1, for the next compass - * position having a value of zero. - */ - uint8_t nextNonZero(uint8_t* compass, uint8_t pos) - { - do { - pos = (pos + 1) % sectors; - } while (compass[pos] == 0); - return pos; - } - - bool isCompassEmpty(uint8_t* compass) - { - int i; - - for (i = 0; i < sectors; i++) { - if (compass[i]) - break; - } - return (i == sectors) ? TRUE : FALSE; - } - - /* Reduce all compass headings equally until a compass heading has a value - * of zero. - */ - void minimizeCompass(uint8_t* compass) - { - uint8_t min = 255; - int i; - - for (i = 0; i < sectors; i++) { - if (compass[i] < min) - min = compass[i]; - } - if (min > 0) { - for (i = 0; i < sectors; i++) - compass[i] -= min; - } - } - - /* Locate the arc in which the m_compass[] has been constrained, defining - * that arc in m_data's left and right fields. The compass arc is always - * defined clockwise, from left to right. - */ - void findArc(uint8_t* compass) - { - uint8_t begin; - uint8_t save = 255; - uint8_t dist = 0; - - begin = m_data->left = nextNonZero(compass, sectors - 1); - do { - uint8_t d; - - m_data->right = nextNonZero(compass, m_data->left); - d = distance(m_data->left, m_data->right); - if (d > dist) { - dist = d; - save = m_data->left; - } - m_data->left = m_data->right; - } while (m_data->left != begin); - m_data->right = save; - m_data->left = (save + dist) % sectors; - } - - void calcAvg(uint8_t* compass) - { - /* Find the average compass heading */ - uint32_t sum = 0; - uint32_t count = 0; - uint32_t tmp = (m_data->right >= m_data->left) ? m_data->right : - m_data->right + sectors; - int i; - - for (i = m_data->left; i <= tmp; i++) { - uint8_t p = i % sectors; - - sum += compass[p] * i; - count += compass[p]; - } - m_data->avg = ((sum + count - 1) / count) % sectors; - } - - - /*** Method implementations ***/ - - command uint8_t Sectors.get() - { - return sectors; - } - - task void startRead() - { - call Vane.read(); - } - - async event void Second.fired() - { - post startRead(); - } - - event void Vane.readDone(error_t error, uint16_t value) - { - if (error == SUCCESS) { - if (++m_compass[degreeToSector(value)] == 0) - m_overflow = TRUE; - } - } - - task void readCompass(); - - command error_t ReadRef.read(wind_vane_t* data) - { - if (!data) - return EINVAL; - else if (m_data) - return EBUSY; - else { - m_data = data; - post readCompass(); - return SUCCESS; - } - } - - task void readCompass() - { - bool overflow; - uint8_t compass[sectors]; - wind_vane_t* data = m_data; - - atomic { - overflow = m_overflow; - m_overflow = FALSE; - if (!overflow) - memcpy(compass, m_compass, sizeof(m_compass)); - memset(m_compass, 0, sizeof(m_compass)); - } - - if (overflow) - m_data->left = m_data->avg = m_data->right = WINDVANE_OVERFLOW; - else { - minimizeCompass(compass); - if (isCompassEmpty(compass)) { - /* If there were no readings in the compass, or each compass heading has - * a number of readings equal to all other compass headings, we have an - * indeterminate wind direction. - */ - m_data->left = m_data->avg = m_data->right = WINDVANE_NO_HEADING; - } else { - findArc(compass); - calcAvg(compass); - } - - m_data = 0; - signal ReadRef.readDone(SUCCESS, data); - } - } -} diff --git a/tos/platforms/tmirws/sensors/WindVaneReadC.nc b/tos/platforms/tmirws/sensors/WindVaneReadC.nc deleted file mode 100644 index 98c1bfeb..00000000 --- a/tos/platforms/tmirws/sensors/WindVaneReadC.nc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Take an instantaneous reading of the wind vane position as a 10 bit unsigned - * value. - * - * @author R. Steve McKown - */ - -configuration WindVaneReadC { - provides interface Read; -} -implementation { - enum { SAMPLES_PER_READ = 4, }; - - components new WindVaneReadP(SAMPLES_PER_READ); - Read = WindVaneReadP; - - components new MultiSampleC(SAMPLES_PER_READ); - WindVaneReadP.ReadRef -> MultiSampleC; - - components WindVaneAdcP; - MultiSampleC.AdcConfigure -> WindVaneAdcP; - - components HalWindVaneC; - WindVaneReadP.WPower -> HalWindVaneC.WPower; - WindVaneReadP.WDead -> HalWindVaneC.WDead; - - components new StateC(); - WindVaneReadP.State -> StateC; -} diff --git a/tos/platforms/tmirws/sensors/WindVaneReadP.nc b/tos/platforms/tmirws/sensors/WindVaneReadP.nc deleted file mode 100644 index 765668f6..00000000 --- a/tos/platforms/tmirws/sensors/WindVaneReadP.nc +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2008, Titanium Mirror, Inc. - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * Take an instantaneous reading of the wind vane position as a 10 bit unsigned - * value. In this case, the instantaneous reading is 4 very fast 12-bit samples - * plus the possibility of an additional four to deal with the dead band. - * - * @author R. Steve McKown - */ - -generic module WindVaneReadP(uint16_t count) @safe() -{ - provides interface Read; - uses { - interface ReadRef; - interface GeneralIO as WPower; - interface GeneralIO as WDead; - interface State; - } -} -implementation -{ - enum { - S_IDLE = 0, - S_READ, - S_CHECK, - S_OUTPUT, - - /* The wind vane has a dead zone where it returns an ADC value that also - * represents another angular location. Therefore, we implement special - * dead zone checking over a certain range of return values from the - * wind vane, with hardware assistance (WDead). - * - * Note: the wind vane's dead zone is probably 5-10 degrees. We would be - * more accurate if we took the ADC range over 350 or 355 degrees, then - * added 1/2 of the dead zone as an offset. However, without this logic, - * the wind vane appears more than accurate enough. It is less accurate - * within the dead zone, of course, but would be even if we did implement - * the extra logic. - */ - DEAD_BEGIN = 1500 * count, /* About 132 degrees */ - DEAD_END = 2500 * count, /* About 220 degrees */ - DEAD_THRESH = 3618 * count, /* > when checking means in dead zone */ - - /* If we assume the greatest angular velocity of the wind vane is 4 full - * rotations in a second, then in the 460us it takes to read the vane 4 - * times, it could move over 6 degrees. This means that the vane could - * cross into, out of, or over the dead band, causing readings that can - * not be averaged. If we see a delta from min reading to max reading - * suggesting a large enough deflection, we can assume the reading is - * invalid. - */ - MAX_DEFLECT = 1024, /* 90 degrees */ - }; - - uint16_t m_value; - uint16_t m_samples[count]; - - command error_t Read.read() - { - if (!(call State.isIdle())) - return EBUSY; - - call WPower.set(); - if (call ReadRef.read(m_samples) == SUCCESS) { - call State.forceState(S_READ); - return SUCCESS; - } else { - call WPower.clr(); - return FAIL; - } - } - - void signalReadDone(error_t error, uint16_t value) - { - call WDead.makeInput(); - call WPower.clr(); - - call State.toIdle(); - /* Read has returned a value that is count * 12-bit ADC values. Convert - * this to a 10-bit value, with rounding. - */ - value = (value + (count / 2)) / count / 4; - signal Read.readDone(error, value); - } - - bool badReading(uint16_t* result) - { - unsigned i; - uint16_t min = result[0]; - uint16_t max = result[0]; - - for (i = 1; i < count; i++) { - if (result[i] < min) - min = result[i]; - if (result[i] > max) - max = result[i]; - } - return (max - min) > MAX_DEFLECT; - } - - event void ReadRef.readDone(error_t error, uint16_t* result) - { - if (error != SUCCESS || badReading(result)) - signalReadDone(error, 0); - else { - unsigned i; - uint16_t value = result[0]; - - for (i = 1; i < count; i++) - value += result[i]; - - switch (call State.getState()) { - case S_READ: - if (value < DEAD_BEGIN || value > DEAD_END) - signalReadDone(SUCCESS, value); - else { - m_value = value; - call WDead.makeOutput(); - if (call ReadRef.read(m_samples) == SUCCESS) - call State.forceState(S_CHECK); - else - signalReadDone(FAIL, 0); - } - break; - case S_CHECK: - signalReadDone(SUCCESS, (value > DEAD_THRESH) ? 0 : m_value); - break; - } - } - } -} -- 2.39.2