[Tinyos-2-commits] CVS: tinyos-2.x/tos/sensorboards/mda100
ArbitratedPhotoDeviceP.nc, NONE, 1.1 ArbitratedTempDeviceP.nc,
NONE, 1.1 DemoSensorC.nc, NONE, 1.1 mda100.h, NONE,
1.1 PhotoC.nc, NONE, 1.1 PhotoImplP.nc, NONE,
1.1 PhotoTempConfigC.nc, NONE, 1.1 PhotoTempConfigP.nc, NONE,
1.1 SharedAnalogDeviceC.nc, NONE, 1.1 SharedAnalogDeviceP.nc,
NONE, 1.1 TempC.nc, NONE, 1.1
Kevin Klues
klueska at users.sourceforge.net
Mon Aug 20 21:44:12 PDT 2007
Update of /cvsroot/tinyos/tinyos-2.x/tos/sensorboards/mda100
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv15954/tos/sensorboards/mda100
Added Files:
ArbitratedPhotoDeviceP.nc ArbitratedTempDeviceP.nc
DemoSensorC.nc mda100.h PhotoC.nc PhotoImplP.nc
PhotoTempConfigC.nc PhotoTempConfigP.nc SharedAnalogDeviceC.nc
SharedAnalogDeviceP.nc TempC.nc
Log Message:
Initial checkin of driver for the mda100ca/cb sensorboard. Devices attached to the prototype portion of the board should have drivers that follow a similar implementation pattern as the ones for the Photo and Temperature sensors.
--- NEW FILE: ArbitratedPhotoDeviceP.nc ---
/*
* Copyright (c) 2007 Stanford University.
* 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 the Stanford University 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 STANFORD
* UNIVERSITY OR ITS 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.
*/
/**
* @author Kevin Klues <klueska at cs.stanford.edu>
* @date August 20th, 2007
*/
configuration ArbitratedPhotoDeviceP
{
provides interface Read<uint16_t>[uint8_t client];
}
implementation
{
components PhotoImplP,
new ArbitratedReadC(uint16_t) as ArbitrateRead;
Read = ArbitrateRead;
ArbitrateRead.Service -> PhotoImplP.Read;
ArbitrateRead.Resource -> PhotoImplP.Resource;
}
--- NEW FILE: ArbitratedTempDeviceP.nc ---
/*
* Copyright (c) 2007 Stanford University.
* 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 the Stanford University 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 STANFORD
* UNIVERSITY OR ITS 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.
*/
/**
* @author Kevin Klues <klueska at cs.stanford.edu>
* @date August 20th, 2007
*/
configuration ArbitratedTempDeviceP
{
provides interface Read<uint16_t>[uint8_t client];
}
implementation
{
components TempImplP,
new ArbitratedReadC(uint16_t) as ArbitrateRead;
Read = ArbitrateRead;
ArbitrateRead.Service -> TempImplP.Read;
ArbitrateRead.Resource -> TempImplP.Resource;
}
--- NEW FILE: DemoSensorC.nc ---
/* $Id: DemoSensorC.nc,v 1.1 2007/08/21 04:44:09 klueska Exp $
* Copyright (c) 2005 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.
*/
/**
* Demo sensor for basicsb sensorboard.
*
* @author David Gay
*/
generic configuration DemoSensorC() {
provides interface Read<uint16_t>;
}
implementation {
components new PhotoC() as Sensor;
Read = Sensor;
}
--- NEW FILE: mda100.h ---
/*
* Copyright (c) 2007 Stanford University.
* 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 the Stanford University 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 STANFORD
* UNIVERSITY OR ITS 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.
*/
/**
* @author Kevin Klues <klueska at cs.stanford.edu>
* @date August 20th, 2007
*/
#ifndef _MDA100_H
#define _MDA100_H
#define UQ_MDA100_PHOTO_RESOURCE "mda100.photo"
#define UQ_MDA100_TEMP_RESOURCE "mda100.temp"
#endif /* _MDA100_H */
--- NEW FILE: PhotoC.nc ---
/* $Id: PhotoC.nc,v 1.1 2007/08/21 04:44:09 klueska Exp $
* 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.
*/
/**
* Photodiode of the mda100 sensor board.
*
* @author David Gay
*/
#include "mda100.h"
generic configuration PhotoC() {
provides interface Read<uint16_t>;
}
implementation {
components ArbitratedPhotoDeviceP;
Read = ArbitratedPhotoDeviceP.Read[unique(UQ_MDA100_PHOTO_RESOURCE)];
}
--- NEW FILE: PhotoImplP.nc ---
/*
* Copyright (c) 2007 Stanford University.
* 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 the Stanford University 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 STANFORD
* UNIVERSITY OR ITS 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.
*/
/**
* @author Kevin Klues <klueska at cs.stanford.edu>
* @date August 20th, 2007
*/
#include "mda100.h"
configuration PhotoImplP {
provides {
interface Resource[uint8_t];
interface Read<uint16_t>[uint8_t];
}
}
implementation {
components new SharedAnalogDeviceC(UQ_MDA100_PHOTO_RESOURCE, 10);
components MicaBusC;
components PhotoTempConfigC as PhotoConfigC;
Resource = SharedAnalogDeviceC;
Read = SharedAnalogDeviceC;
SharedAnalogDeviceC.AdcConfig -> PhotoConfigC;
SharedAnalogDeviceC.EnablePin -> MicaBusC.Int1;
}
--- NEW FILE: PhotoTempConfigC.nc ---
/*
* Copyright (c) 2007 Stanford University.
* 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 the Stanford University 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 STANFORD
* UNIVERSITY OR ITS 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.
*/
/**
* @author Kevin Klues <klueska at cs.stanford.edu>
* @date August 20th, 2007
*/
configuration PhotoTempConfigC {
provides interface Atm128AdcConfig;
}
implementation {
components PhotoTempConfigP;
components MicaBusC;
Atm128AdcConfig = PhotoTempConfigP;
PhotoTempConfigP.PhotoTempAdc -> MicaBusC.Adc1;
}
--- NEW FILE: PhotoTempConfigP.nc ---
/* $Id: PhotoTempConfigP.nc,v 1.1 2007/08/21 04:44:09 klueska Exp $
* 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.
*/
/**
* MDA100 photo and temp sensor ADC configuration.
* @author David Gay <david.e.gay at intel.com>
*/
module PhotoTempConfigP
{
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;
}
}
--- NEW FILE: SharedAnalogDeviceC.nc ---
/*
* Copyright (c) 2007 Stanford University.
* 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 the Stanford University 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 STANFORD
* UNIVERSITY OR ITS 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.
*/
/**
* @author Kevin Klues <klueska at cs.stanford.edu>
* @date August 20th, 2007
*/
generic configuration SharedAnalogDeviceC(char resourceName[], uint32_t startup_delay) {
provides {
interface Resource[uint8_t];
interface Read<uint16_t>[uint8_t];
}
uses {
interface Atm128AdcConfig as AdcConfig;
interface GeneralIO as EnablePin;
}
}
implementation {
components new RoundRobinArbiterC(resourceName) as Arbiter;
components new SplitControlPowerManagerC() as PowerManager;
components new SharedAnalogDeviceP(startup_delay) as AnalogDevice;
components new AdcReadNowClientC() as Adc;
components new TimerMilliC();
Resource = Arbiter;
Read = AnalogDevice;
PowerManager.ArbiterInfo -> Arbiter;
PowerManager.SplitControl -> AnalogDevice;
PowerManager.ResourceDefaultOwner -> Arbiter;
AnalogDevice.ActualRead -> Adc;
AnalogDevice.Timer -> TimerMilliC;
AnalogDevice.AnalogDeviceResource -> Adc;
Adc.Atm128AdcConfig = AdcConfig;
AnalogDevice.EnablePin = EnablePin;
}
--- NEW FILE: SharedAnalogDeviceP.nc ---
/*
* Copyright (c) 2007 Stanford University.
* 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 the Stanford University 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 STANFORD
* UNIVERSITY OR ITS 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.
*/
/**
* @author Kevin Klues <klueska at cs.stanford.edu>
* @date August 20th, 2007
*/
generic module SharedAnalogDeviceP(uint32_t startup_delay) {
provides {
interface SplitControl;
interface Read<uint16_t>[uint8_t];
}
uses {
interface Resource as AnalogDeviceResource;
interface Timer<TMilli>;
interface GeneralIO as EnablePin;
interface ReadNow<uint16_t> as ActualRead;
}
}
implementation {
bool started = FALSE;
bool busy = FALSE;
uint8_t client_id;
norace error_t read_result;
norace uint16_t read_val;
command error_t SplitControl.start() {
error_t error;
if(started == FALSE) {
error = call AnalogDeviceResource.request();
if(error == SUCCESS)
started = TRUE;
return error;
}
return FAIL;
}
event void AnalogDeviceResource.granted() {
call EnablePin.makeOutput();
call EnablePin.set();
call Timer.startOneShot(startup_delay);
}
event void Timer.fired() {
signal SplitControl.startDone(SUCCESS);
}
task void stopDone() {
call AnalogDeviceResource.release();
started = FALSE;
signal SplitControl.stopDone(SUCCESS);
}
command error_t SplitControl.stop() {
if(started == TRUE) {
call EnablePin.clr();
call EnablePin.makeInput();
post stopDone();
return SUCCESS;
}
else if(busy == TRUE)
return EBUSY;
return FAIL;
}
command error_t Read.read[uint8_t id]() {
error_t error;
if(call AnalogDeviceResource.isOwner() && busy == FALSE) {
error = call ActualRead.read();
if(error == SUCCESS) {
busy = TRUE;
client_id = id;
}
return error;
}
return FAIL;
}
task void readDoneTask() {
busy = FALSE;
signal Read.readDone[client_id](read_result, read_val);
}
async event void ActualRead.readDone(error_t result, uint16_t val) {
read_result = result;
read_val = val;
post readDoneTask();
}
}
--- NEW FILE: TempC.nc ---
/* $Id: TempC.nc,v 1.1 2007/08/21 04:44:09 klueska Exp $
* 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.
*/
/**
* Photodiode of the mda100 sensor board.
*
* @author David Gay
*/
#include "mda100.h"
generic configuration TempC() {
provides interface Read<uint16_t>;
}
implementation {
components ArbitratedTempDeviceP;
Read = ArbitratedTempDeviceP.Read[unique(UQ_MDA100_TEMP_RESOURCE)];
}
More information about the Tinyos-2-commits
mailing list