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 */
*/
/**
- * HAL layer for the wind vane sensor.
+ * HAL layer for the wind vane sensor provides a power control.
*
* @author R. Steve McKown <rsmckown@gmail.com>
*/
-#include "WindVane.h"
-
configuration HalWindVaneC {
- provides interface AsyncGet<uint8_t>;
+ 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;
}
+++ /dev/null
-/*
- * 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 <rsmckown@gmail.com>
- */
-
-#include "WindVane.h"
-
-module HalWindVaneP {
- provides {
- interface Init;
- interface AsyncGet<uint8_t> 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;
- }
-}
* 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,
components new WindVaneAdcC();
WindVaneP.Vane -> WindVaneAdcC.Read;
+
+ components HalWindVaneC;
+ WindVaneP.WPower -> HalWindVaneC;
}
uses {
interface Tick as Second;
interface Read<uint16_t> as Vane;
+ interface GeneralIO as WPower;
}
}
implementation {
task void startRead()
{
+ call WPower.set();
call Vane.read();
}
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).