From d891bc488f8ce02ac2ce72f64f8f8a47b7efc460 Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Wed, 2 Dec 2009 15:32:55 -0700 Subject: [PATCH] Add the tmicore and tmirws platforms. --- support/make/tmicore.target | 25 ++++ support/make/tmirws.target | 25 ++++ tos/platforms/tmicore/.platform | 60 +++++++++ tos/platforms/tmicore/DemoSensorC.nc | 57 +++++++++ tos/platforms/tmicore/DemoSensorNowC.nc | 61 ++++++++++ tos/platforms/tmicore/DemoSensorStreamC.nc | 57 +++++++++ tos/platforms/tmicore/HplUserButtonC.nc | 49 ++++++++ tos/platforms/tmicore/MoteClockC.nc | 47 ++++++++ tos/platforms/tmicore/MoteClockP.nc | 73 +++++++++++ tos/platforms/tmicore/MotePlatformC.nc | 101 ++++++++++++++++ tos/platforms/tmicore/PlatformLedsC.nc | 62 ++++++++++ tos/platforms/tmicore/PlatformSerialC.nc | 52 ++++++++ tos/platforms/tmicore/PlatformSerialP.nc | 51 ++++++++ tos/platforms/tmicore/SwitchToggleC.nc | 91 ++++++++++++++ tos/platforms/tmicore/UserButton.h | 39 ++++++ tos/platforms/tmicore/UserButtonC.nc | 52 ++++++++ tos/platforms/tmicore/UserButtonP.nc | 72 +++++++++++ tos/platforms/tmicore/VoltageC.nc | 50 ++++++++ tos/platforms/tmicore/VoltageStreamC.nc | 50 ++++++++ .../tmicore/chips/at25df/At25dfSpiConfigP.nc | 52 ++++++++ .../tmicore/chips/at25df/HplStm25pPinsC.nc | 55 +++++++++ .../tmicore/chips/at25df/HplStm25pSpiC.nc | 55 +++++++++ .../tmicore/chips/at25df/NoMsp430GpioC.nc | 44 +++++++ .../tmicore/chips/bq2403x/BQ2403XPinsC.nc | 85 +++++++++++++ .../tmicore/chips/cp210x/CP210XPinsC.nc | 54 +++++++++ tos/platforms/tmicore/hardware.h | 12 ++ tos/platforms/tmicore/platform.h | 0 tos/platforms/tmirws/.platform | 65 ++++++++++ tos/platforms/tmirws/MotePlatformC.nc | 104 ++++++++++++++++ .../tmirws/chips/scp1000/Scp1000PinsC.nc | 69 +++++++++++ .../tmirws/chips/scp1000/Scp1000PinsP.nc | 114 ++++++++++++++++++ .../tmirws/chips/scp1000/Scp1000SpiC.nc | 51 ++++++++ .../tmirws/chips/scp1000/Scp1000SpiConfigC.nc | 52 ++++++++ .../tmirws/chips/sht11/HalSensirionSht11C.nc | 65 ++++++++++ .../tmirws/chips/sht11/HplSensirionSht11C.nc | 81 +++++++++++++ .../tmirws/chips/sht11/HplSensirionSht11P.nc | 77 ++++++++++++ .../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 +++++++++++ 41 files changed, 2452 insertions(+) create mode 100644 support/make/tmicore.target create mode 100644 support/make/tmirws.target create mode 100644 tos/platforms/tmicore/.platform create mode 100644 tos/platforms/tmicore/DemoSensorC.nc create mode 100644 tos/platforms/tmicore/DemoSensorNowC.nc create mode 100644 tos/platforms/tmicore/DemoSensorStreamC.nc create mode 100644 tos/platforms/tmicore/HplUserButtonC.nc create mode 100644 tos/platforms/tmicore/MoteClockC.nc create mode 100644 tos/platforms/tmicore/MoteClockP.nc create mode 100644 tos/platforms/tmicore/MotePlatformC.nc create mode 100644 tos/platforms/tmicore/PlatformLedsC.nc create mode 100644 tos/platforms/tmicore/PlatformSerialC.nc create mode 100644 tos/platforms/tmicore/PlatformSerialP.nc create mode 100644 tos/platforms/tmicore/SwitchToggleC.nc create mode 100644 tos/platforms/tmicore/UserButton.h create mode 100644 tos/platforms/tmicore/UserButtonC.nc create mode 100644 tos/platforms/tmicore/UserButtonP.nc create mode 100644 tos/platforms/tmicore/VoltageC.nc create mode 100644 tos/platforms/tmicore/VoltageStreamC.nc create mode 100644 tos/platforms/tmicore/chips/at25df/At25dfSpiConfigP.nc create mode 100644 tos/platforms/tmicore/chips/at25df/HplStm25pPinsC.nc create mode 100644 tos/platforms/tmicore/chips/at25df/HplStm25pSpiC.nc create mode 100644 tos/platforms/tmicore/chips/at25df/NoMsp430GpioC.nc create mode 100644 tos/platforms/tmicore/chips/bq2403x/BQ2403XPinsC.nc create mode 100644 tos/platforms/tmicore/chips/cp210x/CP210XPinsC.nc create mode 100644 tos/platforms/tmicore/hardware.h create mode 100644 tos/platforms/tmicore/platform.h create mode 100644 tos/platforms/tmirws/.platform create mode 100644 tos/platforms/tmirws/MotePlatformC.nc create mode 100644 tos/platforms/tmirws/chips/scp1000/Scp1000PinsC.nc create mode 100644 tos/platforms/tmirws/chips/scp1000/Scp1000PinsP.nc create mode 100644 tos/platforms/tmirws/chips/scp1000/Scp1000SpiC.nc create mode 100644 tos/platforms/tmirws/chips/scp1000/Scp1000SpiConfigC.nc 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/support/make/tmicore.target b/support/make/tmicore.target new file mode 100644 index 00000000..680c6e5d --- /dev/null +++ b/support/make/tmicore.target @@ -0,0 +1,25 @@ +#-*-Makefile-*- vim:syntax=make +# tmicore.target + +PLATFORM ?= tmicore + +#MSP_MCU = msp430x2417 + +# Disable MSP430 hardware multiply because it makes MSPGCC die +PFLAGS += -mdisable-hwmul +OPTFLAGS += -O + +MSP_BSL ?= tos-bsl +MSP_BSL_FLAGS = --device=cp2103 + +#VOLUME_FILE = volumes-stm25p.xml +#VOLUME_ALLOCATOR ?= tos-storage-stm25p + +ifdef CC2420_CHANNEL +PFLAGS += -DCC2420_DEF_CHANNEL=$(CC2420_CHANNEL) +endif + +$(call TOSMake_include_platform,msp) + +$(PLATFORM): $(BUILD_DEPS) + @: diff --git a/support/make/tmirws.target b/support/make/tmirws.target new file mode 100644 index 00000000..9e9b57d3 --- /dev/null +++ b/support/make/tmirws.target @@ -0,0 +1,25 @@ +#-*-Makefile-*- vim:syntax=make +# tmirws.target + +PLATFORM ?= tmirws + +#MSP_MCU = msp430x2417 + +# Disable MSP430 hardware multiply because it makes MSPGCC die +PFLAGS += -mdisable-hwmul +OPTFLAGS += -O + +MSP_BSL ?= tos-bsl +MSP_BSL_FLAGS = --device=cp2103 + +#VOLUME_FILE = volumes-stm25p.xml +#VOLUME_ALLOCATOR ?= tos-storage-stm25p + +ifdef CC2420_CHANNEL +PFLAGS += -DCC2420_DEF_CHANNEL=$(CC2420_CHANNEL) +endif + +$(call TOSMake_include_platform,msp) + +$(PLATFORM): $(BUILD_DEPS) + @: diff --git a/tos/platforms/tmicore/.platform b/tos/platforms/tmicore/.platform new file mode 100644 index 00000000..f80694a5 --- /dev/null +++ b/tos/platforms/tmicore/.platform @@ -0,0 +1,60 @@ +# Includes that should take precedence come first. Platforms come before +# chips because they may override files. These must be specified as +# @includes instead of -I's to @opts, otherwise the %T won't be processed +# by ncc. + +push( @includes, qw( + %T/platforms/tmicore + %T/platforms/tmicore/chips/bq2403x + %T/platforms/tmicore/chips/cp210x + %T/platforms/telosa + %T/chips/msp430 + %T/chips/msp430/adc12 + %T/chips/msp430/dma + %T/chips/msp430/pins + %T/chips/msp430/timer + %T/chips/msp430/usci + %T/chips/msp430/sensors + %T/chips/bq2403x + %T/chips/cp210x + %T/lib/timer + %T/lib/serial + %T/lib/adc + %T/lib/power +) ); + +@opts = qw( + -gcc=msp430-gcc + -mmcu=msp430x2417 + -fnesc-target=msp430 + -fnesc-no-debug +); + +push @opts, "-fnesc-scheduler=TinySchedulerC,TinySchedulerC.TaskBasic,TaskBasic,TaskBasic,runTask,postTask" if !$with_scheduler_flag; +push @opts, "-mingw-gcc" if $cygwin; + +$ENV{'CIL_MACHINE'} = + "version_major=3 " . + "version_minor=2 " . + "version=msp430-3.2.3 " . + "short=2,2 " . + "int=2,2 " . + "long=4,2 " . + "long_long=8,2 " . + "pointer=2,2 " . + "enum=2,2 " . + "float=4,2 " . + "double=4,2 " . + "long_double=4,2 " . + "void=1,1 " . + "fun=1,2 " . + "wchar_size_size=2,2 " . + "alignof_string=1 " . + "max_alignment=1 " . + "char_wchar_signed=true,true " . + "const_string_literals=true " . + "big_endian=false " . + "underscore_name=false " . + "__builtin_va_list=true " . + "__thread_is_keyword=true"; + diff --git a/tos/platforms/tmicore/DemoSensorC.nc b/tos/platforms/tmicore/DemoSensorC.nc new file mode 100644 index 00000000..47886257 --- /dev/null +++ b/tos/platforms/tmicore/DemoSensorC.nc @@ -0,0 +1,57 @@ +/* + * 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 + */ + +/** + * DemoSensorC is a generic sensor device that provides a 16-bit + * value. The platform author chooses which sensor actually sits + * behind DemoSensorC, and though it's probably Voltage, Light, or + * Temperature, there are no guarantees. + * + * This particular DemoSensorC on the telosb platform provides a + * voltage reading, using VoltageC. + * + * To convert from ADC counts to actual voltage, divide this reading + * by 4096 and multiply by 3. + * + * @author Gilman Tolle + * @version $Revision: 1.4 $ $Date: 2006/12/12 18:23:45 $ + * + */ + +generic configuration DemoSensorC() +{ + provides interface Read; +} +implementation +{ + components new VoltageC() as DemoSensor; + Read = DemoSensor; +} diff --git a/tos/platforms/tmicore/DemoSensorNowC.nc b/tos/platforms/tmicore/DemoSensorNowC.nc new file mode 100644 index 00000000..da4c4f4e --- /dev/null +++ b/tos/platforms/tmicore/DemoSensorNowC.nc @@ -0,0 +1,61 @@ +/* + * 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 + */ + +/** + * DemoSensorNowC is a generic sensor device that provides a 16-bit + * value that can be read from async context. The platform author + * chooses which sensor actually sits behind DemoSensorNowC, and + * though it's probably Voltage, Light, or Temperature, there are no + * guarantees. + * + * This particular DemoSensorNowC on the telosb platform provides a + * voltage reading, using VoltageC. + * + * To convert from ADC counts to actual voltage, divide this reading + * by 4096 and multiply by 3. + * + * @author Gilman Tolle + * @version $Revision: 1.4 $ $Date: 2006/12/12 18:23:45 $ + * + */ + +generic configuration DemoSensorNowC() +{ + provides interface Resource; + provides interface ReadNow; +} +implementation +{ + components new Msp430InternalVoltageC() as DemoSensorNow; + + Resource = DemoSensorNow; + ReadNow = DemoSensorNow; +} diff --git a/tos/platforms/tmicore/DemoSensorStreamC.nc b/tos/platforms/tmicore/DemoSensorStreamC.nc new file mode 100644 index 00000000..08d40d5d --- /dev/null +++ b/tos/platforms/tmicore/DemoSensorStreamC.nc @@ -0,0 +1,57 @@ +/* + * 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 + */ + +/** + * DemoSensorStreamC is a generic sensor device that provides a 16-bit + * value. The platform author chooses which sensor actually sits + * behind DemoSensorStreamC, and though it's probably Voltage, Light, or + * Temperature, there are no guarantees. + * + * This particular DemoSensorStreamC on the telosb platform provides a + * voltage reading, using VoltageStreamC. + * + * To convert from ADC counts to actual voltage, divide this reading + * by 4096 and multiply by 3. + * + * @author Gilman Tolle + * @version $Revision: 1.4 $ $Date: 2006/12/12 18:23:45 $ + * + */ + +generic configuration DemoSensorStreamC() +{ + provides interface ReadStream; +} +implementation +{ + components new VoltageStreamC() as DemoSensor; + ReadStream = DemoSensor; +} diff --git a/tos/platforms/tmicore/HplUserButtonC.nc b/tos/platforms/tmicore/HplUserButtonC.nc new file mode 100644 index 00000000..9963c605 --- /dev/null +++ b/tos/platforms/tmicore/HplUserButtonC.nc @@ -0,0 +1,49 @@ +/* + * 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. + */ + + /** + * @author R. Steve McKown + */ + +configuration HplUserButtonC { + provides interface GeneralIO; + provides interface GpioInterrupt; +} +implementation { + components HplMsp430GeneralIOC as GeneralIOC; + components HplMsp430InterruptC as InterruptC; + + components new Msp430GpioC() as UserButtonC; + UserButtonC -> GeneralIOC.Port25; + GeneralIO = UserButtonC; + + components new Msp430InterruptC() as InterruptUserButtonC; + InterruptUserButtonC.HplInterrupt -> InterruptC.Port25; + GpioInterrupt = InterruptUserButtonC.Interrupt; +} diff --git a/tos/platforms/tmicore/MoteClockC.nc b/tos/platforms/tmicore/MoteClockC.nc new file mode 100644 index 00000000..46656092 --- /dev/null +++ b/tos/platforms/tmicore/MoteClockC.nc @@ -0,0 +1,47 @@ +/* + * 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. + */ + +/** + * Set the DCO and ACLK specs here, effectively overriding those in + * $TOSDIR/tos/chips/msp430/timer/Msp430DcoSpec.h This is a little hokey. + * I think I'd rather do it using a generic interface. + * + * @author R. Steve McKown + */ + +configuration MoteClockC { + provides interface Init as MoteClockInit; +} +implementation { + components MoteClockP; + MoteClockInit = MoteClockP.Init; + + components new Msp430ClockC(8192, 32); + MoteClockP.SubInit -> Msp430ClockC.Init; +} diff --git a/tos/platforms/tmicore/MoteClockP.nc b/tos/platforms/tmicore/MoteClockP.nc new file mode 100644 index 00000000..a9a97684 --- /dev/null +++ b/tos/platforms/tmicore/MoteClockP.nc @@ -0,0 +1,73 @@ +/* + * 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. + */ + + /** + * @author R. Steve McKown + */ + +#include "Msp430Timer.h" + +module MoteClockP { + provides interface Init; + uses interface Init as SubInit; +} + +implementation { + command error_t Init.init() + { + volatile uint16_t i; + +#if defined (CALDCO_8MHZ_) && !defined(__DisableCalData) + if (CALBC1_8MHZ != 0xff || CALDCO_8MHZ != 0xff) { + /* Use built-in constant */ + atomic { + /* Initialize timers */ + TACTL = TASSEL_2 | TACLR | TAIE; + TAIV = 0; + TBCTL = TBSSEL_1 | TBCLR | TBIE; + TBIV = 0; + + /* Initialize DCO from calibrated data. DCO = 8MHz. SMCLK = DCO/8 */ + BCSCTL1 = CALBC1_8MHZ; + BCSCTL2 = SELM_0 | DIVM_0 | DIVS_3; + DCOCTL = CALDCO_8MHZ; + + /* Turn on timers A and B */ + TACTL |= MC_2; + TBCTL |= MC_2; + } + return SUCCESS; + } +#endif + + /* Calibrate DCOCLK to ACLK when calibration data are disabled or erased */ + for (i = 0; i < 0xfffe; i++); /* ensure LFXT1 is stable */ + return call SubInit.init(); + } +} diff --git a/tos/platforms/tmicore/MotePlatformC.nc b/tos/platforms/tmicore/MotePlatformC.nc new file mode 100644 index 00000000..6882e6e8 --- /dev/null +++ b/tos/platforms/tmicore/MotePlatformC.nc @@ -0,0 +1,101 @@ +/* + * 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. + */ + + /** + * @author R. Steve McKown + */ + +module MotePlatformC @safe() { + provides interface Init; +} +implementation { + command error_t Init.init() { + /* reset all of the ports to be input and using i/o functionality */ + atomic + { +#ifdef __MSP430_HAS_WDT__ + /* Stop the watchdog, if running. Should be somewhere in chips/msp430... */ + WDTCTL = WDTPW + WDTHOLD; +#endif + + /* Port 1: 7:BQSTAT2, 6:BQSTAT1, 5:-, 4:-, 3:CP_CTS, 2:CP_RTS, + * 1:BSL_TX, 0:- + */ + P1SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P1OUT = 0x31; /* 0 0 1 1 0 0 0 1 */ + P1DIR = 0x08; /* 0 0 0 0 1 0 0 0 */ + P1REN = 0x35; /* 0 0 1 1 0 1 0 1 */ + + /* Port 2: + * 7:-, 6:-, 5:BUTTONn, 4:USB_SUSPENDn, 3:-, 2:BSL_RX, 1:USBPGn, + * 0:SOLARPGn + */ + P2SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P2OUT = 0xc8; /* 1 1 0 0 1 0 0 0 */ + P2DIR = 0x00; /* 0 0 0 0 0 0 0 0 */ + P2REN = 0xc8; /* 1 1 0 0 1 0 0 0 */ + + /* Port 3: + * 7:UC_RX, 6:UC_TX, 5:-, 4:-, 3:UC_SCK, 2:UC_SOMI, 1:UC_SIMO, 0:- + */ + P3SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P3OUT = 0x3f; /* 0 0 1 1 1 1 1 1 */ + P3DIR = 0x4a; /* 0 1 0 0 1 0 1 0 */ + P3REN = 0xb5; /* 1 0 1 1 0 1 0 1 */ + + /* Port 4: + * 7:-, 6:LED2n, 5:LED1n, 4:-, 3:-, 2:-, 1:-, 0:- + */ + P4SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P4OUT = 0xff; /* 1 1 1 1 1 1 1 1 */ + P4DIR = 0x60; /* 0 1 1 0 0 0 0 0 */ + P4REN = 0x9f; /* 1 0 0 1 1 1 1 1 */ + + /* Port 5: + * 7:-, 6:-, 5:-, 4:-, 3:-, 2:-, 1:-, 0:- + */ + P5SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P5OUT = 0xff; /* 1 1 1 1 1 1 1 1 */ + P5DIR = 0; /* 0 0 0 0 0 0 0 0 */ + P5REN = 0xff; /* 1 1 1 1 1 1 1 1 */ + + /* Port 6: + * 7:-, 6:-, 5:-, 4:-, 3:-, 2:-, 1:-, 0:ADC_VBATT + */ + P6SEL = 0x01; /* 0 0 0 0 0 0 0 1 */ + P6OUT = 0; /* 0 0 0 0 0 0 0 0 */ + P6DIR = 0; /* 0 0 0 0 0 0 0 0 */ + P6REN = 0xfe; /* 1 1 1 1 1 1 1 0 */ + + P1IE = 0; + P2IE = 0; + } + return SUCCESS; + } +} diff --git a/tos/platforms/tmicore/PlatformLedsC.nc b/tos/platforms/tmicore/PlatformLedsC.nc new file mode 100644 index 00000000..05b78044 --- /dev/null +++ b/tos/platforms/tmicore/PlatformLedsC.nc @@ -0,0 +1,62 @@ +/* + * 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. + */ + + /** + * @author R. Steve McKown + */ + +#include "hardware.h" + +configuration PlatformLedsC { + provides { + interface GeneralIO as Led0; + interface GeneralIO as Led1; + interface GeneralIO as Led2; + } + uses interface Init; +} +implementation +{ + components PlatformP; + Init = PlatformP.LedsInit; + + components HplMsp430GeneralIOC as GeneralIOC; + + components new Msp430GpioC() as Led0Impl; + Led0 = Led0Impl; + Led0Impl -> GeneralIOC.Port45; + + components new Msp430GpioC() as Led1Impl; + Led1 = Led1Impl; + Led1Impl -> GeneralIOC.Port46; + + components new NoPinC() as Led2Impl; + Led2 = Led2Impl; +} + diff --git a/tos/platforms/tmicore/PlatformSerialC.nc b/tos/platforms/tmicore/PlatformSerialC.nc new file mode 100644 index 00000000..28f4354e --- /dev/null +++ b/tos/platforms/tmicore/PlatformSerialC.nc @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2008-2010, 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. + */ + + /** + * @author R. Steve McKown + */ + +configuration PlatformSerialC { + provides interface StdControl; + provides interface UartStream; + provides interface UartByte; +} +implementation { + components new Msp430UartA1C() as UartC; + UartStream = UartC; + UartByte = UartC; + + components PlatformSerialP; + StdControl = PlatformSerialP; + PlatformSerialP.Resource -> UartC; + +#if 0 /* If you want to change the configuration... */ + components SomeConfigurationComponentC as ConfigC; + UartC.AsyncConfigure -> ConfigC; +#endif +} diff --git a/tos/platforms/tmicore/PlatformSerialP.nc b/tos/platforms/tmicore/PlatformSerialP.nc new file mode 100644 index 00000000..ae0fb9f2 --- /dev/null +++ b/tos/platforms/tmicore/PlatformSerialP.nc @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2010, 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. + */ + +/** + * @author R. Steve McKown + */ + +module PlatformSerialP { + provides interface StdControl; + uses interface Resource; +} +implementation { + command error_t StdControl.start() + { + return call Resource.immediateRequest(); + } + + command error_t StdControl.stop() + { + call Resource.release(); + return SUCCESS; + } + + event void Resource.granted() {} +} diff --git a/tos/platforms/tmicore/SwitchToggleC.nc b/tos/platforms/tmicore/SwitchToggleC.nc new file mode 100644 index 00000000..25ef1b9d --- /dev/null +++ b/tos/platforms/tmicore/SwitchToggleC.nc @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2007 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 + */ + +/** + * Generic layer to translate a GIO into a toggle switch + * + * @author Gilman Tolle + * @version $Revision: 1.1 $ + */ + +#include + +generic module SwitchToggleC() { + provides interface Get; + provides interface Notify; + + uses interface GeneralIO; + uses interface GpioInterrupt; +} +implementation { + norace bool m_pinHigh; + + task void sendEvent(); + + command bool Get.get() { return call GeneralIO.get(); } + + command error_t Notify.enable() { + call GeneralIO.makeInput(); + + if ( call GeneralIO.get() ) { + m_pinHigh = TRUE; + return call GpioInterrupt.enableFallingEdge(); + } else { + m_pinHigh = FALSE; + return call GpioInterrupt.enableRisingEdge(); + } + } + + command error_t Notify.disable() { + return call GpioInterrupt.disable(); + } + + async event void GpioInterrupt.fired() { + call GpioInterrupt.disable(); + + m_pinHigh = !m_pinHigh; + + post sendEvent(); + } + + task void sendEvent() { + bool pinHigh; + pinHigh = m_pinHigh; + + signal Notify.notify( pinHigh ); + + if ( pinHigh ) { + call GpioInterrupt.enableFallingEdge(); + } else { + call GpioInterrupt.enableRisingEdge(); + } + } +} diff --git a/tos/platforms/tmicore/UserButton.h b/tos/platforms/tmicore/UserButton.h new file mode 100644 index 00000000..97f124ed --- /dev/null +++ b/tos/platforms/tmicore/UserButton.h @@ -0,0 +1,39 @@ +/* + * 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. + */ + + /** + * @author R. Steve McKown + */ + +#ifndef USERBUTTON_H +#define USERBUTTON_H + +typedef enum { BUTTON_RELEASED = 0, BUTTON_PRESSED = 1 } button_state_t; + +#endif diff --git a/tos/platforms/tmicore/UserButtonC.nc b/tos/platforms/tmicore/UserButtonC.nc new file mode 100644 index 00000000..ff374cec --- /dev/null +++ b/tos/platforms/tmicore/UserButtonC.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. + */ + + /** + * @author R. Steve McKown + */ + +#include + +configuration UserButtonC { + provides interface Get; + provides interface Notify; +} +implementation { + components HplUserButtonC; + components new SwitchToggleC(); + SwitchToggleC.GpioInterrupt -> HplUserButtonC.GpioInterrupt; + SwitchToggleC.GeneralIO -> HplUserButtonC.GeneralIO; + + components UserButtonP; + Get = UserButtonP; + Notify = UserButtonP; + + UserButtonP.GetLower -> SwitchToggleC.Get; + UserButtonP.NotifyLower -> SwitchToggleC.Notify; +} diff --git a/tos/platforms/tmicore/UserButtonP.nc b/tos/platforms/tmicore/UserButtonP.nc new file mode 100644 index 00000000..42e817ef --- /dev/null +++ b/tos/platforms/tmicore/UserButtonP.nc @@ -0,0 +1,72 @@ +/* + * 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. + */ + + /** + * @author R. Steve McKown + */ + +#include + +module UserButtonP { + provides interface Get; + provides interface Notify; + + uses interface Get as GetLower; + uses interface Notify as NotifyLower; +} +implementation { + + command button_state_t Get.get() { + /* tmirws user button pin is high when released - active low */ + if ( call GetLower.get() ) { + return BUTTON_RELEASED; + } else { + return BUTTON_PRESSED; + } + } + + command error_t Notify.enable() { + return call NotifyLower.enable(); + } + + command error_t Notify.disable() { + return call NotifyLower.disable(); + } + + event void NotifyLower.notify( bool val ) { + /* tmirws user button pin is high when released - active low */ + if ( val ) { + signal Notify.notify( BUTTON_RELEASED ); + } else { + signal Notify.notify( BUTTON_PRESSED ); + } + } + + default event void Notify.notify( button_state_t val ) { } +} diff --git a/tos/platforms/tmicore/VoltageC.nc b/tos/platforms/tmicore/VoltageC.nc new file mode 100644 index 00000000..d916c193 --- /dev/null +++ b/tos/platforms/tmicore/VoltageC.nc @@ -0,0 +1,50 @@ +/* + * 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 + */ + +/** + * VoltageC is a common name for the Msp430InternalVoltageC voltage + * sensor available on the telosb platform. + * + * To convert from ADC counts to actual voltage, divide by 4096 and + * multiply by 3. + * + * @author Gilman Tolle + * @version $Revision: 1.4 $ $Date: 2006/12/12 18:23:45 $ + */ + +generic configuration VoltageC() { + provides interface Read; +} +implementation { + components new Msp430InternalVoltageC(); + Read = Msp430InternalVoltageC.Read; +} + diff --git a/tos/platforms/tmicore/VoltageStreamC.nc b/tos/platforms/tmicore/VoltageStreamC.nc new file mode 100644 index 00000000..afbcd6cd --- /dev/null +++ b/tos/platforms/tmicore/VoltageStreamC.nc @@ -0,0 +1,50 @@ +/* + * 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 + */ + +/** + * VoltageC is a common name for the Msp430InternalVoltageC voltage + * sensor available on the telosb platform. + * + * To convert from ADC counts to actual voltage, divide by 4096 and + * multiply by 3. + * + * @author Gilman Tolle + * @version $Revision: 1.4 $ $Date: 2006/12/12 18:23:45 $ + */ + +generic configuration VoltageStreamC() { + provides interface ReadStream; +} +implementation { + components new Msp430InternalVoltageC(); + ReadStream = Msp430InternalVoltageC.ReadStream; +} + diff --git a/tos/platforms/tmicore/chips/at25df/At25dfSpiConfigP.nc b/tos/platforms/tmicore/chips/at25df/At25dfSpiConfigP.nc new file mode 100644 index 00000000..dd7d59bf --- /dev/null +++ b/tos/platforms/tmicore/chips/at25df/At25dfSpiConfigP.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. + */ + +/** + * USCI Spi test program runs the peripheral in loopback mode. + * + * @author R. Steve McKown + */ + +module At25dfSpiConfigP { + provides interface AsyncConfigure as Configure; +} +implementation { + const static msp430_usci_spi_t def = { + ctl0: UCSYNC | UCMODE_0 | UCMST | UCMSB | UCCKPL, /* SPI mode0 master, MSB first */ + ctl1: UCSWRST | UCSSEL_3, /* clock spi from SMCLK */ + brx: 1, + uclisten: FALSE, + ren: USCI_REN_NONE + }; + + async command const msp430_usci_spi_t* Configure.get() + { + return &def; + } +} diff --git a/tos/platforms/tmicore/chips/at25df/HplStm25pPinsC.nc b/tos/platforms/tmicore/chips/at25df/HplStm25pPinsC.nc new file mode 100644 index 00000000..fc3bb412 --- /dev/null +++ b/tos/platforms/tmicore/chips/at25df/HplStm25pPinsC.nc @@ -0,0 +1,55 @@ +/* + * 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 + */ + +/** + * HPL implementation of general-purpose I/O for a ST M25P chip + * connected to a TI MSP430. + * + * @author Jonathan Hui + * @version $Revision: 1.4 $ $Date: 2006/12/12 18:23:45 $ + */ + +configuration HplStm25pPinsC { + provides { + interface GeneralIO as CSN; + interface GeneralIO as Hold; + } +} +implementation { + components new Msp430GpioC() as CSNM; + CSN = CSNM; + + components new NoMsp430GpioC() as HoldM; + Hold = HoldM; + + components HplMsp430GeneralIOC as HplGeneralIOC; + CSNM -> HplGeneralIOC.Port44; +} diff --git a/tos/platforms/tmicore/chips/at25df/HplStm25pSpiC.nc b/tos/platforms/tmicore/chips/at25df/HplStm25pSpiC.nc new file mode 100644 index 00000000..e17579d7 --- /dev/null +++ b/tos/platforms/tmicore/chips/at25df/HplStm25pSpiC.nc @@ -0,0 +1,55 @@ +/* + * 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 + */ + +/** + * HPL implementation of the Spi bus for a ST M25P chip connected to a + * TI MSP430. + * + * @author Jonathan Hui + * @version $Revision: 1.4 $ $Date: 2006/12/12 18:23:45 $ + */ + +configuration HplStm25pSpiC { + provides { + interface Resource; + interface SpiByte; + interface SpiPacket; + } +} +implementation { + components new Msp430SpiB0C(0) as SpiC; + Resource = SpiC; + SpiByte = SpiC; + SpiPacket = SpiC; + + components At25dfSpiConfigP; + SpiC.Configure -> At25dfSpiConfigP; +} diff --git a/tos/platforms/tmicore/chips/at25df/NoMsp430GpioC.nc b/tos/platforms/tmicore/chips/at25df/NoMsp430GpioC.nc new file mode 100644 index 00000000..57b0e25b --- /dev/null +++ b/tos/platforms/tmicore/chips/at25df/NoMsp430GpioC.nc @@ -0,0 +1,44 @@ + +/* "Copyright (c) 2000-2003 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement + * is hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY + * OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + */ + +/** + * A noop version of Msp430GpioC. + * + * @author Joe Polastre + * @see Please refer to TEP 117 for more information about this component and its + * intended use. + */ + +generic module NoMsp430GpioC() @safe() { + provides interface GeneralIO; +} +implementation { + + async command void GeneralIO.set() {} + async command void GeneralIO.clr() {} + async command void GeneralIO.toggle() {} + async command bool GeneralIO.get() { return FALSE; } + async command void GeneralIO.makeInput() {} + async command bool GeneralIO.isInput() { return TRUE; } + async command void GeneralIO.makeOutput() {} + async command bool GeneralIO.isOutput() { return FALSE; } + +} diff --git a/tos/platforms/tmicore/chips/bq2403x/BQ2403XPinsC.nc b/tos/platforms/tmicore/chips/bq2403x/BQ2403XPinsC.nc new file mode 100644 index 00000000..23cd6982 --- /dev/null +++ b/tos/platforms/tmicore/chips/bq2403x/BQ2403XPinsC.nc @@ -0,0 +1,85 @@ +/* + * 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. + */ + +/** + * Pin assignments for the bq24032 on the tmicore. + * + * @author R. Steve McKown + */ + +configuration BQ2403XPinsC { + provides { + interface GeneralIO as BQstat1; + interface GeneralIO as BQstat2; + interface GeneralIO as ACPGn; + interface GeneralIO as USBPGn; + + interface GpioInterrupt as IntBQstat1; + interface GpioInterrupt as IntBQstat2; + interface GpioInterrupt as IntACPGn; + interface GpioInterrupt as IntUSBPGn; + } +} +implementation { + components new Msp430GpioC() as BQstat1C; + BQstat1 = BQstat1C; + + components new Msp430GpioC() as BQstat2C; + BQstat2 = BQstat2C; + + components new Msp430GpioC() as ACPGnC; + ACPGn = ACPGnC; + + components new Msp430GpioC() as USBPGnC; + USBPGn = USBPGnC; + + components new Msp430InterruptC() as IntBQstat1C; + IntBQstat1 = IntBQstat1C; + + components new Msp430InterruptC() as IntBQstat2C; + IntBQstat2 = IntBQstat2C; + + components new Msp430InterruptC() as IntACPGnC; + IntACPGn = IntACPGnC; + + components new Msp430InterruptC() as IntUSBPGnC; + IntUSBPGn = IntUSBPGnC; + + components HplMsp430GeneralIOC as IOC; + BQstat1C.HplGeneralIO -> IOC.Port16; + BQstat2C.HplGeneralIO -> IOC.Port17; + ACPGnC.HplGeneralIO -> IOC.Port20; + USBPGnC.HplGeneralIO -> IOC.Port21; + + components HplMsp430InterruptC as IntC; + IntBQstat1C.HplInterrupt -> IntC.Port16; + IntBQstat2C.HplInterrupt -> IntC.Port17; + IntACPGnC.HplInterrupt -> IntC.Port20; + IntUSBPGnC.HplInterrupt -> IntC.Port21; +} diff --git a/tos/platforms/tmicore/chips/cp210x/CP210XPinsC.nc b/tos/platforms/tmicore/chips/cp210x/CP210XPinsC.nc new file mode 100644 index 00000000..e4a4b2f7 --- /dev/null +++ b/tos/platforms/tmicore/chips/cp210x/CP210XPinsC.nc @@ -0,0 +1,54 @@ +/* + * 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. + */ + +/** + * Pin assignments for the cp2103 on the tmicore. + * + * @author R. Steve McKown + */ + +configuration CP210XPinsC { + provides { + interface GeneralIO as USB_SUSPENDn; + interface GpioInterrupt as IntUSB_SUSPENDn; + } +} +implementation { + components new Msp430GpioC() as USB_SUSPENDnC; + USB_SUSPENDn = USB_SUSPENDnC; + + components new Msp430InterruptC() as IntUSB_SUSPENDnC; + IntUSB_SUSPENDn = IntUSB_SUSPENDnC; + + components HplMsp430GeneralIOC as IOC; + USB_SUSPENDnC.HplGeneralIO -> IOC.Port24; + + components HplMsp430InterruptC as IntC; + IntUSB_SUSPENDnC.HplInterrupt -> IntC.Port24; +} diff --git a/tos/platforms/tmicore/hardware.h b/tos/platforms/tmicore/hardware.h new file mode 100644 index 00000000..c556ef08 --- /dev/null +++ b/tos/platforms/tmicore/hardware.h @@ -0,0 +1,12 @@ +#ifndef _H_hardware_h +#define _H_hardware_h + +#include "msp430hardware.h" +//#include "MSP430ADC12.h" +//#include "CC2420Const.h" +//#include "AM.h" + +// need to undef atomic inside header files or nesC ignores the directive +#undef atomic + +#endif // _H_hardware_h diff --git a/tos/platforms/tmicore/platform.h b/tos/platforms/tmicore/platform.h new file mode 100644 index 00000000..e69de29b diff --git a/tos/platforms/tmirws/.platform b/tos/platforms/tmirws/.platform new file mode 100644 index 00000000..af2b475f --- /dev/null +++ b/tos/platforms/tmirws/.platform @@ -0,0 +1,65 @@ +# Includes that should take precedence come first. Platforms come before +# chips because they may override files. These must be specified as +# @includes instead of -I's to @opts, otherwise the %T won't be processed +# by ncc. + +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 + %T/platforms/telosa + %T/chips/msp430 + %T/chips/msp430/adc12 + %T/chips/msp430/dma + %T/chips/msp430/pins + %T/chips/msp430/timer + %T/chips/msp430/usci + %T/chips/msp430/sensors + %T/chips/bq2403x + %T/chips/cp210x + %T/chips/scp1000 + %T/chips/sht11 + %T/lib/timer + %T/lib/serial + %T/lib/adc + %T/lib/power +) ); + +@opts = qw( + -gcc=msp430-gcc + -mmcu=msp430x2417 + -fnesc-target=msp430 + -fnesc-no-debug +); + +push @opts, "-fnesc-scheduler=TinySchedulerC,TinySchedulerC.TaskBasic,TaskBasic,TaskBasic,runTask,postTask" if !$with_scheduler_flag; +push @opts, "-mingw-gcc" if $cygwin; + +$ENV{'CIL_MACHINE'} = + "version_major=3 " . + "version_minor=2 " . + "version=msp430-3.2.3 " . + "short=2,2 " . + "int=2,2 " . + "long=4,2 " . + "long_long=8,2 " . + "pointer=2,2 " . + "enum=2,2 " . + "float=4,2 " . + "double=4,2 " . + "long_double=4,2 " . + "void=1,1 " . + "fun=1,2 " . + "wchar_size_size=2,2 " . + "alignof_string=1 " . + "max_alignment=1 " . + "char_wchar_signed=true,true " . + "const_string_literals=true " . + "big_endian=false " . + "underscore_name=false " . + "__builtin_va_list=true " . + "__thread_is_keyword=true"; + diff --git a/tos/platforms/tmirws/MotePlatformC.nc b/tos/platforms/tmirws/MotePlatformC.nc new file mode 100644 index 00000000..ade28aa4 --- /dev/null +++ b/tos/platforms/tmirws/MotePlatformC.nc @@ -0,0 +1,104 @@ +/* + * 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. + */ + + /** + * @author R. Steve McKown + */ + +module MotePlatformC @safe() { + provides interface Init; +} +implementation { + command error_t Init.init() { + /* reset all of the ports to be input and using i/o functionality */ + atomic + { +#ifdef __MSP430_HAS_WDT__ + /* Stop the watchdog, if running. Should be somewhere in chips/msp430... */ + WDTCTL = WDTPW + WDTHOLD; +#endif + + /* Port 1: 7:BQSTAT2, 6:BQSTAT1, 5:RAIN, 4:-, 3:CP_CTS, 2:CP_RTS, + * 1:BSL_TX, 0:WSPEED + */ + P1SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P1OUT = 0x10; /* 0 0 0 1 0 0 0 0 */ + P1DIR = 0x08; /* 0 0 0 0 1 0 0 0 */ + P1REN = 0x14; /* 0 0 0 1 0 1 0 0 */ + + /* Port 2: + * 7:SHT_DATA, 6:SCP_DRDY, 5:BUTTONn, 4:USB_SUSPENDn, 3:GM_PWRMON, + * 2:BSL_RX, 1:USBPGn, 0:SOLARPGn + */ + P2SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P2OUT = 0x88; /* 1 0 0 0 1 0 0 0 */ + P2DIR = 0x00; /* 0 0 0 0 0 0 0 0 */ + P2REN = 0x88; /* 1 0 0 0 1 0 0 0 */ + + /* Port 3: + * 7:UC_RX, 6:UC_TX, 5:GM_RXD, 4:GM_TXD, 3:UC_SCK, 2:UC_SOMI, 1:UC_SIMO, + * 0:SHT_SCK + */ + P3SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P3OUT = 0x3f; /* 0 0 1 1 1 1 1 1 */ + P3DIR = 0x4b; /* 0 1 0 0 1 0 1 1 */ + P3REN = 0xb4; /* 1 0 1 1 0 1 0 0 */ + + /* Port 4: + * 7:GM_RTS, 6:LED2n, 5:LED1n, 4:FLH_CSn, 3:SCP_CSn, 2:SCP_PD, 1:GM_ONn, + * 0:GM_VGM_EN + */ + P4SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P4OUT = 0xfe; /* 1 1 1 1 1 1 1 0 */ + P4DIR = 0x7c; /* 0 1 1 1 1 1 0 0 */ + P4REN = 0x83; /* 1 0 0 0 0 0 1 1 */ + + /* Port 5: + * 7:WPOWER, 6:WDEAD, 5:-, 4:-, 3:-, 2:-, 1:-, 0:- + */ + P5SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P5OUT = 0x3f; /* 0 0 1 1 1 1 1 1 */ + P5DIR = 0x80; /* 1 0 0 0 0 0 0 0 */ + P5REN = 0x3f; /* 0 0 1 1 1 1 1 1 */ + + /* Port 6: + * 7:TEMP_PWR, 6:TEMP3, 5:TEMP2, 4:TEMP1, 3:PHOTO, 2:ADC_WIND, 1:-, + * 0:ADC_VBATT + */ + P6SEL = 0x7d; /* 0 1 1 1 1 1 0 1 */ + P6OUT = 0; /* 0 0 0 0 0 0 0 0 */ + P6DIR = 0x80; /* 1 0 0 0 0 0 0 0 */ + P6REN = 0x02; /* 0 0 0 0 0 0 1 0 */ + + P1IE = 0; + P2IE = 0; + } + return SUCCESS; + } +} diff --git a/tos/platforms/tmirws/chips/scp1000/Scp1000PinsC.nc b/tos/platforms/tmirws/chips/scp1000/Scp1000PinsC.nc new file mode 100644 index 00000000..525955e9 --- /dev/null +++ b/tos/platforms/tmirws/chips/scp1000/Scp1000PinsC.nc @@ -0,0 +1,69 @@ +/* + * 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. + */ + +/** + * Platform specific pin mapping for the Scp1000. + * + * @author R. Steve McKown + */ + +configuration Scp1000PinsC { + provides { + interface GeneralIO as CSn; + interface GeneralIO as PD; + interface GeneralIO as DRDY; + interface GpioInterrupt as IntDRDY; + } +} +implementation { + components new Msp430GpioC() as CSn_; + CSn = CSn_.GeneralIO; + + components new Msp430GpioC() as DRDY_; + DRDY = DRDY_.GeneralIO; + + components new Msp430InterruptC() as IntDRDY_; + IntDRDY = IntDRDY_.Interrupt; + + components HplMsp430GeneralIOC as IOC; + CSn_.HplGeneralIO -> IOC.Port43; + DRDY_.HplGeneralIO -> IOC.Port26; + + components HplMsp430InterruptC as IntC; + IntDRDY_.HplInterrupt -> IntC.Port26; + + components new Scp1000PinsP() as PinsP; + PD = PinsP.PD; + PinsP.CSn -> IOC.Port43; + PinsP._PD -> IOC.Port42; + PinsP.DRDY -> IOC.Port26; + + components MainC; + MainC.SoftwareInit -> PinsP; +} diff --git a/tos/platforms/tmirws/chips/scp1000/Scp1000PinsP.nc b/tos/platforms/tmirws/chips/scp1000/Scp1000PinsP.nc new file mode 100644 index 00000000..7fc01fa6 --- /dev/null +++ b/tos/platforms/tmirws/chips/scp1000/Scp1000PinsP.nc @@ -0,0 +1,114 @@ +/* + * 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. + */ + +/** + * Platform dependent scp1000 pin initialization. + * + * @author R. Steve McKown + */ + +#include "Scp1000.h" + +generic module Scp1000PinsP() @safe() +{ + provides { + interface Init; + interface GeneralIO as PD; + } + uses { + interface HplMsp430GeneralIO as CSn; + interface HplMsp430GeneralIO as _PD; + interface HplMsp430GeneralIO as DRDY; + } +} +implementation +{ + command error_t Init.init() + { + call CSn.selectIOFunc(); + call CSn.disableRen(); + call CSn.set(); + call CSn.makeOutput(); + call _PD.selectIOFunc(); + call _PD.disableRen(); + call _PD.set(); + call _PD.makeOutput(); + call DRDY.selectIOFunc(); + call DRDY.enableRen(); + call DRDY.makeInput(); + return SUCCESS; + } + + async command void PD.set() + { + /* When we turn off the device we need to enable the pull-up so the pin + * doesn't float and cause unwanted current consumption. + */ + call DRDY.enableRen(); + call _PD.set(); + } + + async command void PD.clr() + { + /* When the device is powered up, we no longer need the pull-up. This is + * a little bit pedantic, as the unit won't be on that long, but having + * the pull-up on does increase power consumption while DRDY is low during + * the process of taking a reading. On the order of 2.5/35K = 71uA. + */ + call _PD.clr(); + call DRDY.disableRen(); + } + + async command void PD.toggle() + { + } + + async command bool PD.get() + { + return call _PD.get(); + } + + async command void PD.makeInput() + { + } + + async command bool PD.isInput() + { + return FALSE; + } + + async command void PD.makeOutput() + { + } + + async command bool PD.isOutput() + { + return TRUE; + } +} diff --git a/tos/platforms/tmirws/chips/scp1000/Scp1000SpiC.nc b/tos/platforms/tmirws/chips/scp1000/Scp1000SpiC.nc new file mode 100644 index 00000000..5a220df6 --- /dev/null +++ b/tos/platforms/tmirws/chips/scp1000/Scp1000SpiC.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. + */ + +/** + * Platform dependent SPI mapping for Scp1000. + * + * @author R. Steve McKown + */ + +configuration Scp1000SpiC { + provides { + interface Resource; + interface SpiByte; + interface SpiPacket; + } +} +implementation { + components new Msp430SpiB0C(0) as SpiC; + Resource = SpiC; + SpiByte = SpiC; + SpiPacket = SpiC; + + components Scp1000SpiConfigC; + SpiC.Configure -> Scp1000SpiConfigC; +} diff --git a/tos/platforms/tmirws/chips/scp1000/Scp1000SpiConfigC.nc b/tos/platforms/tmirws/chips/scp1000/Scp1000SpiConfigC.nc new file mode 100644 index 00000000..91314a6e --- /dev/null +++ b/tos/platforms/tmirws/chips/scp1000/Scp1000SpiConfigC.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. + */ + +/** + * SPI configuration for Scp1000. + * + * @author R. Steve McKown + */ + +module Scp1000SpiConfigC { + provides interface AsyncConfigure as Configure; +} +implementation { + const static msp430_usci_spi_t def = { + ctl0: UCSYNC | UCMODE_0 | UCMST | UCMSB | UCCKPL, /* SPI mode0 master, MSB first */ + ctl1: UCSWRST | UCSSEL_3, /* clock spi from SMCLK */ + brx: 2, /* part says max 500KHz; this is 524288Hz */ + uclisten: FALSE, + ren: USCI_REN_NONE + }; + + async command const msp430_usci_spi_t* Configure.get() + { + return &def; + } +} diff --git a/tos/platforms/tmirws/chips/sht11/HalSensirionSht11C.nc b/tos/platforms/tmirws/chips/sht11/HalSensirionSht11C.nc new file mode 100644 index 00000000..60a96c6f --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/HalSensirionSht11C.nc @@ -0,0 +1,65 @@ +/* + * 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 SensirionBusyWaitC; + SensirionSht11LogicP.BusyWait -> SensirionBusyWaitC; + + 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..cb715145 --- /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..47b7569e --- /dev/null +++ b/tos/platforms/tmirws/chips/sht11/HplSensirionSht11P.nc @@ -0,0 +1,77 @@ +/* + * 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() { + call SCK.makeOutput(); + call SCK.clr(); + call DATA.makeInput(); + call DATA.set(); + 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..177a0406 --- /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..d34be3d9 --- /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..e89e26f3 --- /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..9cc22462 --- /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