From d32c29caca7c7ae33003c7e0a3a3d3b0ec3620cc Mon Sep 17 00:00:00 2001 From: gtolle Date: Fri, 13 Apr 2007 21:46:18 +0000 Subject: [PATCH] Added DeviceMetadata interface to telosb sensors. --- tos/chips/sht11/SensirionSht11.h | 5 +++++ tos/chips/sht11/SensirionSht11ReaderP.nc | 9 +++++++++ tos/platforms/telosa/chips/s1087/HamamatsuS1087ParC.nc | 2 ++ tos/platforms/telosa/chips/s1087/HamamatsuS1087ParP.nc | 5 ++++- tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrC.nc | 2 ++ tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrP.nc | 3 +++ tos/platforms/telosa/chips/sht11/SensirionSht11C.nc | 4 ++++ 7 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tos/chips/sht11/SensirionSht11.h b/tos/chips/sht11/SensirionSht11.h index 7d3fb206..29485c4a 100644 --- a/tos/chips/sht11/SensirionSht11.h +++ b/tos/chips/sht11/SensirionSht11.h @@ -34,6 +34,11 @@ * @author Gilman Tolle */ +enum { + SHT11_TEMPERATURE_BITS = 14, + SHT11_HUMIDITY_BITS = 12, +}; + enum { SHT11_STATUS_LOW_RES_BIT = 1 << 0, SHT11_STATUS_NO_RELOAD_BIT = 1 << 1, diff --git a/tos/chips/sht11/SensirionSht11ReaderP.nc b/tos/chips/sht11/SensirionSht11ReaderP.nc index 66acc3fd..44c59b91 100644 --- a/tos/chips/sht11/SensirionSht11ReaderP.nc +++ b/tos/chips/sht11/SensirionSht11ReaderP.nc @@ -40,8 +40,12 @@ * @version $Revision$ $Date$ */ +#include + generic module SensirionSht11ReaderP() { + provides interface DeviceMetadata as TemperatureMetadata; provides interface Read as Temperature; + provides interface DeviceMetadata as HumidityMetadata; provides interface Read as Humidity; uses interface Resource as TempResource; @@ -50,6 +54,9 @@ generic module SensirionSht11ReaderP() { uses interface SensirionSht11 as Sht11Hum; } implementation { + + command uint8_t TemperatureMetadata.getSignificantBits() { return SHT11_TEMPERATURE_BITS; } + command error_t Temperature.read() { call TempResource.request(); return SUCCESS; @@ -68,6 +75,8 @@ implementation { signal Temperature.readDone( result, val ); } + command uint8_t HumidityMetadata.getSignificantBits() { return SHT11_HUMIDITY_BITS; } + command error_t Humidity.read() { call HumResource.request(); return SUCCESS; diff --git a/tos/platforms/telosa/chips/s1087/HamamatsuS1087ParC.nc b/tos/platforms/telosa/chips/s1087/HamamatsuS1087ParC.nc index b9907d6f..b36ffa0b 100644 --- a/tos/platforms/telosa/chips/s1087/HamamatsuS1087ParC.nc +++ b/tos/platforms/telosa/chips/s1087/HamamatsuS1087ParC.nc @@ -38,6 +38,7 @@ */ generic configuration HamamatsuS1087ParC() { + provides interface DeviceMetadata; provides interface Read; provides interface ReadStream; } @@ -49,6 +50,7 @@ implementation { ReadStream = AdcReadStreamClientC; components HamamatsuS1087ParP; + DeviceMetadata = HamamatsuS1087ParP; AdcReadClientC.AdcConfigure -> HamamatsuS1087ParP; AdcReadStreamClientC.AdcConfigure -> HamamatsuS1087ParP; } diff --git a/tos/platforms/telosa/chips/s1087/HamamatsuS1087ParP.nc b/tos/platforms/telosa/chips/s1087/HamamatsuS1087ParP.nc index ee9451f0..ac03062f 100644 --- a/tos/platforms/telosa/chips/s1087/HamamatsuS1087ParP.nc +++ b/tos/platforms/telosa/chips/s1087/HamamatsuS1087ParP.nc @@ -40,6 +40,7 @@ */ module HamamatsuS1087ParP { + provides interface DeviceMetadata; provides interface AdcConfigure; } implementation { @@ -54,7 +55,9 @@ implementation { sampcon_ssel: SAMPCON_SOURCE_SMCLK, sampcon_id: SAMPCON_CLOCK_DIV_1 }; - + + command uint8_t DeviceMetadata.getSignificantBits() { return 12; } + async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration() { return &config; } diff --git a/tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrC.nc b/tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrC.nc index 6c2a1641..49b7aabc 100644 --- a/tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrC.nc +++ b/tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrC.nc @@ -38,6 +38,7 @@ */ generic configuration HamamatsuS10871TsrC() { + provides interface DeviceMetadata; provides interface Read; provides interface ReadStream; } @@ -49,6 +50,7 @@ implementation { ReadStream = AdcReadStreamClientC; components HamamatsuS10871TsrP; + DeviceMetadata = HamamatsuS10871TsrP; AdcReadClientC.AdcConfigure -> HamamatsuS10871TsrP; AdcReadStreamClientC.AdcConfigure -> HamamatsuS10871TsrP; } diff --git a/tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrP.nc b/tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrP.nc index 94093628..3e4f6abe 100644 --- a/tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrP.nc +++ b/tos/platforms/telosa/chips/s10871/HamamatsuS10871TsrP.nc @@ -40,6 +40,7 @@ */ module HamamatsuS10871TsrP { + provides interface DeviceMetadata; provides interface AdcConfigure; } implementation { @@ -54,6 +55,8 @@ implementation { sampcon_ssel: SAMPCON_SOURCE_SMCLK, sampcon_id: SAMPCON_CLOCK_DIV_1 }; + + command uint8_t DeviceMetadata.getSignificantBits() { return 12; } async command const msp430adc12_channel_config_t* AdcConfigure.getConfiguration() { return &config; diff --git a/tos/platforms/telosa/chips/sht11/SensirionSht11C.nc b/tos/platforms/telosa/chips/sht11/SensirionSht11C.nc index 6adb709f..871903b4 100644 --- a/tos/platforms/telosa/chips/sht11/SensirionSht11C.nc +++ b/tos/platforms/telosa/chips/sht11/SensirionSht11C.nc @@ -44,13 +44,17 @@ generic configuration SensirionSht11C() { provides interface Read as Temperature; + provides interface DeviceMetadata as TemperatureMetadata; provides interface Read as Humidity; + provides interface DeviceMetadata as HumidityMetadata; } implementation { components new SensirionSht11ReaderP(); Temperature = SensirionSht11ReaderP.Temperature; + TemperatureMetadata = SensirionSht11ReaderP.TemperatureMetadata; Humidity = SensirionSht11ReaderP.Humidity; + HumidityMetadata = SensirionSht11ReaderP.HumidityMetadata; components HalSensirionSht11C; -- 2.39.2