From: smckown Date: Thu, 4 Sep 2008 21:51:37 +0000 (+0000) Subject: Initial support for the tmicore platform, an msp430-based board. X-Git-Tag: release/2.1.0-1~89 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=67ea6e597465286a923da75687454a88104bd6ef Initial support for the tmicore platform, an msp430-based board. --- diff --git a/support/make/tmicore.target b/support/make/tmicore.target new file mode 100644 index 00000000..68f69bef --- /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) + +tmicore: $(BUILD_DEPS) + @: diff --git a/tos/platforms/tmicore/.platform b/tos/platforms/tmicore/.platform new file mode 100755 index 00000000..1c870a6b --- /dev/null +++ b/tos/platforms/tmicore/.platform @@ -0,0 +1,57 @@ +# 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/telosa + %T/chips/msp430 + %T/chips/msp430/adc12 + %T/chips/msp430/dma + %T/chips/msp430/pins + %T/chips/msp430/timer + %T/chips/msp430/usart + %T/chips/msp430/sensors + %T/chips/at45db + %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..31e7cc29 --- /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..8060fa78 --- /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..5518a2dc --- /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..7670dd6c --- /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..46da184e --- /dev/null +++ b/tos/platforms/tmicore/MoteClockC.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. + */ + +/** + * 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 + */ + +#define MS430DCOSPEC_H +#define TARGET_DCO_KHZ 8192 // the target DCO clock rate in binary kHz +#define ACLK_KHZ 32 // the ACLK rate in binary kHz + +configuration MoteClockC { + provides interface Init as MoteClockInit; +} +implementation { + components MoteClockP; + MoteClockInit = MoteClockP.Init; + + components Msp430ClockC; + MoteClockP.SubInit -> Msp430ClockC.Init; + //MoteClockP.Msp430ClockInit -> Msp430ClockC; +} diff --git a/tos/platforms/tmicore/MoteClockP.nc b/tos/platforms/tmicore/MoteClockP.nc new file mode 100644 index 00000000..1e141b45 --- /dev/null +++ b/tos/platforms/tmicore/MoteClockP.nc @@ -0,0 +1,61 @@ +/* + * 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 MoteClockP { + provides interface Init; + uses interface Init as SubInit; + +} + +implementation { + command error_t Init.init() + { + if (CALBC1_8MHZ != 0xff || CALDCO_8MHZ != 0xff) { + /* Initialize timers */ + TACTL = TASSEL_2 | TACLR | TAIE; + TAIV = 0; + TBCTL = TBSSEL_1 | TBCLR | TBIE; + TBIV = 0; + + /* Initialize DCO from calibrated data */ + BCSCTL1 = CALBC1_8MHZ; + DCOCTL = CALDCO_8MHZ; + + /* Turn on TimerB, aka the 32KHz clock */ + TBCTL |= MC1; + + return SUCCESS; + } else + return call SubInit.init(); + } +} diff --git a/tos/platforms/tmicore/MotePlatformC.nc b/tos/platforms/tmicore/MotePlatformC.nc new file mode 100644 index 00000000..25622f99 --- /dev/null +++ b/tos/platforms/tmicore/MotePlatformC.nc @@ -0,0 +1,82 @@ +/* + * 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 = 0x3b; /* 0 0 1 1 1 0 1 1 */ + P1DIR = 0x3b; /* 0 0 1 1 1 0 1 1 */ + + /* Port 2: 7:-, 6:-, 5:nBUTTON, 4:nUSB_SUSPEND, 3:-, 2:BSL_RX, 1:nUSBPG, 0:nSOLARPG */ + P2SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P2OUT = 0xc8; /* 1 1 0 0 1 0 0 0 */ + P2DIR = 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 = 0xc7; /* 1 1 0 0 1 1 1 0 */ + P3OUT = 0x7b; /* 0 1 1 1 1 0 1 1 */ + P3DIR = 0x7b; /* 0 1 1 1 1 0 1 1 */ + + /* Port 4: 7:-, 6:nLED2, 5:nLED1, 4:nFLH_CS, 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 = 0xff; /* 1 1 1 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 = 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 */ + + 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..1859d059 --- /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/SwitchToggleC.nc b/tos/platforms/tmicore/SwitchToggleC.nc new file mode 100644 index 00000000..02762e64 --- /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..654e66df --- /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..8b392217 --- /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..bcec89b4 --- /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/hardware.h b/tos/platforms/tmicore/hardware.h new file mode 100755 index 00000000..54f87e17 --- /dev/null +++ b/tos/platforms/tmicore/hardware.h @@ -0,0 +1,34 @@ +#ifndef _H_hardware_h +#define _H_hardware_h + +#include "msp430hardware.h" +//#include "MSP430ADC12.h" +//#include "CC2420Const.h" +//#include "AM.h" + +// LEDs +TOSH_ASSIGN_PIN(nLED1, 4, 5); +TOSH_ASSIGN_PIN(nLED2, 4, 6); + +// UART pins +TOSH_ASSIGN_PIN(UC_SOMI, 3, 2); +TOSH_ASSIGN_PIN(UC_SIMO, 3, 1); +TOSH_ASSIGN_PIN(UC_SCK, 3, 3); +TOSH_ASSIGN_PIN(UC_TX, 3, 6); +TOSH_ASSIGN_PIN(UC_RX, 3, 7); + +// ADC +TOSH_ASSIGN_PIN(ADC_VBATT, 6, 0); + +// FLASH +TOSH_ASSIGN_PIN(nFLH_CS, 4, 4); + +// PROGRAMMING PINS (tri-state) +//TOSH_ASSIGN_PIN(TCK, ); +TOSH_ASSIGN_PIN(PROG_RX, 1, 1); +TOSH_ASSIGN_PIN(PROG_TX, 2, 2); + +// 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