From 7d75b3c1c1dfcfc519fc9ac96d2ff018883fe445 Mon Sep 17 00:00:00 2001 From: smckown Date: Mon, 15 Sep 2008 23:48:51 +0000 Subject: [PATCH] sht11 support for tmirws. Currently uses an open drain adapter that relies on the msp430's internal pull up/down resistors. Some cleanup may be required. --- tos/platforms/tmirws/.platform | 2 + .../tmirws/chips/sht11/HalSensirionSht11C.nc | 62 ++++++++++++ .../tmirws/chips/sht11/HplSensirionSht11C.nc | 81 ++++++++++++++++ .../tmirws/chips/sht11/HplSensirionSht11P.nc | 84 ++++++++++++++++ .../tmirws/chips/sht11/Msp430OpenDrainC.nc | 52 ++++++++++ .../tmirws/chips/sht11/Msp430OpenDrainP.nc | 75 ++++++++++++++ .../tmirws/chips/sht11/OpenDrainC.nc | 51 ++++++++++ .../tmirws/chips/sht11/OpenDrainP.nc | 97 +++++++++++++++++++ .../tmirws/chips/sht11/SensirionSht11C.nc | 68 +++++++++++++ 9 files changed, 572 insertions(+) create mode 100644 tos/platforms/tmirws/chips/sht11/HalSensirionSht11C.nc create mode 100644 tos/platforms/tmirws/chips/sht11/HplSensirionSht11C.nc create mode 100644 tos/platforms/tmirws/chips/sht11/HplSensirionSht11P.nc create mode 100644 tos/platforms/tmirws/chips/sht11/Msp430OpenDrainC.nc create mode 100644 tos/platforms/tmirws/chips/sht11/Msp430OpenDrainP.nc create mode 100644 tos/platforms/tmirws/chips/sht11/OpenDrainC.nc create mode 100644 tos/platforms/tmirws/chips/sht11/OpenDrainP.nc create mode 100644 tos/platforms/tmirws/chips/sht11/SensirionSht11C.nc diff --git a/tos/platforms/tmirws/.platform b/tos/platforms/tmirws/.platform index 9d080149..af2b475f 100755 --- a/tos/platforms/tmirws/.platform +++ b/tos/platforms/tmirws/.platform @@ -6,6 +6,7 @@ push( @includes, qw( %T/platforms/tmirws %T/platforms/tmirws/chips/scp1000 + %T/platforms/tmirws/chips/sht11 %T/platforms/tmicore %T/platforms/tmicore/chips/bq2403x %T/platforms/tmicore/chips/cp210x @@ -20,6 +21,7 @@ push( @includes, qw( %T/chips/bq2403x %T/chips/cp210x %T/chips/scp1000 + %T/chips/sht11 %T/lib/timer %T/lib/serial %T/lib/adc diff --git a/tos/platforms/tmirws/chips/sht11/HalSensirionSht11C.nc b/tos/platforms/tmirws/chips/sht11/HalSensirionSht11C.nc new file mode 100644 index 00000000..d2de3114 --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/HalSensirionSht11C.nc @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2005-2006 Arch Rock Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * - Neither the name of the Arch Rock Corporation 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 + * ARCHED ROCK OR ITS 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 + */ + +/** + * HalSensirionSht11C is an advanced access component for the + * Sensirion SHT11 model humidity and temperature sensor, available on + * the telosb platform. This component provides the SensirionSht11 + * interface, which offers full control over the device. Please + * acquire the Resource before using it. + * + * @author Gilman Tolle + * @version $Revision: 1.4 $ $Date: 2006/12/12 18:23:45 $ + */ + +configuration HalSensirionSht11C { + provides interface Resource[ uint8_t client ]; + provides interface SensirionSht11[ uint8_t client ]; +} +implementation { + components new SensirionSht11LogicP(); + SensirionSht11 = SensirionSht11LogicP; + + components HplSensirionSht11C; + Resource = HplSensirionSht11C.Resource; + SensirionSht11LogicP.DATA -> HplSensirionSht11C.DATA; + SensirionSht11LogicP.CLOCK -> HplSensirionSht11C.SCK; + SensirionSht11LogicP.InterruptDATA -> HplSensirionSht11C.InterruptDATA; + + components new TimerMilliC(); + SensirionSht11LogicP.Timer -> TimerMilliC; + + components LedsC; + SensirionSht11LogicP.Leds -> LedsC; +} diff --git a/tos/platforms/tmirws/chips/sht11/HplSensirionSht11C.nc b/tos/platforms/tmirws/chips/sht11/HplSensirionSht11C.nc new file mode 100644 index 00000000..295cf7ea --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/HplSensirionSht11C.nc @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2005-2006 Arch Rock Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * - Neither the name of the Arch Rock Corporation 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 + * ARCHED ROCK OR ITS 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 + */ + +/** + * HplSensirionSht11C is a low-level component, intended to provide + * the physical resources used by the Sensirion SHT11 sensor on the + * telosb platform so that the chip driver can make use of them. You + * really shouldn't be wiring to this, unless you're writing a new + * Sensirion SHT11 driver. + * + * @author Gilman Tolle + * @version $Revision: 1.6 $ $Date: 2007/02/04 19:56:29 $ + */ + +configuration HplSensirionSht11C { + provides interface Resource[ uint8_t id ]; + provides interface GeneralIO as DATA; + provides interface GeneralIO as SCK; + provides interface GpioInterrupt as InterruptDATA; +} +implementation { + components new Msp430OpenDrainC() as DATAM; + DATA = DATAM; + + components new Msp430GpioC() as SCKM; + SCK = SCKM; + + components HplMsp430GeneralIOC; + DATAM -> HplMsp430GeneralIOC.Port27; + SCKM -> HplMsp430GeneralIOC.Port30; + + components new NoPinC() as PWRM; + components HplSensirionSht11P; + HplSensirionSht11P.PWR -> PWRM; + HplSensirionSht11P.DATA -> DATAM; + HplSensirionSht11P.SCK -> SCKM; + + components new TimerMilliC(); + HplSensirionSht11P.Timer -> TimerMilliC; + + components HplMsp430InterruptC; + components new Msp430InterruptC() as InterruptDATAC; + InterruptDATAC.HplInterrupt -> HplMsp430InterruptC.Port27; + InterruptDATA = InterruptDATAC.Interrupt; + + components new FcfsArbiterC( "Sht11.Resource" ) as Arbiter; + Resource = Arbiter; + + components new SplitControlPowerManagerC(); + SplitControlPowerManagerC.SplitControl -> HplSensirionSht11P; + SplitControlPowerManagerC.ArbiterInfo -> Arbiter.ArbiterInfo; + SplitControlPowerManagerC.ResourceDefaultOwner -> Arbiter.ResourceDefaultOwner; +} diff --git a/tos/platforms/tmirws/chips/sht11/HplSensirionSht11P.nc b/tos/platforms/tmirws/chips/sht11/HplSensirionSht11P.nc new file mode 100644 index 00000000..45b30ec9 --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/HplSensirionSht11P.nc @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2005-2006 Arch Rock Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * - Neither the name of the Arch Rock Corporation 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 + * ARCHED ROCK OR ITS 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 + */ + +#include "Timer.h" + +/** + * HplSensirionSht11P is a low-level component that controls power for + * the Sensirion SHT11 sensor on the telosb platform. + * + * @author Gilman Tolle + * @version $Revision: 1.4 $ $Date: 2006/12/12 18:23:45 $ + */ + +module HplSensirionSht11P { + provides interface SplitControl; + uses interface Timer; + uses interface GeneralIO as PWR; + uses interface GeneralIO as DATA; + uses interface GeneralIO as SCK; +} +implementation { + task void stopTask(); + + command error_t SplitControl.start() { + call PWR.makeOutput(); + call PWR.set(); + call Timer.startOneShot( 11 ); + return SUCCESS; + } + + event void Timer.fired() { + signal SplitControl.startDone( SUCCESS ); + } + + command error_t SplitControl.stop() { +#if 0 + call SCK.makeInput(); + call SCK.clr(); + call DATA.makeInput(); + call DATA.clr(); +#else + call DATA.makeOutput(); + call SCK.clr(); /* remains an output so no floating pin */ + call DATA.makeOutput(); + call DATA.set(); /* set as pulled-up output so we see no interrupts */ +#endif + call PWR.clr(); + post stopTask(); + return SUCCESS; + } + + task void stopTask() { + signal SplitControl.stopDone( SUCCESS ); + } +} + diff --git a/tos/platforms/tmirws/chips/sht11/Msp430OpenDrainC.nc b/tos/platforms/tmirws/chips/sht11/Msp430OpenDrainC.nc new file mode 100644 index 00000000..6484bd73 --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/Msp430OpenDrainC.nc @@ -0,0 +1,52 @@ +/* + * 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 the Technische Universität Berlin nor the names + * of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Implement an open drain output using an HplMsp430GeneralIO, represented as + * a GeneralIO. This component uses the Msp430's internal pull up/down + * capability, present on only some devices. + * + * @author R. Steve McKown + */ + +generic configuration Msp430OpenDrainC() +{ + provides interface GeneralIO; + uses interface HplMsp430GeneralIO as HplGeneralIO; +} +implementation +{ + components new Msp430OpenDrainP(); + GeneralIO = Msp430OpenDrainP; + HplGeneralIO = Msp430OpenDrainP; + + components MainC; + MainC.SoftwareInit -> Msp430OpenDrainP; +} + diff --git a/tos/platforms/tmirws/chips/sht11/Msp430OpenDrainP.nc b/tos/platforms/tmirws/chips/sht11/Msp430OpenDrainP.nc new file mode 100644 index 00000000..228daaba --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/Msp430OpenDrainP.nc @@ -0,0 +1,75 @@ +/* + * 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 the Technische Universität Berlin nor the names + * of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Implement an open drain output using an HplMsp430GeneralIO, represented as + * a GeneralIO. Uses the pull-up resistor built into the msp430 for each io + * pin to deliver the pull-up necessary. set() is pin in input with pull-up, + * clr() is in output with no pull-up. + * + * @author R. Steve McKown + */ + +generic module Msp430OpenDrainP() +{ + provides { + interface Init; + interface GeneralIO; + } + uses interface HplMsp430GeneralIO as HplGeneralIO; +} +implementation +{ + command error_t Init.init() + { + call HplGeneralIO.makeInput(); + call HplGeneralIO.set(); + call HplGeneralIO.enableRen(); /* this is the important bit */ + return SUCCESS; + } + + async command void GeneralIO.set() { call HplGeneralIO.set(); } + async command void GeneralIO.clr() { call HplGeneralIO.clr(); } + async command void GeneralIO.toggle() { call HplGeneralIO.toggle(); } + //async command uint8_t GeneralIO.getOutRaw() { call HplGeneralIO.getOutRaw(); } + //async command bool GeneralIO.getOut() { return call HplGeneralIO.getOut(); } + //async command uint8_t GeneralIO.getRaw() { call HplGeneralIO.getRaw(); } + async command bool GeneralIO.get() { return call HplGeneralIO.get(); } + async command void GeneralIO.makeInput() {} // call HplGeneralIO.makeInput(); } + async command bool GeneralIO.isInput() { return TRUE; } //call HplGeneralIO.isInput(); } + async command void GeneralIO.makeOutput() {} // call HplGeneralIO.makeOutput(); } + async command bool GeneralIO.isOutput() { return TRUE; } //call HplGeneralIO.isOutput(); } + //async command void GeneralIO.selectModuleFunc() { call HplGeneralIO.selectModuleFunc(); } + //async command bool GeneralIO.isModuleFunc() { return call HplGeneralIO.isModuleFunc(); } + //async command void GeneralIO.selectIOFunc() { call HplGeneralIO.selectIOFunc(); } + //async command bool GeneralIO.isIOFunc() { return call HplGeneralIO.isIOFunc(); } + //async command void GeneralIO.enableRen() { call HplGeneralIO.enableRen(); } + //async command void GeneralIO.disableRen() { call HplGeneralIO.disableRen(); } + //async command bool GeneralIO.isRen() { return call HplGeneralIO.isRen(); } +} diff --git a/tos/platforms/tmirws/chips/sht11/OpenDrainC.nc b/tos/platforms/tmirws/chips/sht11/OpenDrainC.nc new file mode 100644 index 00000000..6eba7fef --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/OpenDrainC.nc @@ -0,0 +1,51 @@ +/* + * 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 the Technische Universität Berlin nor the names + * of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Implement an open drain output using a GeneralIO, represented as a + * GeneralIO. Requires an external pull-up for proper operation. + * + * @author R. Steve McKown + */ + +generic configuration OpenDrainC() +{ + provides interface GeneralIO; + uses interface GeneralIO as RawIO; +} +implementation +{ + components new OpenDrainP(); + GeneralIO = OpenDrainP; + RawIO = OpenDrainP; + + components MainC; + MainC.SoftwareInit -> OpenDrainP; +} + diff --git a/tos/platforms/tmirws/chips/sht11/OpenDrainP.nc b/tos/platforms/tmirws/chips/sht11/OpenDrainP.nc new file mode 100644 index 00000000..38df60a1 --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/OpenDrainP.nc @@ -0,0 +1,97 @@ +/* + * 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 the Technische Universität Berlin nor the names + * of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Implement an open drain output using a GeneralIO, represented as a + * GeneralIO. clr() puts the pin in input mode, simulating open drain and + * therefore requiring a pull-up on the net. set() puts the pin in output + * mode and sinks current by outputting a logic zero. By definition, the + * pin wrapped by this component can only be used as an output. + * + * TODO: there could be a version of this component that uses the msp430's + * built-in pull-up resistor... + * + * @author R. Steve McKown + */ + +generic module OpenDrainP() +{ + provides { + interface Init; + interface GeneralIO; + } + uses interface GeneralIO as RawIO; +} +implementation +{ + command error_t Init.init() + { + call RawIO.clr(); + call RawIO.makeInput(); + return SUCCESS; + } + + async command bool GeneralIO.get() + { + return call RawIO.get(); + } + + async command void GeneralIO.set() + { + call RawIO.makeInput(); + } + + async command void GeneralIO.clr() + { + call RawIO.makeOutput(); + } + + async command void GeneralIO.toggle() + { + if (call RawIO.isInput()) + call RawIO.makeOutput(); + else + call RawIO.makeInput(); + } + + async command void GeneralIO.makeInput() {} + + async command void GeneralIO.makeOutput() {} + + async command bool GeneralIO.isInput() + { + return FALSE; + } + + async command bool GeneralIO.isOutput() + { + return TRUE; + } +} + diff --git a/tos/platforms/tmirws/chips/sht11/SensirionSht11C.nc b/tos/platforms/tmirws/chips/sht11/SensirionSht11C.nc new file mode 100644 index 00000000..d12ab24c --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/SensirionSht11C.nc @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2005-2006 Arch Rock Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * - Neither the name of the Arch Rock Corporation 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 + * ARCHED ROCK OR ITS 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 + */ + +/** + * SensirionSht11C is a top-level access component for the Sensirion + * SHT11 model humidity and temperature sensor, available on the + * telosb platform. Because this component represents one physical + * device, simultaneous calls to read temperature and humidity will be + * arbitrated and executed in sequential order. Feel free to read both + * at the same time, just be aware that they'll come back + * sequentially. + * + * @author Gilman Tolle + * @version $Revision: 1.5 $ $Date: 2007/04/13 21:46:18 $ + */ + +generic configuration SensirionSht11C() { + provides interface Read as Temperature; + provides interface DeviceMetadata as TemperatureMetadata; + provides interface Read as Humidity; + provides interface DeviceMetadata as HumidityMetadata; +} +implementation { + components new SensirionSht11ReaderP(); + + Temperature = SensirionSht11ReaderP.Temperature; + TemperatureMetadata = SensirionSht11ReaderP.TemperatureMetadata; + Humidity = SensirionSht11ReaderP.Humidity; + HumidityMetadata = SensirionSht11ReaderP.HumidityMetadata; + + components HalSensirionSht11C; + + enum { TEMP_KEY = unique("Sht11.Resource") }; + enum { HUM_KEY = unique("Sht11.Resource") }; + + SensirionSht11ReaderP.TempResource -> HalSensirionSht11C.Resource[ TEMP_KEY ]; + SensirionSht11ReaderP.Sht11Temp -> HalSensirionSht11C.SensirionSht11[ TEMP_KEY ]; + SensirionSht11ReaderP.HumResource -> HalSensirionSht11C.Resource[ HUM_KEY ]; + SensirionSht11ReaderP.Sht11Hum -> HalSensirionSht11C.SensirionSht11[ HUM_KEY ]; +} -- 2.39.2