]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Initial checkin of driver for the mda100ca/cb sensorboard. Devices attached to the...
authorklueska <klueska>
Tue, 21 Aug 2007 04:44:09 +0000 (04:44 +0000)
committerklueska <klueska>
Tue, 21 Aug 2007 04:44:09 +0000 (04:44 +0000)
13 files changed:
tos/sensorboards/mda100/ArbitratedPhotoDeviceP.nc [new file with mode: 0644]
tos/sensorboards/mda100/ArbitratedTempDeviceP.nc [new file with mode: 0644]
tos/sensorboards/mda100/DemoSensorC.nc [new file with mode: 0644]
tos/sensorboards/mda100/PhotoC.nc [new file with mode: 0644]
tos/sensorboards/mda100/PhotoImplP.nc [new file with mode: 0644]
tos/sensorboards/mda100/PhotoTempConfigC.nc [new file with mode: 0644]
tos/sensorboards/mda100/PhotoTempConfigP.nc [new file with mode: 0644]
tos/sensorboards/mda100/SharedAnalogDeviceC.nc [new file with mode: 0644]
tos/sensorboards/mda100/SharedAnalogDeviceP.nc [new file with mode: 0644]
tos/sensorboards/mda100/TempC.nc [new file with mode: 0644]
tos/sensorboards/mda100/ca/TempImplP.nc [new file with mode: 0644]
tos/sensorboards/mda100/cb/TempImplP.nc [new file with mode: 0644]
tos/sensorboards/mda100/mda100.h [new file with mode: 0644]

