From 245d1ab65b4b068764b60fefdc7f1978851f1e7c Mon Sep 17 00:00:00 2001 From: "R. Steve McKown" Date: Thu, 4 Mar 2010 13:37:26 -0700 Subject: [PATCH] Olimex P169 platform. --- support/make/olimexp169.target | 26 ++++++ tos/platforms/olimexp169/.platform | 56 ++++++++++++ tos/platforms/olimexp169/DemoSensorC.nc | 57 ++++++++++++ tos/platforms/olimexp169/DemoSensorNowC.nc | 61 +++++++++++++ tos/platforms/olimexp169/DemoSensorStreamC.nc | 57 ++++++++++++ tos/platforms/olimexp169/HplUserButtonC.nc | 49 ++++++++++ tos/platforms/olimexp169/MoteClockC.nc | 40 ++++++++ tos/platforms/olimexp169/MotePlatformC.nc | 82 +++++++++++++++++ tos/platforms/olimexp169/PlatformLedsC.nc | 59 ++++++++++++ tos/platforms/olimexp169/PlatformSerialC.nc | 21 +++++ tos/platforms/olimexp169/PlatformSerialP.nc | 51 +++++++++++ tos/platforms/olimexp169/SwitchToggleC.nc | 91 +++++++++++++++++++ tos/platforms/olimexp169/UserButton.h | 39 ++++++++ tos/platforms/olimexp169/UserButtonC.nc | 52 +++++++++++ tos/platforms/olimexp169/UserButtonP.nc | 72 +++++++++++++++ tos/platforms/olimexp169/VoltageC.nc | 50 ++++++++++ tos/platforms/olimexp169/VoltageStreamC.nc | 50 ++++++++++ tos/platforms/olimexp169/hardware.h | 12 +++ tos/platforms/olimexp169/platform.h | 0 19 files changed, 925 insertions(+) create mode 100644 support/make/olimexp169.target create mode 100644 tos/platforms/olimexp169/.platform create mode 100644 tos/platforms/olimexp169/DemoSensorC.nc create mode 100644 tos/platforms/olimexp169/DemoSensorNowC.nc create mode 100644 tos/platforms/olimexp169/DemoSensorStreamC.nc create mode 100644 tos/platforms/olimexp169/HplUserButtonC.nc create mode 100644 tos/platforms/olimexp169/MoteClockC.nc create mode 100644 tos/platforms/olimexp169/MotePlatformC.nc create mode 100644 tos/platforms/olimexp169/PlatformLedsC.nc create mode 100644 tos/platforms/olimexp169/PlatformSerialC.nc create mode 100644 tos/platforms/olimexp169/PlatformSerialP.nc create mode 100644 tos/platforms/olimexp169/SwitchToggleC.nc create mode 100644 tos/platforms/olimexp169/UserButton.h create mode 100644 tos/platforms/olimexp169/UserButtonC.nc create mode 100644 tos/platforms/olimexp169/UserButtonP.nc create mode 100644 tos/platforms/olimexp169/VoltageC.nc create mode 100644 tos/platforms/olimexp169/VoltageStreamC.nc create mode 100644 tos/platforms/olimexp169/hardware.h create mode 100644 tos/platforms/olimexp169/platform.h diff --git a/support/make/olimexp169.target b/support/make/olimexp169.target new file mode 100644 index 00000000..a2759ab0 --- /dev/null +++ b/support/make/olimexp169.target @@ -0,0 +1,26 @@ +#-*-Makefile-*- vim:syntax=make +# olimexp169.target + +PLATFORM ?= olimexp169 + +#MSP_MCU = msp430x169 + +# Disable MSP430 hardware multiply because it makes MSPGCC die +PFLAGS += -mdisable-hwmul +OPTFLAGS += -O + +# Olimex P169 doesn't support bsl +MSP_BSL ?= false +MSP_BSL_FLAGS = --device=none + +#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/olimexp169/.platform b/tos/platforms/olimexp169/.platform new file mode 100644 index 00000000..7c9db3b8 --- /dev/null +++ b/tos/platforms/olimexp169/.platform @@ -0,0 +1,56 @@ +# 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/olimexp168 + %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/lib/timer + %T/lib/serial + %T/lib/adc + %T/lib/power +) ); + +@opts = qw( + -gcc=msp430-gcc + -mmcu=msp430x169 + -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/olimexp169/DemoSensorC.nc b/tos/platforms/olimexp169/DemoSensorC.nc new file mode 100644 index 00000000..47886257 --- /dev/null +++ b/tos/platforms/olimexp169/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/olimexp169/DemoSensorNowC.nc b/tos/platforms/olimexp169/DemoSensorNowC.nc new file mode 100644 index 00000000..da4c4f4e --- /dev/null +++ b/tos/platforms/olimexp169/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/olimexp169/DemoSensorStreamC.nc b/tos/platforms/olimexp169/DemoSensorStreamC.nc new file mode 100644 index 00000000..08d40d5d --- /dev/null +++ b/tos/platforms/olimexp169/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/olimexp169/HplUserButtonC.nc b/tos/platforms/olimexp169/HplUserButtonC.nc new file mode 100644 index 00000000..56d6a7ce --- /dev/null +++ b/tos/platforms/olimexp169/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.Port61; + GeneralIO = UserButtonC; + + components new Msp430InterruptC() as InterruptUserButtonC; + InterruptUserButtonC.HplInterrupt -> InterruptC.Port61; + GpioInterrupt = InterruptUserButtonC.Interrupt; +} diff --git a/tos/platforms/olimexp169/MoteClockC.nc b/tos/platforms/olimexp169/MoteClockC.nc new file mode 100644 index 00000000..d022620f --- /dev/null +++ b/tos/platforms/olimexp169/MoteClockC.nc @@ -0,0 +1,40 @@ +/* + * 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 MoteClockC { + provides interface Init as MoteClockInit; +} +implementation { + components new Msp430ClockC(4096, 32); + MoteClockInit = Msp430ClockC.Init; +} diff --git a/tos/platforms/olimexp169/MotePlatformC.nc b/tos/platforms/olimexp169/MotePlatformC.nc new file mode 100644 index 00000000..816e544a --- /dev/null +++ b/tos/platforms/olimexp169/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-0:- */ + P1SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P1OUT = 0; /* 0 0 0 0 0 0 0 0 */ + P1DIR = 0; /* 0 0 0 0 0 0 0 0 */ + + /* Port 2: 7-0:- */ + P2SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P2OUT = 0; /* 0 0 0 0 0 0 0 0 */ + P2DIR = 0; /* 0 0 0 0 0 0 0 0 */ + + /* Port 3: 7-6:- , 5:RXD0, 4:TXD0, 3-0:- */ + P3SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P3OUT = 0; /* 0 0 0 0 0 0 0 0 */ + P3DIR = 0x10; /* 0 0 0 1 0 0 0 0 */ + + /* Port 4: 7-0:- */ + P4SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P4OUT = 0; /* 0 0 0 0 0 0 0 0 */ + P4DIR = 0; /* 0 0 0 0 0 0 0 0 */ + + /* Port 5: 7-0:- */ + P5SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P5OUT = 0; /* 0 0 0 0 0 0 0 0 */ + P5DIR = 0; /* 0 0 0 0 0 0 0 0 */ + + /* Port 6: 7-2:-, 1:BUT, 0:LED */ + P6SEL = 0; /* 0 0 0 0 0 0 0 0 */ + P6OUT = 0x01; /* 0 0 0 0 0 0 0 1 */ + P6DIR = 0x01; /* 0 0 0 0 0 0 0 1 */ + + P1IE = 0; + P2IE = 0; + } + return SUCCESS; + } +} diff --git a/tos/platforms/olimexp169/PlatformLedsC.nc b/tos/platforms/olimexp169/PlatformLedsC.nc new file mode 100644 index 00000000..9f1cad7f --- /dev/null +++ b/tos/platforms/olimexp169/PlatformLedsC.nc @@ -0,0 +1,59 @@ +/* + * 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.Port60; + + components new NoPinC() as Led2Impl; + Led1 = Led2Impl; + Led2 = Led2Impl; +} + diff --git a/tos/platforms/olimexp169/PlatformSerialC.nc b/tos/platforms/olimexp169/PlatformSerialC.nc new file mode 100644 index 00000000..58d28330 --- /dev/null +++ b/tos/platforms/olimexp169/PlatformSerialC.nc @@ -0,0 +1,21 @@ + +configuration PlatformSerialC { + + provides interface StdControl; + provides interface UartStream; + provides interface UartByte; + +} + +implementation { + + components new Msp430Uart0C() as UartC; + UartStream = UartC; + UartByte = UartC; + + components TelosSerialP; + StdControl = TelosSerialP; + TelosSerialP.Msp430UartConfigure <- UartC.Msp430UartConfigure; + TelosSerialP.Resource -> UartC.Resource; + +} diff --git a/tos/platforms/olimexp169/PlatformSerialP.nc b/tos/platforms/olimexp169/PlatformSerialP.nc new file mode 100644 index 00000000..034547d1 --- /dev/null +++ b/tos/platforms/olimexp169/PlatformSerialP.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. + */ + + /** + * @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/olimexp169/SwitchToggleC.nc b/tos/platforms/olimexp169/SwitchToggleC.nc new file mode 100644 index 00000000..25ef1b9d --- /dev/null +++ b/tos/platforms/olimexp169/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/olimexp169/UserButton.h b/tos/platforms/olimexp169/UserButton.h new file mode 100644 index 00000000..97f124ed --- /dev/null +++ b/tos/platforms/olimexp169/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/olimexp169/UserButtonC.nc b/tos/platforms/olimexp169/UserButtonC.nc new file mode 100644 index 00000000..ff374cec --- /dev/null +++ b/tos/platforms/olimexp169/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/olimexp169/UserButtonP.nc b/tos/platforms/olimexp169/UserButtonP.nc new file mode 100644 index 00000000..eee88845 --- /dev/null +++ b/tos/platforms/olimexp169/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() { + /* Olimex P169 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/olimexp169/VoltageC.nc b/tos/platforms/olimexp169/VoltageC.nc new file mode 100644 index 00000000..d916c193 --- /dev/null +++ b/tos/platforms/olimexp169/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/olimexp169/VoltageStreamC.nc b/tos/platforms/olimexp169/VoltageStreamC.nc new file mode 100644 index 00000000..afbcd6cd --- /dev/null +++ b/tos/platforms/olimexp169/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/olimexp169/hardware.h b/tos/platforms/olimexp169/hardware.h new file mode 100644 index 00000000..c556ef08 --- /dev/null +++ b/tos/platforms/olimexp169/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/olimexp169/platform.h b/tos/platforms/olimexp169/platform.h new file mode 100644 index 00000000..e69de29b -- 2.39.2