[Tinyos-2-commits] CVS: tinyos-2.x/tos/sensorboards/mts300
AccelC.nc, NONE, 1.1 Mag.nc, NONE, 1.1 MagC.nc, NONE,
1.1 MagConfigP.nc, NONE, 1.1 MagP.nc, NONE, 1.1 Mic.nc, 1.2,
1.3 MicC.nc, NONE, 1.1 MicDeviceP.nc, NONE,
1.1 MicInterrupt.nc, NONE, 1.1 MicP.nc, NONE,
1.1 PhotoTempDeviceP.nc, NONE, 1.1 TempC.nc, NONE, 1.1
Pi Peng
pipeng at users.sourceforge.net
Thu Feb 15 02:33:40 PST 2007
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/sensorboards/mts300 .sensor,
1.5, 1.6 AccelConfigP.nc, 1.1, 1.2 AccelP.nc, 1.1,
1.2 PhotoC.nc, 1.1, 1.2 PhotoTempP.nc, 1.1,
1.2 SensorMts300C.nc, 1.4, 1.5 SensorMts300P.nc, 1.4,
1.5 SounderC.nc, 1.1, 1.2 SounderP.nc, 1.1, 1.2 mts300.h, 1.1, 1.2
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/sensorboards/mts300
AccelReadP.nc, 1.1, NONE AccelReadStreamP.nc, 1.1,
NONE AccelXC.nc, 1.1, NONE AccelXStreamC.nc, 1.1,
NONE AccelYC.nc, 1.1, NONE AccelYStreamC.nc, 1.1,
NONE ArbitratedPhotoDeviceP.nc, 1.1, NONE DemoSensorC.nc, 1.1,
NONE DemoSensorStreamC.nc, 1.1, NONE Mts300Sounder.nc, 1.1,
NONE PhotoConfigP.nc, 1.1, NONE PhotoTempControlP.nc, 1.1,
NONE PhotoTempDeviceC.nc, 1.1, NONE PhotoTempSetupP.nc, 1.1,
NONE WireAccelP.nc, 1.1, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/tos/sensorboards/mts300
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv321
Added Files:
AccelC.nc Mag.nc MagC.nc MagConfigP.nc MagP.nc Mic.nc MicC.nc
MicDeviceP.nc MicInterrupt.nc MicP.nc PhotoTempDeviceP.nc
TempC.nc
Log Message:
Add mic and mag driver .
--- NEW FILE: AccelC.nc ---
// $Id: AccelC.nc,v 1.1 2007/02/15 10:33:37 pipeng Exp $
/* 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."
*
* Copyright (c) 2002-2003 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.
*/
#include "mts300.h"
generic configuration AccelC ()
{
provides interface Init;
provides interface StdControl;
provides interface Read<uint16_t> as AccelX;
provides interface Read<uint16_t> as AccelY;
}
implementation
{
components AccelConfigP,
new AdcReadClientC() as AdcX,
new AdcReadClientC() as AdcY;
Init = AccelConfigP;
StdControl = AccelConfigP;
AccelX = AdcX;
AdcX.Atm128AdcConfig -> AccelConfigP.ConfigX;
AdcX.ResourceConfigure -> AccelConfigP.ResourceX;
AccelY = AdcY;
AdcY.Atm128AdcConfig -> AccelConfigP.ConfigY;
AdcY.ResourceConfigure -> AccelConfigP.ResourceY;
}
--- NEW FILE: Mag.nc ---
// $Id: Mag.nc,v 1.1 2007/02/15 10:33:37 pipeng Exp $
/* 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."
*
* Copyright (c) 2002-2003 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.
*/
/*
* Authors: Alec Woo
* Date lase modified: 8/20/02
*
* The MagSetting inteface provides an asynchronous mechanism for
* setting the gain offset for the Magnetometer on the mica sensorboard.
* This is particularly useful in calibrating the offset of the Magnetometer
* such that X and Y axis can stay in the center for idle signals.
* If not calibrated, the data you get may rail. (railing means
* the data either stays at the maximum (~785) or minimum (~240)).
*
* The gain adjust has 256 steps ranging from 0 to 255.
*
*/
/**
* @author Alec Woo
*/
interface Mag {
/* Effects: adjust pot setting on the X axis of the magnetometer.
* Returns: return SUCCESS of FAILED.
*/
command error_t gainAdjustX(uint8_t val);
/* Effects: adjust pot setting on the Y axis of the magnetometer.
* Returns: return SUCCESS of FAILED.
*/
command error_t gainAdjustY(uint8_t val);
/* Pot adjustment on the X axis of the magnetometer is finished.
* Returns: return SUCCESS.
*/
event error_t gainAdjustXDone(bool result);
/* Pot adjustment on the Y axis of the magnetometer is finished.
* Returns: return SUCCESS.
*/
event error_t gainAdjustYDone(bool result);
}
--- NEW FILE: MagC.nc ---
// $Id: MagC.nc,v 1.1 2007/02/15 10:33:37 pipeng Exp $
/* 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."
*
* Copyright (c) 2002-2003 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.
*/
#include "mts300.h"
generic configuration MagC ()
{
provides interface Init;
provides interface StdControl;
provides interface Read<uint16_t> as MagX;
provides interface Read<uint16_t> as MagY;
provides interface Mag;
}
implementation
{
components MagConfigP,
new AdcReadClientC() as AdcX,
new AdcReadClientC() as AdcY;
Init = MagConfigP;
StdControl = MagConfigP;
Mag = MagConfigP;
MagX = AdcX;
AdcX.Atm128AdcConfig -> MagConfigP.ConfigX;
AdcX.ResourceConfigure -> MagConfigP.ResourceX;
MagY = AdcY;
AdcY.Atm128AdcConfig -> MagConfigP.ConfigY;
AdcY.ResourceConfigure -> MagConfigP.ResourceY;
}
--- NEW FILE: MagConfigP.nc ---
/* $Id: MagConfigP.nc,v 1.1 2007/02/15 10:33:37 pipeng 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.
*/
/**
* 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"
#include "I2C.h"
configuration MagConfigP {
provides {
interface Init;
interface StdControl;
interface Mag;
interface Atm128AdcConfig as ConfigX;
interface Atm128AdcConfig as ConfigY;
interface ResourceConfigure as ResourceX;
interface ResourceConfigure as ResourceY;
}
}
implementation {
components MagP, MicaBusC, new Atm128I2CMasterC() as I2CPot;
Init = MagP;
StdControl = MagP;
Mag = MagP;
ConfigX = MagP.ConfigX;
ConfigY = MagP.ConfigY;
ResourceX = MagP.ResourceX;
ResourceY = MagP.ResourceY;
MagP.I2CPacket -> I2CPot;
MagP.Resource -> I2CPot;
MagP.MagPower -> MicaBusC.PW5;
MagP.MagAdcX -> MicaBusC.Adc6;
MagP.MagAdcY -> MicaBusC.Adc5;
}
--- NEW FILE: MagP.nc ---
#include "mts300.h"
#include "Timer.h"
#include "I2C.h"
module MagP
{
provides interface Init;
provides interface StdControl;
provides interface Mag;
provides interface Atm128AdcConfig as ConfigX;
provides interface Atm128AdcConfig as ConfigY;
provides interface ResourceConfigure as ResourceX;
provides interface ResourceConfigure as ResourceY;
uses interface GeneralIO as MagPower;
uses interface MicaBusAdc as MagAdcX;
uses interface MicaBusAdc as MagAdcY;
uses interface I2CPacket<TI2CBasicAddr>;
uses interface Resource;
}
implementation
{
uint8_t gainData[2];
command error_t Init.init()
{
call MagPower.makeOutput();
call MagPower.clr();
return SUCCESS;
}
command error_t StdControl.start()
{
call MagPower.set();
return SUCCESS;
}
command error_t StdControl.stop()
{
call MagPower.clr();
call MagPower.makeInput();
return SUCCESS;
}
command error_t Mag.gainAdjustX(uint8_t val)
{
gainData[0] = 1; // pot subaddr
gainData[1] = val; // value to write
return call Resource.request();
}
command error_t Mag.gainAdjustY(uint8_t val)
{
gainData[0] = 0; // pot subaddr
gainData[1] = val; // value to write
return call Resource.request();
}
/**
* Resource request
*
*/
event void Resource.granted()
{
if ( call I2CPacket.write(0x3,TOS_MAG_POT_ADDR, 2, gainData) == SUCCESS)
{
return ;
}
}
/**
* I2CPot2
*
*/
async event void I2CPacket.readDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
{
return ;
}
async event void I2CPacket.writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
{
call Resource.release();
if (gainData[0] ==1)
{
signal Mag.gainAdjustXDone(error);
}
if (gainData[0] ==0)
{
signal Mag.gainAdjustYDone(error);
}
return ;
}
async command uint8_t ConfigX.getChannel() {
return call MagAdcX.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 MagAdcY.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() {}
}
--- NEW FILE: MicC.nc ---
/**
* 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 <husq at xbow.com>
*
* $Id: MicC.nc,v 1.1 2007/02/15 10:33:38 pipeng Exp $
*/
#include "mts300.h"
generic configuration MicC() {
provides interface Init;
provides interface StdControl;
provides interface Read<uint16_t>;
provides interface Mic;
provides interface MicInterrupt;
}
implementation {
components new AdcReadClientC(), MicDeviceP;
Init = MicDeviceP;
StdControl = MicDeviceP;
Read = AdcReadClientC;
Mic = MicDeviceP;
MicInterrupt = MicDeviceP;
AdcReadClientC.Atm128AdcConfig -> MicDeviceP;
AdcReadClientC.ResourceConfigure -> MicDeviceP;
}
--- NEW FILE: MicDeviceP.nc ---
/**
* 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 <husq at xbow.com>
*
* $Id: MicDeviceP.nc,v 1.1 2007/02/15 10:33:38 pipeng Exp $
*/
#include "mts300.h"
#include "I2C.h"
configuration MicDeviceP {
provides {
interface Init;
interface StdControl;
interface Mic;
interface MicInterrupt;
interface ResourceConfigure;
interface Atm128AdcConfig;
}
}
implementation {
components MicP, MicaBusC, HplAtm128GeneralIOC as Pins,
HplAtm128InterruptC as IntPins, LedsC, NoLedsC,
new Atm128I2CMasterC() as I2CPot;
Init = MicP;
StdControl = MicP;
ResourceConfigure = MicP;
Atm128AdcConfig = MicP;
Mic = MicP;
MicInterrupt = MicP;
MicP.MicPower -> MicaBusC.PW3;
MicP.MicMuxSel -> MicaBusC.PW6;
MicP.MicAdc -> MicaBusC.Adc2;
MicP.I2CPacket -> I2CPot;
MicP.Resource -> I2CPot;
MicP.AlertInterrupt -> IntPins.Int7;
MicP.DebugLeds -> NoLedsC;
}
--- NEW FILE: MicInterrupt.nc ---
// $Id: MicInterrupt.nc,v 1.1 2007/02/15 10:33:38 pipeng Exp $
/* 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."
*
* Copyright (c) 2002-2003 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.
*/
/*
* Authors: Alec Woo
* Date last modified: 8/20/02
*
* The microphone on the mica sensor board has the tone detector interrupt.
* If an audio signal at 4.3kHz is picked up by the microphone, the tone
* detect will decode it and generate a toneDetected interrupt if the
* interrupt is enabled.
*
*/
/**
* @author Alec Woo
*/
interface MicInterrupt
{
/* Effects: disable interrupts
Returns: SUCCESS
*/
async command error_t disable();
/* Effects: enable interrupts
Returns: SUCCESS
*/
async command error_t enable();
/* Interrupt signal for tone detected. Note that MicInterrupt is automatically disabled
* before this event is signaled. (Upper layer needs to reenable this interrupt for future
* tone detect.
*
* Returns: SUCCESS
*/
async event error_t toneDetected();
}
--- NEW FILE: MicP.nc ---
/**
* 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 <husq at xbow.com>
*
* $Id: MicP.nc,v 1.1 2007/02/15 10:33:38 pipeng Exp $
*/
#include "Timer.h"
#include "I2C.h"
module MicP
{
provides interface Init;
provides interface StdControl;
provides interface Mic;
provides interface MicInterrupt;
provides interface ResourceConfigure as MicResourceConfigure;
provides interface Atm128AdcConfig as MicAtm128AdcConfig;
uses interface Leds as DebugLeds;
uses interface GeneralIO as MicPower;
uses interface GeneralIO as MicMuxSel;
uses interface MicaBusAdc as MicAdc;
uses interface I2CPacket<TI2CBasicAddr>;
uses interface Resource;
uses interface HplAtm128Interrupt as AlertInterrupt;
}
implementation
{
uint8_t gainData[2];
command error_t Init.init()
{
call MicPower.makeOutput();
call MicPower.clr();
call MicMuxSel.makeOutput();
call MicMuxSel.clr();
call AlertInterrupt.disable();
return SUCCESS;
}
command error_t StdControl.start()
{
call MicPower.set();
return SUCCESS;
}
command error_t StdControl.stop()
{
call AlertInterrupt.disable();
call MicPower.clr();
call MicPower.makeInput();
return SUCCESS;
}
/**
* Resource request
*
*/
event void Resource.granted()
{
call DebugLeds.led0Off();
if ( call I2CPacket.write(0x3,TOS_MIC_POT_ADDR, 2, gainData) == SUCCESS)
{
call DebugLeds.led1On();
};
}
/**
* mic control
*
*/
command error_t Mic.muxSel(uint8_t sel)
{
if (sel == 0)
{
call MicMuxSel.clr();
return SUCCESS;
}
else if (sel == 1)
{
call MicMuxSel.set();
return SUCCESS;
}
return FAIL;
}
command error_t Mic.gainAdjust(uint8_t val)
{
call DebugLeds.led0On();
gainData[0] = 0; // pot subaddr
gainData[1] = val; // value to write
return call Resource.request();
}
command uint8_t Mic.readToneDetector()
{
bool bVal = call AlertInterrupt.getValue();
return bVal ? 1 : 0;
}
/**
* mic interrupt control
*
*/
async command error_t MicInterrupt.enable()
{
call AlertInterrupt.enable();
return SUCCESS;
}
async command error_t MicInterrupt.disable()
{
call AlertInterrupt.disable();
return SUCCESS;
}
default async event error_t MicInterrupt.toneDetected()
{
return SUCCESS;
}
async event void AlertInterrupt.fired()
{
signal MicInterrupt.toneDetected();
}
/**
*
*
*/
async command uint8_t MicAtm128AdcConfig.getChannel()
{
return call MicAdc.getChannel();
}
async command uint8_t MicAtm128AdcConfig.getRefVoltage()
{
return ATM128_ADC_VREF_OFF;
}
async command uint8_t MicAtm128AdcConfig.getPrescaler()
{
return ATM128_ADC_PRESCALE;
}
async command void MicResourceConfigure.configure()
{
call MicPower.set();
}
async command void MicResourceConfigure.unconfigure()
{
// call MicPower.clr();
}
/**
* I2CPot2
*
*/
async event void I2CPacket.readDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
{
return ;
}
async event void I2CPacket.writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
{
call DebugLeds.led1Off();
call Resource.release();
return ;
}
}
--- NEW FILE: PhotoTempDeviceP.nc ---
/* $Id: PhotoTempDeviceP.nc,v 1.1 2007/02/15 10:33:38 pipeng 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.
*/
/**
* 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 PhotoTempDeviceP
{
provides
{
interface Init;
interface StdControl;
interface ResourceConfigure as PhotoResourceConfigure;
interface Atm128AdcConfig as PhotoAtm128AdcConfig;
interface ResourceConfigure as TempResourceConfigure;
interface Atm128AdcConfig as TempAtm128AdcConfig;
}
}
implementation
{
components PhotoTempP, MicaBusC, HplAtm128GeneralIOC as Pins;
// components new FcfsArbiterC(MTS3X0_PHOTO_TEMP) as Arbiter;
components LedsC, NoLedsC;
Init = PhotoTempP;
StdControl = PhotoTempP;
PhotoResourceConfigure = PhotoTempP.PhotoResourceConfigure;
PhotoAtm128AdcConfig = PhotoTempP.PhotoAtm128AdcConfig;
TempResourceConfigure = PhotoTempP.TempResourceConfigure;
TempAtm128AdcConfig = PhotoTempP.TempAtm128AdcConfig;
PhotoTempP.LightPower -> Pins.PortE5;
PhotoTempP.TempPower -> Pins.PortE6;
PhotoTempP.SensorAdc -> MicaBusC.Adc1;
DEBUG_LEDS(PhotoTempP);
}
--- NEW FILE: TempC.nc ---
/**
* 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 <husq at xbow.com>
*
* $Id: TempC.nc,v 1.1 2007/02/15 10:33:38 pipeng Exp $
*/
#include "mts300.h"
generic configuration TempC() {
provides interface Read<uint16_t>;
}
implementation {
components new AdcReadClientC(), PhotoTempDeviceP;
Read = AdcReadClientC;
AdcReadClientC.Atm128AdcConfig -> PhotoTempDeviceP.TempAtm128AdcConfig;
AdcReadClientC.ResourceConfigure -> PhotoTempDeviceP.TempResourceConfigure;
}
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/sensorboards/mts300 .sensor,
1.5, 1.6 AccelConfigP.nc, 1.1, 1.2 AccelP.nc, 1.1,
1.2 PhotoC.nc, 1.1, 1.2 PhotoTempP.nc, 1.1,
1.2 SensorMts300C.nc, 1.4, 1.5 SensorMts300P.nc, 1.4,
1.5 SounderC.nc, 1.1, 1.2 SounderP.nc, 1.1, 1.2 mts300.h, 1.1, 1.2
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/sensorboards/mts300
AccelReadP.nc, 1.1, NONE AccelReadStreamP.nc, 1.1,
NONE AccelXC.nc, 1.1, NONE AccelXStreamC.nc, 1.1,
NONE AccelYC.nc, 1.1, NONE AccelYStreamC.nc, 1.1,
NONE ArbitratedPhotoDeviceP.nc, 1.1, NONE DemoSensorC.nc, 1.1,
NONE DemoSensorStreamC.nc, 1.1, NONE Mts300Sounder.nc, 1.1,
NONE PhotoConfigP.nc, 1.1, NONE PhotoTempControlP.nc, 1.1,
NONE PhotoTempDeviceC.nc, 1.1, NONE PhotoTempSetupP.nc, 1.1,
NONE WireAccelP.nc, 1.1, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list