diff --git a/tos/sensorboards/mda100/ArbitratedPhotoDeviceP.nc b/tos/sensorboards/mda100/ArbitratedPhotoDeviceP.nc
new file mode 100644 (file)
index 0000000..7668a03
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * 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 Stanford University 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 STANFORD
+ * UNIVERSITY 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.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date August 20th, 2007
+ */
+
+configuration ArbitratedPhotoDeviceP
+{
+  provides interface Read<uint16_t>[uint8_t client];
+}
+implementation
+{
+  components PhotoImplP,
+    new ArbitratedReadC(uint16_t) as ArbitrateRead;
+
+  Read = ArbitrateRead;
+  ArbitrateRead.Service -> PhotoImplP.Read;
+  ArbitrateRead.Resource -> PhotoImplP.Resource;
+}
diff --git a/tos/sensorboards/mda100/ArbitratedTempDeviceP.nc b/tos/sensorboards/mda100/ArbitratedTempDeviceP.nc
new file mode 100644 (file)
index 0000000..94f7af9
--- /dev/null
@@ -0,0 +1,49 @@
+/*\r
+ * Copyright (c) 2007 Stanford University.\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * - Redistributions of source code must retain the above copyright\r
+ *   notice, this list of conditions and the following disclaimer.\r
+ * - Redistributions in binary form must reproduce the above copyright\r
+ *   notice, this list of conditions and the following disclaimer in the\r
+ *   documentation and/or other materials provided with the\r
+ *   distribution.\r
+ * - Neither the name of the Stanford University nor the names of\r
+ *   its contributors may be used to endorse or promote products derived\r
+ *   from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD\r
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\r
+ * OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**\r
+ * @author Kevin Klues <klueska@cs.stanford.edu>\r
+ * @date August 20th, 2007\r
+ */\r
+\r
+configuration ArbitratedTempDeviceP\r
+{\r
+  provides interface Read<uint16_t>[uint8_t client];\r
+}\r
+implementation\r
+{\r
+  components TempImplP,\r
+    new ArbitratedReadC(uint16_t) as ArbitrateRead;\r
+\r
+  Read = ArbitrateRead;\r
+  ArbitrateRead.Service -> TempImplP.Read;\r
+  ArbitrateRead.Resource -> TempImplP.Resource;\r
+}\r
diff --git a/tos/sensorboards/mda100/DemoSensorC.nc b/tos/sensorboards/mda100/DemoSensorC.nc
new file mode 100644 (file)
index 0000000..3e67b8e
--- /dev/null
@@ -0,0 +1,23 @@
+/* $Id$
+ * Copyright (c) 2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE     
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+/**
+ * Demo sensor for basicsb sensorboard.
+ * 
+ * @author David Gay
+ */
+
+generic configuration DemoSensorC() {
+  provides interface Read<uint16_t>;
+}
+implementation {
+  components new PhotoC() as Sensor;
+
+  Read = Sensor;
+}
diff --git a/tos/sensorboards/mda100/PhotoC.nc b/tos/sensorboards/mda100/PhotoC.nc
new file mode 100644 (file)
index 0000000..05fd6ae
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Id$
+ * Copyright (c) 2006 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE     
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+/**
+ * Photodiode of the mda100 sensor board.
+ * 
+ * @author David Gay
+ */
+
+#include "mda100.h"
+
+generic configuration PhotoC() {
+  provides interface Read<uint16_t>;
+}
+implementation {
+  components ArbitratedPhotoDeviceP;
+
+  Read = ArbitratedPhotoDeviceP.Read[unique(UQ_MDA100_PHOTO_RESOURCE)];
+}
diff --git a/tos/sensorboards/mda100/PhotoImplP.nc b/tos/sensorboards/mda100/PhotoImplP.nc
new file mode 100644 (file)
index 0000000..d85ff7b
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * 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 Stanford University 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 STANFORD
+ * UNIVERSITY 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.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date August 20th, 2007
+ */
+
+#include "mda100.h"
+
+configuration PhotoImplP {
+  provides {
+    interface Resource[uint8_t];
+    interface Read<uint16_t>[uint8_t];
+  }
+}
+implementation {
+  components new SharedAnalogDeviceC(UQ_MDA100_PHOTO_RESOURCE, 10);
+  components MicaBusC;
+  components PhotoTempConfigC as PhotoConfigC;
+
+  Resource = SharedAnalogDeviceC;
+  Read = SharedAnalogDeviceC;
+  SharedAnalogDeviceC.AdcConfig -> PhotoConfigC;
+  SharedAnalogDeviceC.EnablePin -> MicaBusC.Int1;
+}
diff --git a/tos/sensorboards/mda100/PhotoTempConfigC.nc b/tos/sensorboards/mda100/PhotoTempConfigC.nc
new file mode 100644 (file)
index 0000000..82374a4
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * 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 Stanford University 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 STANFORD
+ * UNIVERSITY 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.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date August 20th, 2007
+ */
+
+configuration PhotoTempConfigC {
+  provides interface Atm128AdcConfig;
+}
+implementation {
+  components PhotoTempConfigP;
+  components MicaBusC;
+  Atm128AdcConfig = PhotoTempConfigP;
+
+  PhotoTempConfigP.PhotoTempAdc -> MicaBusC.Adc1;
+}
diff --git a/tos/sensorboards/mda100/PhotoTempConfigP.nc b/tos/sensorboards/mda100/PhotoTempConfigP.nc
new file mode 100644 (file)
index 0000000..9cbbd64
--- /dev/null
@@ -0,0 +1,32 @@
+/* $Id$
+ * Copyright (c) 2007 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE     
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+/**
+ * MDA100 photo and temp sensor ADC configuration.
+ * @author David Gay <david.e.gay@intel.com>
+ */
+module PhotoTempConfigP
+{
+  provides interface Atm128AdcConfig;
+  uses interface MicaBusAdc as PhotoTempAdc;
+}
+implementation
+{
+  async command uint8_t Atm128AdcConfig.getChannel() {
+    return call PhotoTempAdc.getChannel();
+  }
+
+  async command uint8_t Atm128AdcConfig.getRefVoltage() {
+    return ATM128_ADC_VREF_OFF;
+  }
+
+  async command uint8_t Atm128AdcConfig.getPrescaler() {
+    return ATM128_ADC_PRESCALE;
+  }
+}
diff --git a/tos/sensorboards/mda100/SharedAnalogDeviceC.nc b/tos/sensorboards/mda100/SharedAnalogDeviceC.nc
new file mode 100644 (file)
index 0000000..d9a87f2
--- /dev/null
@@ -0,0 +1,65 @@
+/*\r
+ * Copyright (c) 2007 Stanford University.\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * - Redistributions of source code must retain the above copyright\r
+ *   notice, this list of conditions and the following disclaimer.\r
+ * - Redistributions in binary form must reproduce the above copyright\r
+ *   notice, this list of conditions and the following disclaimer in the\r
+ *   documentation and/or other materials provided with the\r
+ *   distribution.\r
+ * - Neither the name of the Stanford University nor the names of\r
+ *   its contributors may be used to endorse or promote products derived\r
+ *   from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL STANFORD\r
+ * UNIVERSITY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\r
+ * OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+/**\r
+ * @author Kevin Klues <klueska@cs.stanford.edu>\r
+ * @date August 20th, 2007\r
+ */\r
+\r
+generic configuration SharedAnalogDeviceC(char resourceName[], uint32_t startup_delay) {\r
+  provides {\r
+    interface Resource[uint8_t];\r
+    interface Read<uint16_t>[uint8_t];\r
+  }\r
+  uses {\r
+    interface Atm128AdcConfig as AdcConfig;\r
+    interface GeneralIO as EnablePin;\r
+  } \r
+}\r
+implementation {\r
+  components new RoundRobinArbiterC(resourceName) as Arbiter;\r
+  components new SplitControlPowerManagerC() as PowerManager;\r
+  components new SharedAnalogDeviceP(startup_delay) as AnalogDevice;\r
+  components new AdcReadNowClientC() as Adc;\r
+  components new TimerMilliC();\r
+  Resource = Arbiter;\r
+  Read = AnalogDevice;\r
+\r
+  PowerManager.ArbiterInfo -> Arbiter;\r
+  PowerManager.SplitControl -> AnalogDevice;\r
+  PowerManager.ResourceDefaultOwner -> Arbiter;\r
+  AnalogDevice.ActualRead -> Adc;\r
+  AnalogDevice.Timer -> TimerMilliC;\r
+  AnalogDevice.AnalogDeviceResource -> Adc;\r
+\r
+  Adc.Atm128AdcConfig = AdcConfig;\r
+  AnalogDevice.EnablePin = EnablePin;\r
+}\r
diff --git a/tos/sensorboards/mda100/SharedAnalogDeviceP.nc b/tos/sensorboards/mda100/SharedAnalogDeviceP.nc
new file mode 100644 (file)
index 0000000..d6d017d
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * 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 Stanford University 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 STANFORD
+ * UNIVERSITY 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.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date August 20th, 2007
+ */
+
+generic module SharedAnalogDeviceP(uint32_t startup_delay) {
+  provides {
+    interface SplitControl;
+    interface Read<uint16_t>[uint8_t];
+  }
+  uses {
+    interface Resource as AnalogDeviceResource;
+    interface Timer<TMilli>;
+    interface GeneralIO as EnablePin;
+    interface ReadNow<uint16_t> as ActualRead;
+  }
+}
+implementation {
+  bool started = FALSE;
+  bool busy = FALSE;
+  uint8_t client_id;
+  norace error_t read_result;
+  norace uint16_t read_val;
+       
+  command error_t SplitControl.start() {
+    error_t error;
+    if(started == FALSE) {
+      error = call AnalogDeviceResource.request();
+      if(error == SUCCESS)
+        started = TRUE;
+      return error;
+    }
+    return FAIL;
+  }
+
+  event void AnalogDeviceResource.granted() {
+    call EnablePin.makeOutput();
+    call EnablePin.set();
+    call Timer.startOneShot(startup_delay);
+  }
+
+  event void Timer.fired() {
+    signal SplitControl.startDone(SUCCESS);
+  }
+
+  task void stopDone() {
+    call AnalogDeviceResource.release();
+    started = FALSE;
+    signal SplitControl.stopDone(SUCCESS);
+  }
+
+  command error_t SplitControl.stop() {
+    if(started == TRUE) {
+      call EnablePin.clr();
+      call EnablePin.makeInput();
+      post stopDone();
+      return SUCCESS;
+    }
+    else if(busy == TRUE)
+      return EBUSY;
+    return FAIL;
+  }
+
+  command error_t Read.read[uint8_t id]() {
+    error_t error;
+    if(call AnalogDeviceResource.isOwner() && busy == FALSE) {
+      error = call ActualRead.read();
+      if(error == SUCCESS) {
+        busy = TRUE;
+        client_id = id; 
+      }
+      return error;
+    }
+    return FAIL;
+  }
+
+  task void readDoneTask() {
+    busy = FALSE;
+    signal Read.readDone[client_id](read_result, read_val);
+  }
+
+  async event void ActualRead.readDone(error_t result, uint16_t val) {
+    read_result = result;
+    read_val = val;
+    post readDoneTask();
+  }
+}
diff --git a/tos/sensorboards/mda100/TempC.nc b/tos/sensorboards/mda100/TempC.nc
new file mode 100644 (file)
index 0000000..6bdfb60
--- /dev/null
@@ -0,0 +1,25 @@
+/* $Id$\r
+ * Copyright (c) 2006 Intel Corporation\r
+ * All rights reserved.\r
+ *\r
+ * This file is distributed under the terms in the attached INTEL-LICENSE     \r
+ * file. If you do not find these files, copies can be found by writing to\r
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, \r
+ * 94704.  Attention:  Intel License Inquiry.\r
+ */\r
+/**\r
+ * Photodiode of the mda100 sensor board.\r
+ * \r
+ * @author David Gay\r
+ */\r
+\r
+#include "mda100.h"\r
+\r
+generic configuration TempC() {\r
+  provides interface Read<uint16_t>;\r
+}\r
+implementation {\r
+  components ArbitratedTempDeviceP;\r
+\r
+  Read = ArbitratedTempDeviceP.Read[unique(UQ_MDA100_TEMP_RESOURCE)];\r
+}\r
diff --git a/tos/sensorboards/mda100/ca/TempImplP.nc b/tos/sensorboards/mda100/ca/TempImplP.nc
new file mode 100644 (file)
index 0000000..94a1494
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * 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 Stanford University 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 STANFORD
+ * UNIVERSITY 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.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date August 20th, 2007
+ */
+
+#include "mda100.h"
+
+configuration TempImplP {
+  provides {
+    interface Resource[uint8_t];
+    interface Read<uint16_t>[uint8_t];
+  }
+}
+implementation {
+  components new SharedAnalogDeviceC(UQ_MDA100_TEMP_RESOURCE, 10);
+  components MicaBusC;
+  components PhotoTempConfigC as TempConfigC;
+
+  Resource = SharedAnalogDeviceC;
+  Read = SharedAnalogDeviceC;
+  SharedAnalogDeviceC.AdcConfig -> TempConfigC;
+  SharedAnalogDeviceC.EnablePin -> MicaBusC.Int2;
+}
diff --git a/tos/sensorboards/mda100/cb/TempImplP.nc b/tos/sensorboards/mda100/cb/TempImplP.nc
new file mode 100644 (file)
index 0000000..588a329
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * 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 Stanford University 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 STANFORD
+ * UNIVERSITY 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.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date August 20th, 2007
+ */
+
+#include "mda100.h"
+
+configuration TempImplP {
+  provides {
+    interface Resource[uint8_t];
+    interface Read<uint16_t>[uint8_t];
+  }
+}
+implementation {
+  components new SharedAnalogDeviceC(UQ_MDA100_TEMP_RESOURCE, 10);
+  components MicaBusC;
+  components PhotoTempConfigC as TempConfigC;
+
+  Resource = SharedAnalogDeviceC;
+  Read = SharedAnalogDeviceC;
+  SharedAnalogDeviceC.AdcConfig -> TempConfigC;
+  SharedAnalogDeviceC.EnablePin -> MicaBusC.PW0;
+}
diff --git a/tos/sensorboards/mda100/mda100.h b/tos/sensorboards/mda100/mda100.h
new file mode 100644 (file)
index 0000000..50e690d
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2007 Stanford University.
+ * 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 Stanford University 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 STANFORD
+ * UNIVERSITY 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.
+ */
+
+/**
+ * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @date August 20th, 2007
+ */
+
+#ifndef _MDA100_H
+#define _MDA100_H
+
+#define UQ_MDA100_PHOTO_RESOURCE "mda100.photo"
+#define UQ_MDA100_TEMP_RESOURCE "mda100.temp"
+
+#endif /* _MDA100_H */
+