From c62eb5a8f569e1a267d10a4c4aa24e8f5151fb8b Mon Sep 17 00:00:00 2001 From: smckown Date: Mon, 2 Nov 2009 20:43:23 +0000 Subject: [PATCH] Work on wind sensor move to Davis Instruments. --- tos/platforms/tmirws/MotePlatformC.nc | 7 ++- tos/platforms/tmirws/sensors/HalWindVaneC.nc | 14 ++--- tos/platforms/tmirws/sensors/HalWindVaneP.nc | 63 -------------------- tos/platforms/tmirws/sensors/WindVaneAdcP.nc | 10 ++-- tos/platforms/tmirws/sensors/WindVaneC.nc | 3 + tos/platforms/tmirws/sensors/WindVaneP.nc | 3 + 6 files changed, 21 insertions(+), 79 deletions(-) delete mode 100644 tos/platforms/tmirws/sensors/HalWindVaneP.nc diff --git a/tos/platforms/tmirws/MotePlatformC.nc b/tos/platforms/tmirws/MotePlatformC.nc index 9f750488..6aebc096 100644 --- a/tos/platforms/tmirws/MotePlatformC.nc +++ b/tos/platforms/tmirws/MotePlatformC.nc @@ -80,15 +80,16 @@ 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 + * 7:WPOWER, 6:W270, 5:W225, 4:W180, 3:W135, 2:W090, 1:W045, 0:W000 */ 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 */ + P5DIR = 0x80; /* 1 0 0 0 0 0 0 0 */ P5REN = 0; /* 0 0 0 0 0 0 0 0 */ /* Port 6: - * 7:TEMP_PWR, 6:TEMP3, 5:TEMP2, 4:TEMP1, 3:PHOTO, 2:-, 1:-, 0:ADC_VBATT + * 7:TEMP_PWR, 6:TEMP3, 5:TEMP2, 4:TEMP1, 3:PHOTO, 2:ADC_WIND, 1:-, + * 0:ADC_VBATT */ P6SEL = 0x79; /* 0 1 1 1 1 0 0 1 */ P6OUT = 0; /* 0 0 0 0 0 0 0 0 */ diff --git a/tos/platforms/tmirws/sensors/HalWindVaneC.nc b/tos/platforms/tmirws/sensors/HalWindVaneC.nc index 21322ae1..2125a28e 100644 --- a/tos/platforms/tmirws/sensors/HalWindVaneC.nc +++ b/tos/platforms/tmirws/sensors/HalWindVaneC.nc @@ -28,20 +28,18 @@ */ /** - * HAL layer for the wind vane sensor. + * HAL layer for the wind vane sensor provides a power control. * * @author R. Steve McKown */ -#include "WindVane.h" - configuration HalWindVaneC { - provides interface AsyncGet; + provides interface GeneralIO as WPower; } implementation { - components HalWindVaneP; - AsyncGet = HalWindVaneP; + components new Msp430GpioC() as WPowerM; + WPower = WPowerM; - components MainC; - MainC.SoftwareInit -> HalWindVaneP.Init; + components HplMsp430GeneralIOC; + WPowerM -> HplMsp430GeneralIOC.Port57; } diff --git a/tos/platforms/tmirws/sensors/HalWindVaneP.nc b/tos/platforms/tmirws/sensors/HalWindVaneP.nc deleted file mode 100644 index 92bd42a1..00000000 --- a/tos/platforms/tmirws/sensors/HalWindVaneP.nc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 Titanium Mirror, Inc. 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. - */ - -/** - * HAL/HPL layers for the WindVane sensor. - * - * @author R. Steve McKown - */ - -#include "WindVane.h" - -module HalWindVaneP { - provides { - interface Init; - interface AsyncGet as Vane; - } -} -implementation { -#define WIND_IN (*TCAST(volatile uint8_t* ONE, P5IN_)) -#define WIND_DIR (*TCAST(volatile uint8_t* ONE, P5DIR_)) -#define WIND_SEL (*TCAST(volatile uint8_t* ONE, P5SEL_)) -#define WIND_REN (*TCAST(volatile uint8_t* ONE, P5REN_)) - - command error_t Init.init() - { - /* Initialize the port providing wind direction information */ - WIND_DIR = 0; - WIND_SEL = 0; - WIND_REN = 0; - return SUCCESS; - } - - async command uint8_t Vane.get() - { - atomic return ~WIND_IN; - } -} diff --git a/tos/platforms/tmirws/sensors/WindVaneAdcP.nc b/tos/platforms/tmirws/sensors/WindVaneAdcP.nc index b4e92054..e898db0f 100644 --- a/tos/platforms/tmirws/sensors/WindVaneAdcP.nc +++ b/tos/platforms/tmirws/sensors/WindVaneAdcP.nc @@ -51,13 +51,13 @@ implementation { * jumping around. The external reference of 2.50V seems stable. */ const msp430adc12_channel_config_t config = { - inch: INPUT_CHANNEL_A0, // A2 -#if 0 /* internal references unstable */ + inch: INPUT_CHANNEL_A2, +#if 1 /* internal references unstable (no, I don't think so) */ sref: REFERENCE_VREFplus_AVss, - ref2_5v: REFVOLT_LEVEL_1_5, /* REFVOLT_LEVEL_2_5, */ -#else /* external reference is stable */ + ref2_5v: /*REFVOLT_LEVEL_1_5, */ REFVOLT_LEVEL_2_5, +#else /* external reference is stable, and is 2.5V */ sref: REFERENCE_VeREFplus_AVss, - ref2_5v: REFVOLT_LEVEL_1_5, + ref2_5v: REFVOLT_LEVEL_1_5, #endif #if 0 /* clock source doesn't seem to affect stability */ adc12ssel: SHT_SOURCE_ADC12OSC, diff --git a/tos/platforms/tmirws/sensors/WindVaneC.nc b/tos/platforms/tmirws/sensors/WindVaneC.nc index 2c317596..883021f7 100644 --- a/tos/platforms/tmirws/sensors/WindVaneC.nc +++ b/tos/platforms/tmirws/sensors/WindVaneC.nc @@ -47,4 +47,7 @@ implementation { components new WindVaneAdcC(); WindVaneP.Vane -> WindVaneAdcC.Read; + + components HalWindVaneC; + WindVaneP.WPower -> HalWindVaneC; } diff --git a/tos/platforms/tmirws/sensors/WindVaneP.nc b/tos/platforms/tmirws/sensors/WindVaneP.nc index 4042470e..f9907c8e 100644 --- a/tos/platforms/tmirws/sensors/WindVaneP.nc +++ b/tos/platforms/tmirws/sensors/WindVaneP.nc @@ -40,6 +40,7 @@ module WindVaneP { uses { interface Tick as Second; interface Read as Vane; + interface GeneralIO as WPower; } } implementation { @@ -164,6 +165,7 @@ implementation { task void startRead() { + call WPower.set(); call Vane.read(); } @@ -174,6 +176,7 @@ implementation { event void Vane.readDone(error_t error, uint16_t value) { + //call WPower.clr(); if (error == SUCCESS) { /* Convert the adc value (0...4095) to a compass heading * (0...COMPASS_COUNT - 1). -- 2.39.2