From 2ffa09f67a30cf3fa75de30b5078996dbf3dfeb6 Mon Sep 17 00:00:00 2001 From: pipeng Date: Thu, 15 Feb 2007 10:28:46 +0000 Subject: [PATCH] update the latest driver code for T2. --- tos/sensorboards/mts300/.sensor | 4 +- tos/sensorboards/mts300/AccelConfigP.nc | 85 ++-- tos/sensorboards/mts300/AccelP.nc | 147 +++---- tos/sensorboards/mts300/PhotoC.nc | 54 ++- tos/sensorboards/mts300/PhotoTempP.nc | 226 ++++++++-- tos/sensorboards/mts300/SensorMts300C.nc | 90 ++-- tos/sensorboards/mts300/SensorMts300P.nc | 530 +++++++++++++++-------- tos/sensorboards/mts300/SounderC.nc | 41 +- tos/sensorboards/mts300/SounderP.nc | 76 +++- tos/sensorboards/mts300/mts300.h | 58 ++- 10 files changed, 904 insertions(+), 407 deletions(-) diff --git a/tos/sensorboards/mts300/.sensor b/tos/sensorboards/mts300/.sensor index b67f0304..191bed2b 100644 --- a/tos/sensorboards/mts300/.sensor +++ b/tos/sensorboards/mts300/.sensor @@ -10,5 +10,7 @@ # $Id$ # push( @includes, qw( - %T/sensorboards/mts300 + %T/sensorboards/mts300_me + %T/chips/atm128/i2c +# %T/chips/atm128/adc ) ); diff --git a/tos/sensorboards/mts300/AccelConfigP.nc b/tos/sensorboards/mts300/AccelConfigP.nc index d5546411..6005babd 100644 --- a/tos/sensorboards/mts300/AccelConfigP.nc +++ b/tos/sensorboards/mts300/AccelConfigP.nc @@ -1,41 +1,44 @@ -/* $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. - */ -/** - * Internal component for basicsb photodiode. Arbitrates access to the photo - * diode and automatically turns it on or off based on user requests. - * - * @author David Gay - */ - -configuration AccelConfigP { - provides { - interface Resource[uint8_t client]; - interface Atm128AdcConfig as ConfigX; - interface Atm128AdcConfig as ConfigY; - } -} -implementation { - components AccelP, MicaBusC, new TimerMilliC() as WarmupTimer, - new RoundRobinArbiterC(UQ_ACCEL_RESOURCE) as Arbiter, - new SplitControlPowerManagerC() as PowerManager; - - Resource = Arbiter; - ConfigX = AccelP.ConfigX; - ConfigY = AccelP.ConfigY; - - PowerManager.ResourceDefaultOwner -> Arbiter; - PowerManager.ArbiterInfo -> Arbiter; - PowerManager.SplitControl -> AccelP; - - AccelP.Timer -> WarmupTimer; - AccelP.AccelPin -> MicaBusC.PW4; - AccelP.AccelAdcX -> MicaBusC.Adc3; - AccelP.AccelAdcY -> MicaBusC.Adc4; -} +/* $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. + */ +/** + * Internal component for basicsb photodiode. Arbitrates access to the photo + * diode and automatically turns it on or off based on user requests. + * + * @author David Gay + */ + +#include "mts300.h" + +configuration AccelConfigP { + provides { + interface Init; + interface StdControl; + + interface Atm128AdcConfig as ConfigX; + interface Atm128AdcConfig as ConfigY; + interface ResourceConfigure as ResourceX; + interface ResourceConfigure as ResourceY; + } +} +implementation { + components AccelP, MicaBusC; + + Init = AccelP; + StdControl = AccelP; + + ConfigX = AccelP.ConfigX; + ConfigY = AccelP.ConfigY; + ResourceX = AccelP.ResourceX; + ResourceY = AccelP.ResourceY; + + AccelP.AccelPower -> MicaBusC.PW4; + AccelP.AccelAdcX -> MicaBusC.Adc3; + AccelP.AccelAdcY -> MicaBusC.Adc4; +} diff --git a/tos/sensorboards/mts300/AccelP.nc b/tos/sensorboards/mts300/AccelP.nc index c3742a78..cfe5c597 100644 --- a/tos/sensorboards/mts300/AccelP.nc +++ b/tos/sensorboards/mts300/AccelP.nc @@ -1,76 +1,71 @@ -/* $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. - */ -/** - * ADXL202JE accelerometer ADC configuration and power management. - * @author David Gay - */ -module AccelP -{ - provides { - interface SplitControl; - interface Atm128AdcConfig as ConfigX; - interface Atm128AdcConfig as ConfigY; - } - uses { - interface Timer; - interface GeneralIO as AccelPin; - interface MicaBusAdc as AccelAdcX; - interface MicaBusAdc as AccelAdcY; - } -} -implementation -{ - async command uint8_t ConfigX.getChannel() { - return call AccelAdcX.getChannel(); - } - - async command uint8_t ConfigX.getRefVoltage() { - return ATM128_ADC_VREF_OFF; - } - - async command uint8_t ConfigX.getPrescaler() { - return ATM128_ADC_PRESCALE; - } - - async command uint8_t ConfigY.getChannel() { - return call AccelAdcY.getChannel(); - } - - async command uint8_t ConfigY.getRefVoltage() { - return ATM128_ADC_VREF_OFF; - } - - async command uint8_t ConfigY.getPrescaler() { - return ATM128_ADC_PRESCALE; - } - - command error_t SplitControl.start() { - call AccelPin.makeOutput(); - call AccelPin.set(); - /* Startup time is 16.3ms for 0.1uF capacitors, - according to the ADXL202E data sheet */ - call Timer.startOneShot(17); - return SUCCESS; - } - - event void Timer.fired() { - signal SplitControl.startDone(SUCCESS); - } - - task void stopDone() { - call AccelPin.clr(); - signal SplitControl.stopDone(SUCCESS); - } - - command error_t SplitControl.stop() { - post stopDone(); - return SUCCESS; - } -} +#include "mts300.h" +#include "Timer.h" + +module AccelP +{ + provides interface Init; + provides interface StdControl; + + provides interface Atm128AdcConfig as ConfigX; + provides interface Atm128AdcConfig as ConfigY; + provides interface ResourceConfigure as ResourceX; + provides interface ResourceConfigure as ResourceY; + + uses interface GeneralIO as AccelPower; + uses interface MicaBusAdc as AccelAdcX; + uses interface MicaBusAdc as AccelAdcY; +} + +implementation +{ + command error_t Init.init() + { + call AccelPower.makeOutput(); + call AccelPower.clr(); + + return SUCCESS; + } + + command error_t StdControl.start() + { + call AccelPower.set(); + return SUCCESS; + } + + command error_t StdControl.stop() + { + call AccelPower.clr(); + call AccelPower.makeInput(); + + return SUCCESS; + } + + async command uint8_t ConfigX.getChannel() { + return call AccelAdcX.getChannel(); + } + + async command uint8_t ConfigX.getRefVoltage() { + return ATM128_ADC_VREF_OFF; + } + + async command uint8_t ConfigX.getPrescaler() { + return ATM128_ADC_PRESCALE; + } + + async command uint8_t ConfigY.getChannel() { + return call AccelAdcY.getChannel(); + } + + async command uint8_t ConfigY.getRefVoltage() { + return ATM128_ADC_VREF_OFF; + } + + async command uint8_t ConfigY.getPrescaler() { + return ATM128_ADC_PRESCALE; + } + + async command void ResourceX.configure() { } + async command void ResourceX.unconfigure() { } + async command void ResourceY.configure() { } + async command void ResourceY.unconfigure() {} +} \ No newline at end of file diff --git a/tos/sensorboards/mts300/PhotoC.nc b/tos/sensorboards/mts300/PhotoC.nc index d6acb651..38f788ea 100644 --- a/tos/sensorboards/mts300/PhotoC.nc +++ b/tos/sensorboards/mts300/PhotoC.nc @@ -1,25 +1,49 @@ -/* $Id$ - * Copyright (c) 2006 Intel Corporation - * All rights reserved. +/** + * Copyright (c) 2005-2006 Crossbow Technology, Inc. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written + * agreement is hereby granted, provided that the above copyright + * notice, the (updated) modification history and the author appear in + * all copies of this source code. + * + * Permission is also granted to distribute this software under the + * standard BSD license as contained in the TinyOS distribution. * - * 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. + * 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 HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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. */ -/** - * Photodiode of the mts300 sensor board. - * - * @author David Gay + /* + * @author Hu Siquan + * + * $Id$ */ #include "mts300.h" -generic configuration PhotoC() { +generic configuration PhotoC() +{ provides interface Read; + provides interface StdControl; + provides interface Init; } -implementation { - components ArbitratedPhotoDeviceP; +implementation +{ + components new AdcReadClientC(), PhotoTempDeviceP; + + Init = PhotoTempDeviceP; + StdControl = PhotoTempDeviceP; - Read = ArbitratedPhotoDeviceP.Read[unique(UQ_PHOTO_RESOURCE)]; + Read = AdcReadClientC; + AdcReadClientC.Atm128AdcConfig -> PhotoTempDeviceP.PhotoAtm128AdcConfig; + AdcReadClientC.ResourceConfigure -> PhotoTempDeviceP.PhotoResourceConfigure; } diff --git a/tos/sensorboards/mts300/PhotoTempP.nc b/tos/sensorboards/mts300/PhotoTempP.nc index 185f6f7a..dc4a6387 100644 --- a/tos/sensorboards/mts300/PhotoTempP.nc +++ b/tos/sensorboards/mts300/PhotoTempP.nc @@ -1,32 +1,194 @@ -/* $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. - */ -/** - * MTS300 photo and temp sensor ADC configuration. - * @author David Gay - */ -module PhotoTempP -{ - 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; - } -} +/** + * Copyright (c) 2005-2006 Crossbow Technology, Inc. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written + * agreement is hereby granted, provided that the above copyright + * notice, the (updated) modification history and the author appear in + * all copies of this source code. + * + * Permission is also granted to distribute this software under the + * standard BSD license as contained in the TinyOS distribution. + * + * 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 HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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 Martin Turon + * @author Hu Siquan + * + * $Id$ + */ + +#include "Timer.h" + +module PhotoTempP +{ + provides + { + interface Init; //!< Standard Initialization + interface StdControl; //!< Start/Stop for Temp Sensor's Power Management + interface ResourceConfigure as TempResourceConfigure; + interface ResourceConfigure as PhotoResourceConfigure; + interface Atm128AdcConfig as TempAtm128AdcConfig; + interface Atm128AdcConfig as PhotoAtm128AdcConfig; + } + uses + { + interface GeneralIO as TempPower; + interface GeneralIO as LightPower; + interface MicaBusAdc as SensorAdc; + interface Leds as DebugLeds; + } +} +implementation +{ +/* + enum + { + STATE_IDLE = 0, + STATE_LIGHT_WARMING, //!< Powering on sensor + STATE_LIGHT_READY, //!< Power up of sensor complete + STATE_LIGHT_SAMPLING, //!< Sampling sensor + STATE_TEMP_WARMING, //!< Powering on sensor + STATE_TEMP_READY, //!< Power up of sensor complete + STATE_TEMP_SAMPLING, //!< Sampling sensor + }; + + /// Yes, this could be a simple uint8_t. There used to be more bits here, + /// but they were optimized out and removed. + union + { + uint8_t flat; + struct + { + uint8_t state : 4; //!< sensorboard state + } bits; + } g_flags; +*/ + + void inline TOSH_uwait(int u_sec) + { + /* In most cases (constant arg), the test is elided at compile-time */ + if (u_sec) + /* loop takes 4 cycles, aka 1us */ + asm volatile ( + "1: sbiw %0,1\n" + " brne 1b" : "+w" (u_sec)); + } + /** + * Initialize this component. Initialization should not assume that + * any component is running: init() cannot call any commands besides + * those that initialize other components. + * + */ + command error_t Init.init() + { + return SUCCESS; + } + + + /** + * Start the component and its subcomponents. + * + * @return SUCCESS if the component was successfully started. + */ + command error_t StdControl.start() + { + call TempPower.makeOutput(); + call TempPower.clr(); + call LightPower.makeOutput(); + call LightPower.clr(); + + return SUCCESS; + } + + /** + * Stop the component and pertinent subcomponents (not all + * subcomponents may be turned off due to wakeup timers, etc.). + * + * @return SUCCESS if the component was successfully stopped. + */ + command error_t StdControl.stop() + { + call TempPower.clr(); + call LightPower.clr(); + call TempPower.makeInput(); + call LightPower.makeInput(); + + return SUCCESS; + } + + async command uint8_t TempAtm128AdcConfig.getChannel() + { + return call SensorAdc.getChannel(); + } + + async command uint8_t TempAtm128AdcConfig.getRefVoltage() + { + return ATM128_ADC_VREF_OFF; + } + + async command uint8_t TempAtm128AdcConfig.getPrescaler() + { + return ATM128_ADC_PRESCALE; + } + + async command uint8_t PhotoAtm128AdcConfig.getChannel() + { + return call SensorAdc.getChannel(); + } + + async command uint8_t PhotoAtm128AdcConfig.getRefVoltage() + { + return ATM128_ADC_VREF_OFF; + } + + async command uint8_t PhotoAtm128AdcConfig.getPrescaler() + { + return ATM128_ADC_PRESCALE; + } + + async command void TempResourceConfigure.configure() + { + call DebugLeds.led0On(); + call LightPower.clr(); + call LightPower.makeInput(); + call TempPower.makeOutput(); + call TempPower.set(); + TOSH_uwait(1000); + } + + async command void TempResourceConfigure.unconfigure() + { + call DebugLeds.led0Off(); + call TempPower.clr(); + call TempPower.makeInput(); + } + + /** Turns on the light sensor and turns the thermistor off. */ + async command void PhotoResourceConfigure.configure() + { + call DebugLeds.led1On(); + call TempPower.clr(); + call TempPower.makeInput(); + call LightPower.makeOutput(); + call LightPower.set(); + TOSH_uwait(1000); + } + + async command void PhotoResourceConfigure.unconfigure() + { + call DebugLeds.led1Off(); + call LightPower.clr(); + call LightPower.makeInput(); + } +} diff --git a/tos/sensorboards/mts300/SensorMts300C.nc b/tos/sensorboards/mts300/SensorMts300C.nc index df62369a..12e093b2 100644 --- a/tos/sensorboards/mts300/SensorMts300C.nc +++ b/tos/sensorboards/mts300/SensorMts300C.nc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004-2005 Crossbow Technology, Inc. + * Copyright (c) 2005-2006 Crossbow Technology, Inc. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its @@ -12,51 +12,83 @@ * standard BSD license as contained in the TinyOS distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * 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 HOLDERS OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, - * OR PROFITS) 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 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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 Martin Turon - * @author Miguel Freitas + * @author Hu Siquan * * $Id$ */ -configuration SensorMts300C +//configuration SensorMts300C +generic configuration SensorMts300C() { - provides { - interface Init; //!< Standard Initialization - interface StdControl; //!< Start/Stop for Power Management - interface Read as Temp; //!< Thermister - interface Read as Light; //!< Photo sensor - } + provides + { + interface Init; //!< Standard Initialization + interface StdControl; //!< Start/Stop for Power Management + interface Read as Vref; //!< voltage + interface Read as Temp; //!< Thermister + interface Read as Light; //!< Photo sensor + interface Read as Microphone; //!< Mic sensor + interface Read as AccelX; //!< Accelerometer sensor + interface Read as AccelY; //!< Accelerometer sensor + interface Read as MagX; //!< magnetometer sensor + interface Read as MagY; //!< magnetometer sensor + } } -implementation +implementation { - components - SensorMts300P, - SensorMts300DeviceP, - HplAtm128GeneralIOC as IO, - new AdcReadClientC() as SensorADC, - new TimerMilliC() as WarmUpTimer - ; + components SensorMts300P, HplAtm128GeneralIOC as IO, + new VoltageC(), + new PhotoC(), + new TempC(), + new MicC(), + new MagC(), + new AccelC(), + new TimerMilliC() as WarmUpTimer; Init = SensorMts300P.Init; + Init = PhotoC.Init; + Init = MicC.Init; StdControl = SensorMts300P.StdControl; + Vref = SensorMts300P.Vref; Temp = SensorMts300P.Temp; Light = SensorMts300P.Light; + Microphone = SensorMts300P.Microphone; + AccelX = SensorMts300P.AccelX; + AccelY = SensorMts300P.AccelY; + MagX = SensorMts300P.MagX; + MagY = SensorMts300P.MagY; - SensorADC.Atm128AdcConfig -> SensorMts300DeviceP; - SensorADC.ResourceConfigure -> SensorMts300DeviceP; + SensorMts300P.WarmUpTimer -> WarmUpTimer; - SensorMts300P.SensorADC -> SensorADC; - SensorMts300P.TempPower -> IO.PortE6; + SensorMts300P.VrefRead -> VoltageC.Read; + SensorMts300P.PhotoControl -> PhotoC.StdControl; + SensorMts300P.TempRead -> TempC.Read; + SensorMts300P.LightRead -> PhotoC.Read; SensorMts300P.LightPower -> IO.PortE5; - SensorMts300P.WarmUpTimer -> WarmUpTimer; + SensorMts300P.TempPower -> IO.PortE6; + + SensorMts300P.MicControl -> MicC.StdControl; + SensorMts300P.Mic -> MicC.Mic; + SensorMts300P.MicRead -> MicC.Read; + + SensorMts300P.MagControl -> MagC.StdControl; + SensorMts300P.Mag -> MagC.Mag; + SensorMts300P.MagXRead -> MagC.MagX; + SensorMts300P.MagYRead -> MagC.MagY; + + SensorMts300P.AccelControl -> AccelC.StdControl; + SensorMts300P.AccelXRead -> AccelC.AccelX; + SensorMts300P.AccelYRead -> AccelC.AccelY; + } diff --git a/tos/sensorboards/mts300/SensorMts300P.nc b/tos/sensorboards/mts300/SensorMts300P.nc index 5984093c..82a90bde 100644 --- a/tos/sensorboards/mts300/SensorMts300P.nc +++ b/tos/sensorboards/mts300/SensorMts300P.nc @@ -1,5 +1,5 @@ /** - * Copyright (c) 2004-2005 Crossbow Technology, Inc. + * Copyright (c) 2005-2006 Crossbow Technology, Inc. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its @@ -12,18 +12,17 @@ * standard BSD license as contained in the TinyOS distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * 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 HOLDERS OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, - * OR PROFITS) 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 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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 Martin Turon - * @author Miguel Freitas * * $Id$ */ @@ -33,62 +32,94 @@ /** * This component is the "platform" of the sensorboard space. * It handles particulars of initialization, and glues all the - * member sensor "chips" into one place. The current implementation - * is overly monolithic, and should be divided into smaller + * member sensor "chips" into one place. The current implementation + * is overly monolithic, and should be divided into smaller * components that handle each individual sensor. The temperature * and light sensors are tightly coupled however and in the case * of the micaz, interfere with the radio (INT2), so more can * be done to clean up the design here. - * + * * @author Martin Turon * @date October 19, 2005 */ module SensorMts300P { - provides { - interface Init; //!< Standard Initialization - interface StdControl; //!< Start/Stop for Power Management - interface Read as Temp; //!< Thermister - interface Read as Light; //!< Photo sensor - } + provides + { + interface Init; //!< Standard Initialization + interface StdControl; //!< Start/Stop for Power Management + interface Read as Vref; //!< voltage + interface Read as Temp; //!< Thermister + interface Read as Light; //!< Photo sensor + interface Read as Microphone; //!< Mic sensor + interface Read as AccelX; //!< Accelerometer sensor + interface Read as AccelY; //!< Accelerometer sensor + interface Read as MagX; //!< magnetometer sensor + interface Read as MagY; //!< magnetometer sensor + } - uses { - interface GeneralIO as TempPower; - interface GeneralIO as LightPower; - interface Read as SensorADC; - interface Timer as WarmUpTimer; - } + uses + { + interface GeneralIO as TempPower; + interface GeneralIO as LightPower; + interface StdControl as PhotoControl; + interface StdControl as MicControl; + interface Mic; + interface StdControl as MagControl; + interface Mag; + interface StdControl as AccelControl; + + interface Read as VrefRead; + interface Read as TempRead; //!< Thermister + interface Read as LightRead; //!< Photo sensor + interface Read as MicRead; //!< Mic sensor + interface Read as AccelXRead; //!< Magnetometer sensor + interface Read as AccelYRead; //!< Magnetometer sensor + interface Read as MagXRead; //!< Magnetometer sensor + interface Read as MagYRead; //!< Magnetometer sensor + interface Timer as WarmUpTimer; + } } -implementation +implementation { - enum { - STATE_IDLE = 0, - STATE_LIGHT_WARMING, //!< Powering on sensor - STATE_LIGHT_READY, //!< Power up of sensor complete - STATE_LIGHT_SAMPLING, //!< Sampling sensor - STATE_TEMP_WARMING, //!< Powering on sensor - STATE_TEMP_READY, //!< Power up of sensor complete - STATE_TEMP_SAMPLING, //!< Sampling sensor - }; + enum + { + STATE_IDLE = 0, + STATE_LIGHT_WARMING, //!< Powering on sensor + STATE_LIGHT_READY, //!< Power up of sensor complete + STATE_LIGHT_SAMPLING, //!< Sampling sensor + STATE_TEMP_WARMING, //!< Powering on sensor + STATE_TEMP_READY, //!< Power up of sensor complete + STATE_TEMP_SAMPLING, //!< Sampling sensor + STATE_MIC_WARMING, //!< Powering on sensor + STATE_MIC_READY, //!< Power up of sensor complete + STATE_MIC_SAMPLING, //!< Sampling sensor + }; /// Yes, this could be a simple uint8_t. There used to be more bits here, /// but they were optimized out and removed. - union { - uint8_t flat; - struct { + union + { + uint8_t flat; + struct + { uint8_t state : 4; //!< sensorboard state - } bits; - } g_flags; + } bits; + } g_flags; /** * Initialize this component. Initialization should not assume that * any component is running: init() cannot call any commands besides - * those that initialize other components. + * those that initialize other components. * */ - command error_t Init.init() { - g_flags.flat = STATE_IDLE; - return SUCCESS; + command error_t Init.init() + { + g_flags.flat = STATE_IDLE; + call Mic.muxSel(1); // Set the mux so that raw microhpone output is selected + call Mic.gainAdjust(64); // Set the gain of the microphone. + + return SUCCESS; } /** @@ -96,109 +127,130 @@ implementation * * @return SUCCESS if the component was successfully started. */ - command error_t StdControl.start() { - return SUCCESS; + command error_t StdControl.start() + { + call PhotoControl.start(); + call MicControl.start(); + call MagControl.start(); + call AccelControl.start(); + return SUCCESS; } - + /** * Stop the component and pertinent subcomponents (not all * subcomponents may be turned off due to wakeup timers, etc.). * * @return SUCCESS if the component was successfully stopped. */ - command error_t StdControl.stop() { - call TempPower.clr(); - call LightPower.clr(); - call TempPower.makeInput(); - call LightPower.makeInput(); - atomic g_flags.bits.state = STATE_IDLE; - return SUCCESS; + command error_t StdControl.stop() + { + call TempPower.clr(); + call LightPower.clr(); + call TempPower.makeInput(); + call LightPower.makeInput(); + atomic g_flags.bits.state = STATE_IDLE; + + call PhotoControl.stop(); + call MicControl.stop(); + call MagControl.stop(); + call AccelControl.stop(); + + return SUCCESS; } /** Turns on the light sensor and turns the thermistor off. */ - void switchLightOn() { - atomic g_flags.bits.state = STATE_LIGHT_WARMING; - call TempPower.clr(); - call TempPower.makeInput(); - call LightPower.makeOutput(); - call LightPower.set(); - call WarmUpTimer.startOneShot(10); + void switchLightOn() + { + atomic g_flags.bits.state = STATE_LIGHT_WARMING; + call TempPower.clr(); + call TempPower.makeInput(); + call LightPower.makeOutput(); + call LightPower.set(); + call WarmUpTimer.startOneShot(10); } /** Turns on the thermistor and turns the light sensor off. */ - void switchTempOn() { - atomic g_flags.bits.state = STATE_TEMP_WARMING; - call LightPower.clr(); - call LightPower.makeInput(); - call TempPower.makeOutput(); - call TempPower.set(); - call WarmUpTimer.startOneShot(10); + void switchTempOn() + { + atomic g_flags.bits.state = STATE_TEMP_WARMING; + call LightPower.clr(); + call LightPower.makeInput(); + call TempPower.makeOutput(); + call TempPower.set(); + call WarmUpTimer.startOneShot(10); } - task void getLightSample() { - switch (g_flags.bits.state) { - case STATE_TEMP_WARMING: - case STATE_TEMP_READY: - case STATE_TEMP_SAMPLING: - // If Temperature is busy, repost and try again later. - // This will not let the CPU sleep. Add delay timer. - post getLightSample(); - return; - - case STATE_IDLE: - // Okay, grab the sensor. - switchLightOn(); - return; - - case STATE_LIGHT_WARMING: - // Warm-up Timer will switch out of this state. - return; - - case STATE_LIGHT_READY: - // Start the sample. - atomic { g_flags.bits.state = STATE_LIGHT_SAMPLING; } - call SensorADC.read(); - return; + void switchMicOn() + { + atomic g_flags.bits.state = STATE_MIC_WARMING; + call WarmUpTimer.startOneShot(10); + } - case STATE_LIGHT_SAMPLING: - // SensorADC.dataReady will switch out of this state. - return; - } + task void getLightSample() + { + switch (g_flags.bits.state) + { + case STATE_IDLE: + // Okay, grab the sensor. + switchLightOn(); + return; + case STATE_LIGHT_READY: + // Start the sample. + atomic { g_flags.bits.state = STATE_LIGHT_SAMPLING; } + call LightRead.read(); + return; + case STATE_LIGHT_WARMING: + // Warm-up Timer will switch out of this state. + case STATE_LIGHT_SAMPLING: + // LightRead.readDone will switch out of this state. + return; + } } - task void getTempSample() { - switch (g_flags.bits.state) { - case STATE_LIGHT_WARMING: - case STATE_LIGHT_READY: - case STATE_LIGHT_SAMPLING: - // If Temperature is busy, repost and try again later. - // This will not let the CPU sleep. Add delay timer. - post getTempSample(); - return; - - case STATE_IDLE: - // Okay, grab the sensor. - switchTempOn(); - return; - - case STATE_TEMP_WARMING: - // Warm-up Timer will switch out of this state. - return; - - case STATE_TEMP_READY: - // Start the sample. - atomic { g_flags.bits.state = STATE_TEMP_SAMPLING; } - call SensorADC.read(); - return; + task void getTempSample() + { + switch (g_flags.bits.state) + { + case STATE_IDLE: + // Okay, grab the sensor. + switchTempOn(); + return; + case STATE_TEMP_READY: + // Start the sample. + atomic { g_flags.bits.state = STATE_TEMP_SAMPLING; } + call TempRead.read(); + return; + case STATE_TEMP_WARMING: + // Warm-up Timer will switch out of this state. + case STATE_TEMP_SAMPLING: + // TempRead.readDone will switch out of this state. + return; + } + } - case STATE_TEMP_SAMPLING: - // SensorADC.dataReady will switch out of this state. - return; - } + task void getMicSample() + { + switch (g_flags.bits.state) + { + case STATE_IDLE: + // Okay, grab the sensor. + switchMicOn(); + return; + case STATE_MIC_READY: + // Start the sample. + atomic { g_flags.bits.state = STATE_MIC_SAMPLING; } + call MicRead.read(); + return; + case STATE_MIC_WARMING: + // Warm-up Timer will switch out of this state. + case STATE_MIC_SAMPLING: + // MicRead.readDone will switch out of this state. + return; + } } - /** - * Start Temperature data acquisition. + /** + * Start Temperature data acquisition. * * This will post a task which will handle sequential states: * WARMING, READY, SAMPLING, DONE (IDLE) @@ -207,77 +259,191 @@ implementation * @return SUCCESS if request accepted, EBUSY if it is refused * 'dataReady' or 'error' will be signaled if SUCCESS is returned */ - command error_t Temp.read() { - post getTempSample(); - return SUCCESS; + command error_t Temp.read() + { + post getTempSample(); + return SUCCESS; } - - /** - * Start Light data acquisition. - * - * This will post a task which will handle sequential states: - * WARMING, READY, SAMPLING, DONE (IDLE) - * and repost itself until it is completed. - * - * @return SUCCESS if request accepted, EBUSY if it is refused - * 'dataReady' or 'error' will be signaled if SUCCESS is returned - */ - command error_t Light.read() { - post getLightSample(); - return SUCCESS; + command error_t Light.read() + { + post getLightSample(); + return SUCCESS; } - - /** + command error_t Microphone.read() + { + post getMicSample(); + return SUCCESS; + } + command error_t Vref.read() + { + call VrefRead.read(); + return SUCCESS; + } + command error_t AccelX.read() + { + //signal AccelX.readDone(SUCCESS,0x1); + call AccelXRead.read(); + return SUCCESS; + } + command error_t AccelY.read() + { + //signal AccelY.readDone(SUCCESS,0x2); + call AccelYRead.read(); + return SUCCESS; + } + command error_t MagX.read() + { + //signal MagX.readDone(SUCCESS,0x3); + call MagXRead.read(); + return SUCCESS; + } + command error_t MagY.read() + { + //signal MagY.readDone(SUCCESS,0x4); + call MagYRead.read(); + return SUCCESS; + } + /** * Timer to allow either thermistor or light sensor to warm up for 10 msec. */ - event void WarmUpTimer.fired() { - switch (g_flags.bits.state) { - case STATE_LIGHT_WARMING: - atomic { g_flags.bits.state = STATE_LIGHT_READY; } - post getLightSample(); - return; - - case STATE_TEMP_WARMING: - atomic { g_flags.bits.state = STATE_TEMP_READY; } - post getTempSample(); - return; - - default: - //ERROR!!! - signal Light.readDone( FAIL, 0 ); - signal Temp.readDone( FAIL, 0 ); - } - // Worst case -- return to the IDLE state so next task can progress !! - atomic { g_flags.bits.state = STATE_IDLE; } + event void WarmUpTimer.fired() + { + switch (g_flags.bits.state) + { + case STATE_LIGHT_WARMING: + atomic { g_flags.bits.state = STATE_LIGHT_READY; } + post getLightSample(); + return; + + case STATE_TEMP_WARMING: + atomic { g_flags.bits.state = STATE_TEMP_READY; } + post getTempSample(); + return; + + case STATE_MIC_WARMING: + atomic { g_flags.bits.state = STATE_MIC_READY; } + post getMicSample(); + return; + + default: + //ERROR!!! + signal Light.readDone(FAIL,0); + signal Temp.readDone(FAIL,0); + signal Microphone.readDone(FAIL,0); + } + // Worst case -- return to the IDLE state so next task can progress !! + atomic { g_flags.bits.state = STATE_IDLE; } } - /** + /** * Data has been acquired. - * @param data Acquired value - * Values are "left-justified" within each 16-bit integer, i.e., if - * the data is acquired with n bits of precision, each value is - * shifted left by 16-n bits. + * @param result Acquired success flag + * @param val Acquired value */ - event void SensorADC.readDone( error_t result, uint16_t data ) { - switch (g_flags.bits.state) { + event void LightRead.readDone( error_t result, uint16_t val ) + { + //val = (val >>6); + val &= 0x3ff; + switch (g_flags.bits.state) + { case STATE_LIGHT_SAMPLING: - signal Light.readDone(result, data); - break; + signal Light.readDone(result,val); + break; + default: //ERROR!!! + signal Light.readDone(FAIL,0); + } + // state must return to IDLE state so next task can progress !! + atomic { g_flags.bits.state = STATE_IDLE; } + } + event void TempRead.readDone( error_t result, uint16_t val ) + { + //val = (val >>6); + val &= 0x3ff; + switch (g_flags.bits.state) + { case STATE_TEMP_SAMPLING: - signal Temp.readDone(result, data); - break; - - default: - //ERROR!!! - signal Light.readDone( FAIL, 0 ); - signal Temp.readDone( FAIL, 0 ); - } - // ADC.dataReady must return to IDLE state so next task can progress !! - atomic { g_flags.bits.state = STATE_IDLE; } + signal Temp.readDone(result,val); + break; + default: //ERROR!!! + signal Temp.readDone(FAIL,0); + } + // state must return to IDLE state so next task can progress !! + atomic { g_flags.bits.state = STATE_IDLE; } } + event void MicRead.readDone( error_t result, uint16_t val ) + { + //val = (val >>6); + val &= 0x3ff; + switch (g_flags.bits.state) + { + case STATE_MIC_SAMPLING: + signal Microphone.readDone(result,val); + break; + default: //ERROR!!! + signal Microphone.readDone(FAIL,0); + } + // state must return to IDLE state so next task can progress !! + atomic { g_flags.bits.state = STATE_IDLE; } + } + + event void VrefRead.readDone( error_t result, uint16_t val ) + { + //val = (val >>6); + val &= 0x3ff; + signal Vref.readDone(result,val); + // state must return to IDLE state so next task can progress !! + atomic { g_flags.bits.state = STATE_IDLE; } + } + + event void AccelXRead.readDone( error_t result, uint16_t val ) + { + //val = (val >>6); + val &= 0x3ff; + signal AccelX.readDone(result,val); + // state must return to IDLE state so next task can progress !! + atomic { g_flags.bits.state = STATE_IDLE; } + } + + event void AccelYRead.readDone( error_t result, uint16_t val ) + { + //val = (val >>6); + val &= 0x3ff; + signal AccelY.readDone(result,val); + // state must return to IDLE state so next task can progress !! + atomic { g_flags.bits.state = STATE_IDLE; } + } + + event void MagXRead.readDone( error_t result, uint16_t val ) + { + //val = (val >>6); + val &= 0x3ff; + signal MagX.readDone(result,val); + // state must return to IDLE state so next task can progress !! + atomic { g_flags.bits.state = STATE_IDLE; } + } + + event void MagYRead.readDone( error_t result, uint16_t val ) + { + //val = (val >>6); + val &= 0x3ff; + signal MagY.readDone(result,val); + // state must return to IDLE state so next task can progress !! + atomic { g_flags.bits.state = STATE_IDLE; } + } + + event error_t Mag.gainAdjustXDone(bool result) + { + return result; + } + event error_t Mag.gainAdjustYDone(bool result) + { + return result; + } } + + diff --git a/tos/sensorboards/mts300/SounderC.nc b/tos/sensorboards/mts300/SounderC.nc index a121e89e..52ec479c 100644 --- a/tos/sensorboards/mts300/SounderC.nc +++ b/tos/sensorboards/mts300/SounderC.nc @@ -1,12 +1,45 @@ +/** + * Copyright (c) 2005-2006 Crossbow Technology, Inc. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written + * agreement is hereby granted, provided that the above copyright + * notice, the (updated) modification history and the author appear in + * all copies of this source code. + * + * Permission is also granted to distribute this software under the + * standard BSD license as contained in the TinyOS distribution. + * + * 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 HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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 Hu Siquan + * + * $Id$ + */ + +#include "mts300.h" + configuration SounderC { - provides interface Mts300Sounder; + provides interface Init; + provides interface StdControl; } implementation { - components SounderP, new TimerMilliC(), MicaBusC; + components SounderP, MicaBusC; - Mts300Sounder = SounderP; - SounderP.Timer -> TimerMilliC; + Init = SounderP; + StdControl = SounderP; SounderP.SounderPin -> MicaBusC.PW2; } diff --git a/tos/sensorboards/mts300/SounderP.nc b/tos/sensorboards/mts300/SounderP.nc index e5f2c064..7b71bc05 100644 --- a/tos/sensorboards/mts300/SounderP.nc +++ b/tos/sensorboards/mts300/SounderP.nc @@ -1,31 +1,65 @@ -module SounderP +/** + * Copyright (c) 2005-2006 Crossbow Technology, Inc. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written + * agreement is hereby granted, provided that the above copyright + * notice, the (updated) modification history and the author appear in + * all copies of this source code. + * + * Permission is also granted to distribute this software under the + * standard BSD license as contained in the TinyOS distribution. + * + * 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 HOLDERS OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA, + * OR PROFITS) 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 Hu Siquan + * + * $Id$ + */ + +#include "mts300.h" + +module SounderP { - provides interface Mts300Sounder; - uses { - interface Timer; - interface GeneralIO as SounderPin; - } + provides interface Init; + provides interface StdControl; + uses interface GeneralIO as SounderPin; } -implementation -{ - command void Mts300Sounder.beep(uint16_t length) { - if (call Timer.isRunning()) - { - uint32_t remaining = call Timer.getdt(), - elapsed = call Timer.getNow() - call Timer.gett0(); - - /* If more time left than we are requesting, just exit */ - if (remaining > elapsed && (remaining - elapsed) > length) - return; - /* Override timer with new duration */ - } - call Timer.startOneShot(length); +implementation +{ + command error_t Init.init() + { +#if SOUNDER call SounderPin.makeOutput(); + call SounderPin.clr(); +#endif + return SUCCESS; + } + + command error_t StdControl.start() + { +#if SOUNDER call SounderPin.set(); +#endif + return SUCCESS; } - event void Timer.fired() { + command error_t StdControl.stop() + { +#if SOUNDER call SounderPin.clr(); +#endif + return SUCCESS; } } diff --git a/tos/sensorboards/mts300/mts300.h b/tos/sensorboards/mts300/mts300.h index 8c2f7af9..9424ae28 100644 --- a/tos/sensorboards/mts300/mts300.h +++ b/tos/sensorboards/mts300/mts300.h @@ -1,9 +1,55 @@ -#ifndef MTS300_H -#define MTS300_H +/* $Id$ */ +/* + * Copyright (c) 2005-2006 Crossbow Technology, Inc. All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL CROSSBOW TECHNOLOGY OR ANY OF ITS LICENSORS BE LIABLE TO + * ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL + * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF CROSSBOW OR ITS LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * CROSSBOW TECHNOLOGY AND ITS LICENSORS SPECIFICALLY DISCLAIM ALL WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND NEITHER CROSSBOW NOR ANY LICENSOR HAS ANY + * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR + * MODIFICATIONS. + */ +/** + * + * @author Hu Siquan + * Revision: $Revision$ + * + */ -#define UQ_ACCEL_RESOURCE "mts300.accel" -#define UQ_PHOTO_RESOURCE "mts300.photo" -#define UQ_TEMP_RESOURCE "mts300.temp" -#define UQ_PHOTOTEMP_RESOURCE "mts300.phototemp" +#ifndef _MTS300_H +#define _MTS300_H +// sounder enable (1) /disable (0) +#ifndef SOUNDER +#define SOUNDER 1 #endif + +#define MTS3X0_PHOTO_TEMP "mts300.photo.temp" +#define MTS3X0_MAG_RESOURCE "mts300.mag" + +enum +{ + TOS_MIC_POT_ADDR = 0x5A, + TOS_MAG_POT_ADDR = 0x58, +}; + +// debug leds +//#define _DEBUG_LEDS +#ifdef _DEBUG_LEDS +#define DEBUG_LEDS(X) X.DebugLeds -> LedsC +#else +#define DEBUG_LEDS(X) X.DebugLeds -> NoLedsC +#endif +#endif /* _MTS300_H */ + -- 2.39.2