]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Migrate scp1000 components into tos tree
authorsmckown <smckown@4bc1554a-c7f2-4f65-a403-e0be01f0239c>
Fri, 12 Sep 2008 23:27:42 +0000 (23:27 +0000)
committerR. Steve McKown <rsmckown@gmail.com>
Tue, 1 Dec 2009 03:00:59 +0000 (20:00 -0700)
tos/chips/scp1000/Scp1000.h [new file with mode: 0644]
tos/chips/scp1000/Scp1000C.nc [new file with mode: 0644]
tos/chips/scp1000/Scp1000P.nc [new file with mode: 0644]
tos/platforms/tmirws/.platform
tos/platforms/tmirws/MotePlatformC.nc
tos/platforms/tmirws/chips/scp1000/Scp1000PinsC.nc [new file with mode: 0644]
tos/platforms/tmirws/chips/scp1000/Scp1000SpiC.nc [new file with mode: 0644]
tos/platforms/tmirws/chips/scp1000/Scp1000SpiConfigC.nc [new file with mode: 0644]

diff --git a/tos/chips/scp1000/Scp1000.h b/tos/chips/scp1000/Scp1000.h
new file mode 100644 (file)
index 0000000..22a7603
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+/**
+ * Header definitions for the SCP1000.
+ * 
+ * @author R. Steve McKown <smckown@gmail.com>
+ */
+#ifndef SCP1000_H
+#define SCP1000_H
+
+typedef struct {
+  unsigned int temp;
+  unsigned long pressure;
+} scp1000_t;
+
+#endif
diff --git a/tos/chips/scp1000/Scp1000C.nc b/tos/chips/scp1000/Scp1000C.nc
new file mode 100644 (file)
index 0000000..bb022c2
--- /dev/null
@@ -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.
+ */
+/**
+ * Main user component for the SCP1000 pressure sensor.  This is a highly
+ * abstracted component designed for infrequent pressure measurements where
+ * energy costs are to be minimized.
+ * 
+ * @author R. Steve McKown <smckown@gmail.com>
+ */
+#include "Scp1000.h"
+
+configuration Scp1000C {
+  provides interface ReadRef<scp1000_t>;
+}
+implementation {
+  components new Scp1000P();
+  ReadRef = Scp1000P;
+
+  components MainC;
+  MainC.SoftwareInit -> Scp1000P;
+
+  components Scp1000PinsC;
+  Scp1000P.CSn -> Scp1000PinsC.CSn;
+  Scp1000P.PD -> Scp1000PinsC.PD;
+  Scp1000P.DRDY -> Scp1000PinsC.DRDY;
+  Scp1000P.IntDRDY -> Scp1000PinsC;
+
+  components Scp1000SpiC;
+  Scp1000P.Resource -> Scp1000SpiC;
+  Scp1000P.SpiByte -> Scp1000SpiC;
+
+  components new TimerMilliC();
+  Scp1000P.Timer -> TimerMilliC;
+}
diff --git a/tos/chips/scp1000/Scp1000P.nc b/tos/chips/scp1000/Scp1000P.nc
new file mode 100644 (file)
index 0000000..89dd629
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * 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.
+ */
+/**
+ * scp1000 implementation.
+ * 
+ * @author R. Steve McKown <smckown@gmail.com>
+ */
+
+#include "Scp1000.h"
+generic module Scp1000P() @safe()
+{
+  provides {
+    interface Init;
+    interface ReadRef<scp1000_t>;
+  }
+  uses {
+    /* TODO: too platform specific, but need for disableRen() */
+    interface HplMsp430GeneralIO as CSn;
+    interface HplMsp430GeneralIO as PD;
+    interface HplMsp430GeneralIO as DRDY;
+    interface GpioInterrupt as IntDRDY;
+    interface Resource;
+    interface SpiByte;
+    interface Timer<TMilli>;
+  }
+}
+implementation
+{
+  enum {
+    /* Data register names for SCP1000 */
+    OPERATION = 3,
+    STATUS = 7,
+    DATARD8 = 0x1f,
+    DATARD16 = 0x20,
+    TEMPOUT = 0x21,
+
+    /* Timer states */
+    TIMER_NONE = 0,
+    TIMER_POWER,
+    TIMER_CHECK,
+    TIMER_DRDY
+  };
+
+  scp1000_t* m_ptr;
+  uint8_t tstate;
+  uint8_t counter;
+
+  inline uint8_t addrOut(uint8_t addr, bool write)
+  {
+    return (addr << 2) + (write ? 2 : 0);
+  }
+
+  uint8_t readByte(uint8_t addr)
+  {
+    uint8_t data;
+
+    call CSn.clr();
+    call SpiByte.write(addrOut(addr, FALSE));
+    data = call SpiByte.write(0);
+    call CSn.set();
+    return data;
+  }
+
+  void writeByte(uint8_t addr, uint8_t data)
+  {
+    call CSn.clr();
+    call SpiByte.write(addrOut(addr, TRUE));
+    call SpiByte.write(data);
+    call CSn.set();
+  }
+
+  uint16_t readWord(uint8_t addr)
+  {
+    uint16_t data;
+
+    call CSn.clr();
+    call SpiByte.write(addrOut(addr, FALSE));
+    data = (call SpiByte.write(0) << 8);
+    data += call SpiByte.write(0);
+    call CSn.set();
+    return data;
+  }
+
+  void signalDone(error_t error)
+  {
+    scp1000_t* tmp = m_ptr;
+
+    call DRDY.enableRen();
+    call PD.set();
+    call Resource.release();
+    m_ptr = 0;
+    signal ReadRef.readDone(error, tmp);
+  }
+
+  command error_t Init.init()
+  {
+    /* TODO: tmicore MotePlatformC sets the pins we use up in a way that isn't
+     * ideal for our use, but changing them requires that we use platform
+     * dependent code.  Find a way to fix this.
+     *
+     * When the part is 'soldered' onto the board, aka tmirws, then
+     * MotePlatform can set it and be done, mostly.  However, DRDY will use
+     * extra energy since with the scp1000 on it pulls DRDY low most of the
+     * time, causing current through the enabled pull-up.  Best to turn it
+     * off after PD is enabled and on before PD is disabled.
+     */
+    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;
+  }
+
+  command error_t ReadRef.read(scp1000_t* ptr)
+  {
+    if (m_ptr || !ptr)
+      return FAIL;
+    m_ptr = ptr;
+    call Resource.request();
+    return SUCCESS;
+  }
+
+  event void Resource.granted()
+  {
+    /* Begin powerup sequence */
+    call PD.clr();
+    tstate = TIMER_POWER;
+    call Timer.startOneShot(60);
+  }
+
+  task void check()
+  {
+    /* Abort if we've waited too long for ready state */
+    if (counter++ == 6) {
+      signalDone(FAIL);
+      return;
+    }
+
+    /* Poll to see if the sensor is ready */
+    if (readByte(STATUS) & 0x01) {
+      tstate = TIMER_CHECK;
+      call Timer.startOneShot(10);
+      return;
+    }
+
+    /* Verify EEPROM was loaded without error */
+    if (!(readByte(DATARD8) & 0x01)) {
+      signalDone(FAIL);
+      return;
+    }
+
+    /* Initiate a reading.  DRDY will assert when done, ~ 500ms from now */
+    tstate = TIMER_DRDY;
+    call Timer.startOneShot(1024);
+    call IntDRDY.enableRisingEdge();
+    writeByte(OPERATION, 0x0c);
+  }
+
+  task void results();
+
+  async event void IntDRDY.fired()
+  {
+    call IntDRDY.disable();
+    post results();
+  }
+
+  task void results()
+  {
+    call Timer.stop();
+    m_ptr->temp = readWord(TEMPOUT);
+    m_ptr->pressure = (uint32_t)readByte(DATARD8) << 16;
+    m_ptr->pressure += readWord(DATARD16);
+    signalDone(SUCCESS);
+    return;
+  }
+
+  event void Timer.fired()
+  {
+    uint8_t tmp = tstate;
+
+    tstate = TIMER_NONE;
+    switch (tmp) {
+      case TIMER_POWER:
+       call DRDY.disableRen();
+       counter = 0;
+       post check();
+       break;
+      case TIMER_CHECK:
+       post check();
+       break;
+      case TIMER_DRDY:
+       signalDone(FAIL);
+       break;
+      default:
+    }
+  }
+}
index be7e9235c0f307e5bc80e702933b52f3edafb121..9d0801499d59c0715bf71810f5c5eff40030bb7c 100755 (executable)
@@ -5,6 +5,7 @@
 
 push( @includes, qw(
   %T/platforms/tmirws
+  %T/platforms/tmirws/chips/scp1000
   %T/platforms/tmicore
   %T/platforms/tmicore/chips/bq2403x
   %T/platforms/tmicore/chips/cp210x
@@ -18,6 +19,7 @@ push( @includes, qw(
   %T/chips/msp430/sensors
   %T/chips/bq2403x
   %T/chips/cp210x
+  %T/chips/scp1000
   %T/lib/timer
   %T/lib/serial
   %T/lib/adc
index e79701a3523979c15b168a3551b7f3a97445b6a3..41643345788174202cc502f5e5e2e24d84fba144 100644 (file)
@@ -45,10 +45,17 @@ implementation {
 #endif
 
        /* Port 1: 7:BQSTAT2, 6:BQSTAT1, 5:RAIN, 4:-, 3:CP_CTS, 2:CP_RTS, 1:BSL_TX, 0:WSPEED */
+#if 0 /* no rain/wind yet */
        P1SEL = 0;      /* 0 0 0 0 0 0 0 0 */
        P1OUT = 0x18;   /* 0 0 0 1 1 0 0 0 */
        P1DIR = 0x08;   /* 0 0 0 0 1 0 0 0 */
        P1REN = 0x10;   /* 0 0 0 1 0 0 0 0 */
+#else 
+       P1SEL = 0;      /* 0 0 0 0 0 0 0 0 */
+       P1OUT = 0x39;   /* 0 0 1 1 1 0 0 1 */
+       P1DIR = 0x08;   /* 0 0 0 0 1 0 0 0 */
+       P1REN = 0x31;   /* 0 0 1 1 0 0 0 1 */
+#endif
  
        /* Port 2:
         * 7:SHT_DATA, 6:SCP_DRDY, 5:BUTTONn, 4:USB_SUSPENDn, 3:-, 2:BSL_RX, 1:USBPGn, 0:SOLARPGn
@@ -59,10 +66,17 @@ implementation {
        P2REN = 0x08;   /* 0 0 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:SHT_SCK */
+#if 0 /* no sht yet */
        P3SEL = 0;      /* 0 0 0 0 0 0 0 0 */
        P3OUT = 0xff;   /* 1 1 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 */
+#else
+       P3SEL = 0;      /* 0 0 0 0 0 0 0 0 */
+       P3OUT = 0xff;   /* 1 1 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 */
+#endif
 
        /* Port 4: 7:-, 6:LED2n, 5:LED1n, 4:FLH_CSn, 3:SCP_CSn, 2:SCP_PD, 1:-, 0:- */
        P4SEL = 0;      /* 0 0 0 0 0 0 0 0 */
@@ -71,16 +85,31 @@ implementation {
        P4REN = 0x83;   /* 1 0 0 0 0 0 1 1 */
 
        /* Port 5: 7:W315, 6:W270, 5:W225, 4:W180, 3:W135, 2:W090, 1:W045, 0:W000 */
+#if 0 /* no wind yet */
        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 */
        P5REN = 0;      /* 0 0 0 0 0 0 0 0 */
+#else
+       /* 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 */
+#endif
 
        /* Port 6: 7:TEMP_PWR, 6:TEMP3, 5:TEMP2, 4:TEMP1, 3:PHOTO, 2:-, 1:-, 0:ADC_VBATT */
+#if 0 /* no photo or temps yet */
        P6SEL = 0x79;   /* 0 1 1 1 1 0 0 1 */
        P6OUT = 0;      /* 0 0 0 0 0 0 0 0 */
        P6DIR = 0x80;   /* 1 0 0 0 0 0 0 0 */
        P6REN = 0x06;   /* 0 0 0 0 0 1 1 0 */
+#else
+       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 = 0xff;   /* 1 1 1 1 1 1 1 1 */
+#endif
 
        P1IE = 0;
        P2IE = 0;
diff --git a/tos/platforms/tmirws/chips/scp1000/Scp1000PinsC.nc b/tos/platforms/tmirws/chips/scp1000/Scp1000PinsC.nc
new file mode 100644 (file)
index 0000000..96e9655
--- /dev/null
@@ -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.
+ */
+/**
+ * Platform specific pin mapping for the Scp1000.
+ * 
+ * @author R. Steve McKown <smckown@gmail.com>
+ */
+configuration Scp1000PinsC {
+  provides {
+    interface HplMsp430GeneralIO as CSn;
+    interface HplMsp430GeneralIO as PD;
+    interface HplMsp430GeneralIO as DRDY;
+    interface GpioInterrupt as IntDRDY;
+  }
+}
+implementation {
+#if 0
+  components new Msp430GpioC() as CSn_;
+  CSn = CSn_.GeneralIO;
+
+  components new Msp430GpioC() as PD_;
+  PD = PD_.GeneralIO;
+
+  components new Msp430GpioC() as DRDY_;
+  DRDY = DRDY_.GeneralIO;
+#endif
+
+  components new Msp430InterruptC() as IntDRDY_;
+  IntDRDY = IntDRDY_.Interrupt;
+
+  components HplMsp430GeneralIOC as IOC;
+#if 0
+  CSn_.HplGeneralIO -> IOC.Port43;
+  PD_.HplGeneralIO -> IOC.Port42;
+  DRDY_.HplGeneralIO -> IOC.Port26;
+#else
+  CSn = IOC.Port43;
+  PD = IOC.Port42;
+  DRDY = IOC.Port26;
+#endif
+
+  components HplMsp430InterruptC as IntC;
+  IntDRDY_.HplInterrupt -> IntC.Port26;
+}
diff --git a/tos/platforms/tmirws/chips/scp1000/Scp1000SpiC.nc b/tos/platforms/tmirws/chips/scp1000/Scp1000SpiC.nc
new file mode 100644 (file)
index 0000000..bf91c44
--- /dev/null
@@ -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 <smckown@gmail.com>
+ */
+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 (file)
index 0000000..2b2b689
--- /dev/null
@@ -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 <smckown@gmail.com>
+ */
+module Scp1000SpiConfigC {
+  provides interface AsyncConfigure<const msp430_usci_spi_t*> 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;
+  }
+}