[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/tsb
AccelDriverC.nc, NONE, 1.1 AccelDriverM.nc, NONE,
1.1 AccelInterrupt.nc, NONE, 1.1 AccelM.nc, NONE,
1.1 PhotoDriverC.nc, NONE, 1.1 PhotoDriverM.nc, NONE,
1.1 PhotoGain.nc, NONE, 1.1 Accel.h, NONE, 1.1 Photo.h, NONE,
1.1 sensorboard.h, NONE, 1.1
Joe Polastre
jpolastre at users.sourceforge.net
Mon Feb 21 17:24:43 PST 2005
Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/tsb
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16662
Added Files:
AccelDriverC.nc AccelDriverM.nc AccelInterrupt.nc AccelM.nc
PhotoDriverC.nc PhotoDriverM.nc PhotoGain.nc Accel.h Photo.h
sensorboard.h
Log Message:
Initial checkin of Photo and Accel drivers for the Telos Sensor Board
Note that these are simply drivers--the wrapper components (PhotoC and
AccelC) that perform gain adjustment and abstract away the ADC have not
yet been written, but the full functionality (HAL style) for the sensors
is available with this commit
--- NEW FILE: AccelDriverC.nc ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
*/
/*
*
* Authors: Joe Polastre
*
* $Id: AccelDriverC.nc,v 1.1 2005/02/22 01:24:40 jpolastre Exp $
*/
includes Accel;
includes sensorboard;
configuration AccelDriverC
{
provides {
interface SplitControl;
interface ADC as AccelX;
interface ADC as AccelY;
interface AccelInterrupt;
}
}
implementation
{
components AccelDriverM, ADCC, AD5242C, MSP430InterruptC, LedsC;
AccelDriverM.Leds -> LedsC;
SplitControl = AccelDriverM;
AccelX = ADCC.ADC[TOS_ADC_ACCELX_PORT];
AccelY = ADCC.ADC[TOS_ADC_ACCELY_PORT];
AccelInterrupt = AccelDriverM;
AccelDriverM.ADCStdControl -> ADCC;
AccelDriverM.ADCControl -> ADCC;
AccelDriverM.AD5242 -> AD5242C;
AccelDriverM.AD5242Control -> AD5242C;
AccelDriverM.AccelInt -> MSP430InterruptC.Port23; // GIO2
}
--- NEW FILE: AccelDriverM.nc ---
// $Id: AccelDriverM.nc,v 1.1 2005/02/22 01:24:40 jpolastre Exp $
/*
* "Copyright (c) 2000-2005 The Regents of the University of California.
* 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*/
/**
* @author Joe Polastre
* Revision: $Revision: 1.1 $
*
*/
includes Accel;
module AccelDriverM
{
provides {
interface SplitControl;
interface AccelInterrupt;
}
uses {
interface AD5242;
interface ADCControl;
interface StdControl as ADCStdControl;
interface StdControl as PotControl;
interface StdControl as AD5242Control;
interface MSP430Interrupt as AccelInt;
interface Leds;
}
}
implementation
{
enum {
OFF = 0,
IDLE,
START,
START_O,
STOP,
STOP_O,
GAIN,
};
uint8_t state;
uint8_t gain;
task void initDone() {
signal SplitControl.initDone();
}
command result_t SplitControl.init() {
atomic {
// state is off
state = OFF;
}
call ADCStdControl.init();
call AD5242Control.init();
return post initDone();
}
command result_t SplitControl.start() {
uint8_t _state = OFF;
atomic {
if (state == OFF) {
state = START;
_state = state;
}
}
if (_state == START) {
call ADCStdControl.start();
call ADCControl.init();
if (!call ADCControl.bindPort(TOS_ADC_ACCELX_PORT,
TOSH_ACTUAL_ADC_ACCELX_PORT) ||
!call ADCControl.bindPort(TOS_ADC_ACCELY_PORT,
TOSH_ACTUAL_ADC_ACCELY_PORT)) {
state = OFF;
return FAIL;
}
TOSH_SEL_ADC0_MODFUNC();
TOSH_SEL_ADC1_MODFUNC();
call AD5242Control.start();
return call AD5242.start(AD5242_ACCEL_ADDR);
}
return FAIL;
}
event void AD5242.startDone(uint8_t _addr, result_t _result) {
uint8_t _state = OFF;
atomic {
if (state == START) {
state = START_O;
_state = state;
}
}
if (_state == START_O) {
if (!(call AD5242.setOutput2(AD5242_ACCEL_ADDR, TRUE))) {
atomic state = IDLE;
signal SplitControl.startDone();
}
}
}
command result_t SplitControl.stop() {
uint8_t _state = OFF;
atomic {
if (state == IDLE) {
state = STOP;
_state = state;
}
}
if (_state == STOP) {
// questionable whether this should be here...
call ADCStdControl.stop();
TOSH_SEL_ADC0_IOFUNC();
TOSH_SEL_ADC1_IOFUNC();
return call AD5242.stop(AD5242_ACCEL_ADDR);
}
return FAIL;
}
event void AD5242.stopDone(uint8_t _addr, result_t _result) {
uint8_t _state = OFF;
atomic {
if (state == STOP) {
state = STOP_O;
_state = state;
}
}
if (_state == STOP_O) {
if (!(call AD5242.setOutput2(AD5242_ACCEL_ADDR, FALSE))) {
atomic state = IDLE;
signal SplitControl.stopDone();
}
}
}
event void AD5242.setOutput1Done(uint8_t _addr, result_t _result) { }
event void AD5242.setPot1Done(uint8_t _addr, result_t _result) { }
event void AD5242.getPot1Done(uint8_t _addr, uint8_t _val, result_t _result) { }
event void AD5242.getPot2Done(uint8_t _addr, uint8_t _val, result_t _result) { }
event void AD5242.setPot2Done(uint8_t _addr, result_t _result) {
uint8_t _state = OFF;
atomic {
if (state == GAIN) {
_state = state;
state = IDLE;
}
}
if (_state == GAIN) {
signal AccelInterrupt.setDone(gain, _result);
}
}
event void AD5242.setOutput2Done(uint8_t _addr, result_t _result) {
uint8_t _state = OFF;
atomic {
if ((state == START_O) || (state == STOP_O)) {
_state = state;
state = IDLE;
}
}
if (_state == START_O)
signal SplitControl.startDone();
else if (_state == STOP_O) {
call AD5242Control.stop();
signal SplitControl.stopDone();
}
}
command result_t AccelInterrupt.set(uint8_t _gain) {
uint8_t _state = OFF;
atomic {
if (state == IDLE) {
state = GAIN;
_state = state;
}
}
if (_state == GAIN) {
atomic gain = _gain;
return call AD5242.setPot2(AD5242_ACCEL_ADDR, gain);
}
return FAIL;
}
default event void AccelInterrupt.setDone(uint8_t _gain, result_t _result) { }
command uint8_t AccelInterrupt.get() {
return gain;
}
async command result_t AccelInterrupt.enable() {
atomic {
TOSH_MAKE_ACCEL_INT_INPUT();
call AccelInt.disable();
call AccelInt.clear();
call AccelInt.edge(FALSE);
call AccelInt.enable();
}
return SUCCESS;
}
async command result_t AccelInterrupt.disable() {
atomic {
call AccelInt.disable();
call AccelInt.clear();
TOSH_MAKE_ACCEL_INT_OUTPUT();
}
return SUCCESS;
}
default async event void AccelInterrupt.fired() { }
async event void AccelInt.fired() {
signal AccelInterrupt.fired();
call AccelInt.clear();
}
}
--- NEW FILE: AccelInterrupt.nc ---
// $Id: AccelInterrupt.nc,v 1.1 2005/02/22 01:24:40 jpolastre Exp $
/*
* "Copyright (c) 2000-2005 The Regents of the University of California.
* 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*/
/**
* @author Joe Polastre
* Revision: $Revision: 1.1 $
*
*/
interface AccelInterrupt {
command result_t set(uint8_t gain);
event void setDone(uint8_t gain, result_t result);
command uint8_t get();
async command result_t enable();
async command result_t disable();
async event void fired();
}
--- NEW FILE: AccelM.nc ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
*/
/*
*
* Authors: Joe Polastre
*
* $Id: AccelM.nc,v 1.1 2005/02/22 01:24:40 jpolastre Exp $
*/
includes Hamamatsu;
module HamamatsuM {
provides {
interface StdControl;
}
uses {
interface ADCControl;
}
}
implementation {
command result_t StdControl.init() {
return SUCCESS;
}
command result_t StdControl.start() {
result_t ok;
atomic P6SEL |= 0x30;
ok = call ADCControl.init();
ok &= call ADCControl.bindPort(TOS_ADC_TSR_PORT,
TOSH_ACTUAL_ADC_TSR_PORT);
ok &= call ADCControl.bindPort(TOS_ADC_PAR_PORT,
TOSH_ACTUAL_ADC_PAR_PORT);
return ok;
}
command result_t StdControl.stop() {
atomic P6SEL &= ~0x30;
return SUCCESS;
}
}
--- NEW FILE: PhotoDriverC.nc ---
/* tab:4
* "Copyright (c) 2000-2003 The Regents of the University of California.
* 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
*/
/*
*
* Authors: Joe Polastre
*
* $Id: PhotoDriverC.nc,v 1.1 2005/02/22 01:24:40 jpolastre Exp $
*/
includes Photo;
includes sensorboard;
configuration PhotoDriverC
{
provides {
interface SplitControl;
interface ADC as Photo;
interface PhotoGain;
}
}
implementation
{
components PhotoDriverM, ADCC, AD5242C, LedsC;
PhotoDriverM.Leds -> LedsC;
SplitControl = PhotoDriverM;
PhotoGain = PhotoDriverM;
Photo = ADCC.ADC[TOS_ADC_PHOTO_PORT];
PhotoDriverM.ADCStdControl -> ADCC;
PhotoDriverM.ADCControl -> ADCC;
PhotoDriverM.AD5242 -> AD5242C;
PhotoDriverM.AD5242Control -> AD5242C;
}
--- NEW FILE: PhotoDriverM.nc ---
// $Id: PhotoDriverM.nc,v 1.1 2005/02/22 01:24:40 jpolastre Exp $
/*
* "Copyright (c) 2000-2005 The Regents of the University of California.
* 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*/
/**
* @author Joe Polastre
* Revision: $Revision: 1.1 $
*
*/
includes Photo;
module PhotoDriverM
{
provides {
interface SplitControl;
interface PhotoGain;
}
uses {
interface AD5242;
interface ADCControl;
interface StdControl as ADCStdControl;
interface StdControl as AD5242Control;
interface Leds;
}
}
implementation
{
enum {
OFF = 0,
IDLE,
START,
START_O,
STOP,
STOP_O,
GAIN
};
uint8_t state;
uint8_t gain;
task void initDone() {
signal SplitControl.initDone();
}
command result_t SplitControl.init() {
atomic {
// state is off
state = OFF;
// default pot state is in the middle
gain = 0xFF >> 1;
}
call ADCStdControl.init();
call AD5242Control.init();
return post initDone();
}
command result_t SplitControl.start() {
uint8_t _state = OFF;
atomic {
if (state == OFF) {
state = START;
_state = state;
}
}
if (_state == START) {
call ADCStdControl.start();
call ADCControl.init();
if (!call ADCControl.bindPort(TOS_ADC_PHOTO_PORT,
TOSH_ACTUAL_ADC_PHOTO_PORT)) {
state = OFF;
return FAIL;
}
TOSH_SEL_ADC3_MODFUNC();
call AD5242Control.start();
return call AD5242.start(AD5242_PHOTO_ADDR);
}
return FAIL;
}
event void AD5242.startDone(uint8_t _addr, result_t _result) {
uint8_t _state = OFF;
atomic {
if (state == START) {
state = START_O;
_state = state;
}
}
if (_state == START_O) {
if (!(call AD5242.setOutput1(AD5242_PHOTO_ADDR, TRUE))) {
atomic state = IDLE;
signal SplitControl.startDone();
}
}
}
command result_t SplitControl.stop() {
uint8_t _state = OFF;
atomic {
if (state == IDLE) {
state = STOP;
_state = state;
}
}
if (_state == STOP) {
// questionable whether this should be here...
// call ADCStdControl.stop();
TOSH_SEL_ADC0_IOFUNC();
TOSH_SEL_ADC1_IOFUNC();
return call AD5242.stop(AD5242_PHOTO_ADDR);
}
return FAIL;
}
event void AD5242.stopDone(uint8_t _addr, result_t _result) {
uint8_t _state = OFF;
atomic {
if (state == STOP) {
state = STOP_O;
_state = state;
}
}
if (_state == STOP_O) {
if (!(call AD5242.setOutput1(AD5242_PHOTO_ADDR, FALSE))) {
atomic state = IDLE;
signal SplitControl.stopDone();
}
}
}
event void AD5242.setOutput1Done(uint8_t _addr, result_t _result) {
uint8_t _state = OFF;
atomic {
if ((state == START_O) || (state == STOP_O)) {
_state = state;
state = IDLE;
}
}
if (_state == START_O)
signal SplitControl.startDone();
else if (_state == STOP_O) {
// turn off the potentiometer
call AD5242Control.stop();
signal SplitControl.stopDone();
}
}
event void AD5242.setPot1Done(uint8_t _addr, result_t _result) {
uint8_t _state = OFF;
atomic {
if (state == GAIN) {
_state = state;
state = IDLE;
}
}
if (_state == GAIN) {
signal PhotoGain.setDone(gain, _result);
}
}
event void AD5242.getPot1Done(uint8_t _addr, uint8_t _val, result_t _result) { }
event void AD5242.getPot2Done(uint8_t _addr, uint8_t _val, result_t _result) { }
event void AD5242.setPot2Done(uint8_t _addr, result_t _result) { }
event void AD5242.setOutput2Done(uint8_t _addr, result_t _result) {
}
command result_t PhotoGain.set(uint8_t _gain) {
uint8_t _state = OFF;
atomic {
if (state == IDLE) {
state = GAIN;
_state = state;
}
}
if (_state == GAIN) {
atomic gain = _gain;
return call AD5242.setPot1(AD5242_PHOTO_ADDR, gain);
}
return FAIL;
}
command uint8_t PhotoGain.get() {
return gain;
}
default event void PhotoGain.setDone(uint8_t _gain, uint8_t _result) { }
}
--- NEW FILE: PhotoGain.nc ---
// $Id: PhotoGain.nc,v 1.1 2005/02/22 01:24:40 jpolastre Exp $
/*
* "Copyright (c) 2000-2005 The Regents of the University of California.
* 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 THE UNIVERSITY OF CALIFORNIA 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 THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY 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 THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*/
/**
* @author Joe Polastre
* Revision: $Revision: 1.1 $
*
*/
interface PhotoGain {
/**
* Set the gain on the photodiode. The gain is a relative value between
* 0 and 255 where 0 is minimal gain and 255 is maximum gain. These values
* correspond to:
* 0 = 0 ohm resistence
* 255 = 10kohm resistence
* Since V=IR, the output voltage of the photodiode depends on the amount
* of light (I) and the gain (R).
*
* @param gain The amount of gain, relative, between 0 and 255.
*
* @return SUCCESS if the request was accepted
*/
command result_t set(uint8_t gain);
/**
* Notification that the gain of the photo sensor has been changed.
*
* @param gain New gain setting
* @param result SUCCESS if the new gain setting was successfully set,
* FAIL if the gain could not be set (then ignore "gain"
* parameter)
*/
event void setDone(uint8_t gain, result_t result);
/**
* Get the current gain of the Photo sensor.
*
* @return The current gain value between 0 and 255 where 0 is the
* minimum gain and 255 is the maximum gain.
*/
command uint8_t get();
}
--- NEW FILE: Accel.h ---
#ifndef _H_ACCEL_H
#define _H_ACCEL_H
#include "MSP430ADC12.h"
enum {
AD5242_ACCEL_ADDR = 0x02,
};
// TSR, Total Solar Radiation
enum
{
TOS_ADC_ACCELX_PORT = unique("ADCPort"),
TOS_ADC_ACCELY_PORT = unique("ADCPort"),
TOSH_ACTUAL_ADC_ACCELX_PORT = ASSOCIATE_ADC_CHANNEL(
INPUT_CHANNEL_A0,
REFERENCE_AVcc_AVss,
REFVOLT_LEVEL_2_5
),
TOSH_ACTUAL_ADC_ACCELY_PORT = ASSOCIATE_ADC_CHANNEL(
INPUT_CHANNEL_A1,
REFERENCE_AVcc_AVss,
REFVOLT_LEVEL_2_5
),
};
#endif
--- NEW FILE: Photo.h ---
#ifndef _H_PHOTO_H
#define _H_PHOTO_H
#include "MSP430ADC12.h"
enum {
AD5242_PHOTO_ADDR = 0x02,
};
// TSR, Total Solar Radiation
enum
{
TOS_ADC_PHOTO_PORT = unique("ADCPort"),
TOSH_ACTUAL_ADC_PHOTO_PORT = ASSOCIATE_ADC_CHANNEL(
INPUT_CHANNEL_A3,
REFERENCE_VREFplus_AVss,
REFVOLT_LEVEL_1_5
)
};
#endif
--- NEW FILE: sensorboard.h ---
#ifndef _H_sensorboard_h
#define _H_sensorboard_h
#include "msp430hardware.h"
// sensorboard dependent connection of AD524X shutdown pin
TOSH_ASSIGN_PIN(AD524X_SD, 3, 5);
// Accel interrupt pin
TOSH_ASSIGN_PIN(ACCEL_INT, 2, 3);
#endif
More information about the Tinyos-beta-commits
mailing list