From 9f961063e0462824a666490afaaed0c7292c2757 Mon Sep 17 00:00:00 2001 From: klueska Date: Fri, 13 Jun 2008 23:04:21 +0000 Subject: [PATCH] Added universal blocking SineSensor drivers for the C API --- tos/lib/tosthreads/csystem/TosThreadApiC.nc | 7 ++- .../sensorboards/universal/CSineSensorC.nc | 41 +++++++++++++++++ .../sensorboards/universal/CSineSensorP.nc | 45 +++++++++++++++++++ .../universal/tosthread_sinesensor.h | 43 ++++++++++++++++++ .../universal/universal_sensors.h | 41 +++++++++++++++++ tos/lib/tosthreads/system/BlockingReadP.nc | 2 + .../tosthreads/system/BlockingReadStreamP.nc | 1 + 7 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 tos/lib/tosthreads/sensorboards/universal/CSineSensorC.nc create mode 100644 tos/lib/tosthreads/sensorboards/universal/CSineSensorP.nc create mode 100644 tos/lib/tosthreads/sensorboards/universal/tosthread_sinesensor.h create mode 100644 tos/lib/tosthreads/sensorboards/universal/universal_sensors.h diff --git a/tos/lib/tosthreads/csystem/TosThreadApiC.nc b/tos/lib/tosthreads/csystem/TosThreadApiC.nc index 394c636d..d7c4d512 100644 --- a/tos/lib/tosthreads/csystem/TosThreadApiC.nc +++ b/tos/lib/tosthreads/csystem/TosThreadApiC.nc @@ -68,7 +68,7 @@ implementation { components CLogStorageC; #endif - //Telosb sensorbard specific. Later need to find conditional way of adding this in + //Telosb sensorboard specific. Later need to find conditional way of adding this in #if defined(TOSTHREAD_HAMAMATSUS1087_H) || defined(TOSTHREAD_DYNAMIC_LOADER) components CHamamatsuS1087ParC; #endif @@ -78,4 +78,9 @@ implementation { #if defined(TOSTHREAD_SENSIRIONSHT11_H) || defined(TOSTHREAD_DYNAMIC_LOADER) components CSensirionSht11C; #endif + + //Universal sensorboard specific + #if defined(TOSTHREAD_SINESENSOR_H) || defined(TOSTHREAD_DYNAMIC_LOADER) + components CSineSensorC; + #endif } diff --git a/tos/lib/tosthreads/sensorboards/universal/CSineSensorC.nc b/tos/lib/tosthreads/sensorboards/universal/CSineSensorC.nc new file mode 100644 index 00000000..6409b473 --- /dev/null +++ b/tos/lib/tosthreads/sensorboards/universal/CSineSensorC.nc @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2008 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 + */ + +configuration CSineSensorC {} +implementation { + components CSineSensorP; + components new BlockingSineSensorC(); + CSineSensorP.BlockingRead -> BlockingSineSensorC; +} diff --git a/tos/lib/tosthreads/sensorboards/universal/CSineSensorP.nc b/tos/lib/tosthreads/sensorboards/universal/CSineSensorP.nc new file mode 100644 index 00000000..63f197d5 --- /dev/null +++ b/tos/lib/tosthreads/sensorboards/universal/CSineSensorP.nc @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2008 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 + */ + +module CSineSensorP { + uses { + interface BlockingRead; + } +} +implementation { + error_t sinesensor_read(uint16_t* val) @C() @spontaneous() { + return call BlockingRead.read(val); + } +} diff --git a/tos/lib/tosthreads/sensorboards/universal/tosthread_sinesensor.h b/tos/lib/tosthreads/sensorboards/universal/tosthread_sinesensor.h new file mode 100644 index 00000000..46e0c12c --- /dev/null +++ b/tos/lib/tosthreads/sensorboards/universal/tosthread_sinesensor.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2008 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 + */ + +#ifndef TOSTHREAD_SINESENSOR_H +#define TOSTHREAD_SINESENSOR_H + +#include "TinyError.h" + +extern error_t sinesensor_read(uint16_t* val); + +#endif //TOSTHREAD_SINESENSOR_H diff --git a/tos/lib/tosthreads/sensorboards/universal/universal_sensors.h b/tos/lib/tosthreads/sensorboards/universal/universal_sensors.h new file mode 100644 index 00000000..3745ded9 --- /dev/null +++ b/tos/lib/tosthreads/sensorboards/universal/universal_sensors.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2008 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 + */ + +#ifndef UNIVERSAL_SENSORS_H +#define UNIVERSAL_SENSORS_H + +#include "tosthread_sinesensor.h" + +#endif //UNIVERSAL_SENSORS_H diff --git a/tos/lib/tosthreads/system/BlockingReadP.nc b/tos/lib/tosthreads/system/BlockingReadP.nc index be16b882..f933503a 100644 --- a/tos/lib/tosthreads/system/BlockingReadP.nc +++ b/tos/lib/tosthreads/system/BlockingReadP.nc @@ -93,4 +93,6 @@ implementation { p->error = result; call SystemCall.finish(s); } + default command error_t Read.read[uint8_t id]() { return FAIL; } + } diff --git a/tos/lib/tosthreads/system/BlockingReadStreamP.nc b/tos/lib/tosthreads/system/BlockingReadStreamP.nc index 616c5e75..adc3fb06 100644 --- a/tos/lib/tosthreads/system/BlockingReadStreamP.nc +++ b/tos/lib/tosthreads/system/BlockingReadStreamP.nc @@ -103,4 +103,5 @@ implementation { p->error = result; call SystemCall.finish(s); } + default command error_t ReadStream.read[uint8_t id](uint32_t usPeriod) { return FAIL; } } -- 2.39.2