From 9e324ad44418812d23f20217304562367444f451 Mon Sep 17 00:00:00 2001 From: idgay Date: Thu, 8 Feb 2007 17:55:35 +0000 Subject: [PATCH] mts300 support, a work in progress - accelerometer (with warmup, unlike 1.x...), photo, temperature, sounder support --- tos/sensorboards/mts300/.sensor | 1 - tos/sensorboards/mts300/AccelConfigP.nc | 41 ++++++++++ tos/sensorboards/mts300/AccelP.nc | 76 +++++++++++++++++++ tos/sensorboards/mts300/AccelReadP.nc | 26 +++++++ tos/sensorboards/mts300/AccelReadStreamP.nc | 29 +++++++ tos/sensorboards/mts300/AccelXC.nc | 25 ++++++ tos/sensorboards/mts300/AccelXStreamC.nc | 30 ++++++++ tos/sensorboards/mts300/AccelYC.nc | 25 ++++++ tos/sensorboards/mts300/AccelYStreamC.nc | 30 ++++++++ .../mts300/ArbitratedPhotoDeviceP.nc | 13 ++++ tos/sensorboards/mts300/DemoSensorC.nc | 23 ++++++ tos/sensorboards/mts300/DemoSensorStreamC.nc | 23 ++++++ tos/sensorboards/mts300/Mts300Sounder.nc | 4 + tos/sensorboards/mts300/PhotoC.nc | 25 ++++++ tos/sensorboards/mts300/PhotoConfigP.nc | 6 ++ tos/sensorboards/mts300/PhotoTempControlP.nc | 55 ++++++++++++++ tos/sensorboards/mts300/PhotoTempDeviceC.nc | 45 +++++++++++ tos/sensorboards/mts300/PhotoTempP.nc | 32 ++++++++ tos/sensorboards/mts300/PhotoTempSetupP.nc | 25 ++++++ tos/sensorboards/mts300/SounderC.nc | 12 +++ tos/sensorboards/mts300/SounderP.nc | 31 ++++++++ tos/sensorboards/mts300/WireAccelP.nc | 35 +++++++++ 22 files changed, 611 insertions(+), 1 deletion(-) create mode 100644 tos/sensorboards/mts300/AccelConfigP.nc create mode 100644 tos/sensorboards/mts300/AccelP.nc create mode 100644 tos/sensorboards/mts300/AccelReadP.nc create mode 100644 tos/sensorboards/mts300/AccelReadStreamP.nc create mode 100644 tos/sensorboards/mts300/AccelXC.nc create mode 100644 tos/sensorboards/mts300/AccelXStreamC.nc create mode 100644 tos/sensorboards/mts300/AccelYC.nc create mode 100644 tos/sensorboards/mts300/AccelYStreamC.nc create mode 100644 tos/sensorboards/mts300/ArbitratedPhotoDeviceP.nc create mode 100644 tos/sensorboards/mts300/DemoSensorC.nc create mode 100644 tos/sensorboards/mts300/DemoSensorStreamC.nc create mode 100644 tos/sensorboards/mts300/Mts300Sounder.nc create mode 100644 tos/sensorboards/mts300/PhotoC.nc create mode 100644 tos/sensorboards/mts300/PhotoConfigP.nc create mode 100644 tos/sensorboards/mts300/PhotoTempControlP.nc create mode 100644 tos/sensorboards/mts300/PhotoTempDeviceC.nc create mode 100644 tos/sensorboards/mts300/PhotoTempP.nc create mode 100644 tos/sensorboards/mts300/PhotoTempSetupP.nc create mode 100644 tos/sensorboards/mts300/SounderC.nc create mode 100644 tos/sensorboards/mts300/SounderP.nc create mode 100644 tos/sensorboards/mts300/WireAccelP.nc diff --git a/tos/sensorboards/mts300/.sensor b/tos/sensorboards/mts300/.sensor index 125b3ef2..b67f0304 100644 --- a/tos/sensorboards/mts300/.sensor +++ b/tos/sensorboards/mts300/.sensor @@ -11,5 +11,4 @@ # push( @includes, qw( %T/sensorboards/mts300 -# %T/chips/atm128/adc ) ); diff --git a/tos/sensorboards/mts300/AccelConfigP.nc b/tos/sensorboards/mts300/AccelConfigP.nc new file mode 100644 index 00000000..d5546411 --- /dev/null +++ b/tos/sensorboards/mts300/AccelConfigP.nc @@ -0,0 +1,41 @@ +/* $Id$ + * 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 + */ + +configuration AccelConfigP { + provides { + interface Resource[uint8_t client]; + interface Atm128AdcConfig as ConfigX; + interface Atm128AdcConfig as ConfigY; + } +} +implementation { + components AccelP, MicaBusC, new TimerMilliC() as WarmupTimer, + new RoundRobinArbiterC(UQ_ACCEL_RESOURCE) as Arbiter, + new SplitControlPowerManagerC() as PowerManager; + + Resource = Arbiter; + ConfigX = AccelP.ConfigX; + ConfigY = AccelP.ConfigY; + + PowerManager.ResourceDefaultOwner -> Arbiter; + PowerManager.ArbiterInfo -> Arbiter; + PowerManager.SplitControl -> AccelP; + + AccelP.Timer -> WarmupTimer; + AccelP.AccelPin -> MicaBusC.PW4; + AccelP.AccelAdcX -> MicaBusC.Adc3; + AccelP.AccelAdcY -> MicaBusC.Adc4; +} diff --git a/tos/sensorboards/mts300/AccelP.nc b/tos/sensorboards/mts300/AccelP.nc new file mode 100644 index 00000000..c3742a78 --- /dev/null +++ b/tos/sensorboards/mts300/AccelP.nc @@ -0,0 +1,76 @@ +/* $Id$ + * 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. + */ +/** + * ADXL202JE accelerometer ADC configuration and power management. + * @author David Gay + */ +module AccelP +{ + provides { + interface SplitControl; + interface Atm128AdcConfig as ConfigX; + interface Atm128AdcConfig as ConfigY; + } + uses { + interface Timer; + interface GeneralIO as AccelPin; + interface MicaBusAdc as AccelAdcX; + interface MicaBusAdc as AccelAdcY; + } +} +implementation +{ + async command uint8_t ConfigX.getChannel() { + return call AccelAdcX.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 AccelAdcY.getChannel(); + } + + async command uint8_t ConfigY.getRefVoltage() { + return ATM128_ADC_VREF_OFF; + } + + async command uint8_t ConfigY.getPrescaler() { + return ATM128_ADC_PRESCALE; + } + + command error_t SplitControl.start() { + call AccelPin.makeOutput(); + call AccelPin.set(); + /* Startup time is 16.3ms for 0.1uF capacitors, + according to the ADXL202E data sheet */ + call Timer.startOneShot(17); + return SUCCESS; + } + + event void Timer.fired() { + signal SplitControl.startDone(SUCCESS); + } + + task void stopDone() { + call AccelPin.clr(); + signal SplitControl.stopDone(SUCCESS); + } + + command error_t SplitControl.stop() { + post stopDone(); + return SUCCESS; + } +} diff --git a/tos/sensorboards/mts300/AccelReadP.nc b/tos/sensorboards/mts300/AccelReadP.nc new file mode 100644 index 00000000..9425973c --- /dev/null +++ b/tos/sensorboards/mts300/AccelReadP.nc @@ -0,0 +1,26 @@ +configuration AccelReadP +{ + provides { + interface Read as ReadX[uint8_t client]; + interface Read as ReadY[uint8_t client]; + } +} +implementation +{ + components AccelConfigP, + new MultiplexedReadC(uint16_t) as MultiplexX, + new MultiplexedReadC(uint16_t) as MultiplexY, + new AdcReadClientC() as AdcX, + new AdcReadClientC() as AdcY; + + ReadX = MultiplexX; + MultiplexX.Resource -> AccelConfigP; + MultiplexX.Service -> AdcX; + AdcX.Atm128AdcConfig -> AccelConfigP.ConfigX; + + ReadY = MultiplexY; + MultiplexY.Resource -> AccelConfigP; + MultiplexY.Service -> AdcY; + AdcY.Atm128AdcConfig -> AccelConfigP.ConfigY; +} + diff --git a/tos/sensorboards/mts300/AccelReadStreamP.nc b/tos/sensorboards/mts300/AccelReadStreamP.nc new file mode 100644 index 00000000..3db96e83 --- /dev/null +++ b/tos/sensorboards/mts300/AccelReadStreamP.nc @@ -0,0 +1,29 @@ +configuration AccelReadStreamP +{ + provides { + interface ReadStream as ReadStreamX[uint8_t client]; + interface ReadStream as ReadStreamY[uint8_t client]; + } + uses { + interface ReadStream as ActualX[uint8_t client]; + interface ReadStream as ActualY[uint8_t client]; + } +} +implementation +{ + enum { + NACCEL_CLIENTS = uniqueCount(UQ_ACCEL_RESOURCE) + }; + components AccelConfigP, + new ArbitratedReadStreamC(NACCEL_CLIENTS, uint16_t) as MultiplexX, + new ArbitratedReadStreamC(NACCEL_CLIENTS, uint16_t) as MultiplexY; + + ReadStreamX = MultiplexX; + MultiplexX.Resource -> AccelConfigP; + MultiplexX.Service = ActualX; + + ReadStreamY = MultiplexY; + MultiplexY.Resource -> AccelConfigP; + MultiplexY.Service = ActualY; +} + diff --git a/tos/sensorboards/mts300/AccelXC.nc b/tos/sensorboards/mts300/AccelXC.nc new file mode 100644 index 00000000..3d28e0b7 --- /dev/null +++ b/tos/sensorboards/mts300/AccelXC.nc @@ -0,0 +1,25 @@ +/* $Id$ + * 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. + */ +/** + * Acceldiode of the basicsb sensor board. + * + * @author David Gay + */ + +#include "mts300.h" + +generic configuration AccelXC() { + provides interface Read; +} +implementation { + components AccelReadP; + + Read = AccelReadP.ReadX[unique(UQ_ACCEL_RESOURCE)]; +} diff --git a/tos/sensorboards/mts300/AccelXStreamC.nc b/tos/sensorboards/mts300/AccelXStreamC.nc new file mode 100644 index 00000000..ee0efbe4 --- /dev/null +++ b/tos/sensorboards/mts300/AccelXStreamC.nc @@ -0,0 +1,30 @@ +/* $Id$ + * 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. + */ +/** + * AccelXdiode of the basicsb sensor board. + * + * @author David Gay + */ + +#include "mts300.h" + +generic configuration AccelXStreamC() { + provides interface ReadStream; +} +implementation { + enum { + ID = unique(UQ_ACCEL_RESOURCE) + }; + components AccelReadStreamP, AccelConfigP, new AdcReadStreamClientC(); + + ReadStream = AccelReadStreamP.ReadStreamX[ID]; + AccelReadStreamP.ActualX[ID] -> AdcReadStreamClientC; + AdcReadStreamClientC.Atm128AdcConfig -> AccelConfigP.ConfigX; +} diff --git a/tos/sensorboards/mts300/AccelYC.nc b/tos/sensorboards/mts300/AccelYC.nc new file mode 100644 index 00000000..74c6e946 --- /dev/null +++ b/tos/sensorboards/mts300/AccelYC.nc @@ -0,0 +1,25 @@ +/* $Id$ + * 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. + */ +/** + * Acceldiode of the basicsb sensor board. + * + * @author David Gay + */ + +#include "mts300.h" + +generic configuration AccelXC() { + provides interface Read; +} +implementation { + components AccelReadP; + + Read = AccelReadP.ReadY[unique(UQ_ACCEL_RESOURCE)]; +} diff --git a/tos/sensorboards/mts300/AccelYStreamC.nc b/tos/sensorboards/mts300/AccelYStreamC.nc new file mode 100644 index 00000000..51182130 --- /dev/null +++ b/tos/sensorboards/mts300/AccelYStreamC.nc @@ -0,0 +1,30 @@ +/* $Id$ + * 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. + */ +/** + * AccelXdiode of the basicsb sensor board. + * + * @author David Gay + */ + +#include "mts300.h" + +generic configuration AccelYStreamC() { + provides interface ReadStream; +} +implementation { + enum { + ID = unique(UQ_ACCEL_RESOURCE) + }; + components AccelReadStreamP, AccelConfigP, new AdcReadStreamClientC(); + + ReadStream = AccelReadStreamP.ReadStreamY[ID]; + AccelReadStreamP.ActualY[ID] -> AdcReadStreamClientC; + AdcReadStreamClientC.Atm128AdcConfig -> AccelConfigP.ConfigY; +} diff --git a/tos/sensorboards/mts300/ArbitratedPhotoDeviceP.nc b/tos/sensorboards/mts300/ArbitratedPhotoDeviceP.nc new file mode 100644 index 00000000..d0c7f8ac --- /dev/null +++ b/tos/sensorboards/mts300/ArbitratedPhotoDeviceP.nc @@ -0,0 +1,13 @@ +configuration ArbitratedPhotoDeviceP +{ + provides interface Read[uint8_t client]; +} +implementation +{ + components PhotoTempDeviceC, + new ArbitratedReadC(uint16_t) as ArbitrateRead; + + Read = ArbitrateRead; + ArbitrateRead.Service -> PhotoTempDeviceC.ReadPhoto; + ArbitrateRead.Resource -> PhotoTempDeviceC.PhotoResource; +} diff --git a/tos/sensorboards/mts300/DemoSensorC.nc b/tos/sensorboards/mts300/DemoSensorC.nc new file mode 100644 index 00000000..3e67b8e2 --- /dev/null +++ b/tos/sensorboards/mts300/DemoSensorC.nc @@ -0,0 +1,23 @@ +/* $Id$ + * 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; +} +implementation { + components new PhotoC() as Sensor; + + Read = Sensor; +} diff --git a/tos/sensorboards/mts300/DemoSensorStreamC.nc b/tos/sensorboards/mts300/DemoSensorStreamC.nc new file mode 100644 index 00000000..cb763a78 --- /dev/null +++ b/tos/sensorboards/mts300/DemoSensorStreamC.nc @@ -0,0 +1,23 @@ +/* $Id$ + * 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 DemoSensorStreamC() { + provides interface ReadStream; +} +implementation { + components new PhotoStreamC() as SensorStream; + + ReadStream = SensorStream; +} diff --git a/tos/sensorboards/mts300/Mts300Sounder.nc b/tos/sensorboards/mts300/Mts300Sounder.nc new file mode 100644 index 00000000..6f39bff0 --- /dev/null +++ b/tos/sensorboards/mts300/Mts300Sounder.nc @@ -0,0 +1,4 @@ +interface Mts300Sounder +{ + command void beep(uint16_t length); +} diff --git a/tos/sensorboards/mts300/PhotoC.nc b/tos/sensorboards/mts300/PhotoC.nc new file mode 100644 index 00000000..d6acb651 --- /dev/null +++ b/tos/sensorboards/mts300/PhotoC.nc @@ -0,0 +1,25 @@ +/* $Id$ + * 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 mts300 sensor board. + * + * @author David Gay + */ + +#include "mts300.h" + +generic configuration PhotoC() { + provides interface Read; +} +implementation { + components ArbitratedPhotoDeviceP; + + Read = ArbitratedPhotoDeviceP.Read[unique(UQ_PHOTO_RESOURCE)]; +} diff --git a/tos/sensorboards/mts300/PhotoConfigP.nc b/tos/sensorboards/mts300/PhotoConfigP.nc new file mode 100644 index 00000000..52367a30 --- /dev/null +++ b/tos/sensorboards/mts300/PhotoConfigP.nc @@ -0,0 +1,6 @@ +configuration PhotoConfigP +{ +} +implementation +{ +} diff --git a/tos/sensorboards/mts300/PhotoTempControlP.nc b/tos/sensorboards/mts300/PhotoTempControlP.nc new file mode 100644 index 00000000..4a688a3f --- /dev/null +++ b/tos/sensorboards/mts300/PhotoTempControlP.nc @@ -0,0 +1,55 @@ +generic module PhotoTempControlP() +{ + provides { + interface SplitControl; + interface Read[uint8_t client]; + } + uses { + interface Resource as PhotoTempResource; + interface Timer; + interface GeneralIO as Power; + interface Read as ActualRead; + } +} +implementation +{ + command error_t SplitControl.start() { + call PhotoTempResource.request(); + return SUCCESS; + } + + event void PhotoTempResource.granted() { + call Power.makeOutput(); + call Power.set(); + call Timer.startOneShot(10); + } + + event void Timer.fired() { + signal SplitControl.startDone(SUCCESS); + } + + task void stopDone() { + call PhotoTempResource.release(); + signal SplitControl.stopDone(SUCCESS); + } + + command error_t SplitControl.stop() { + call Power.clr(); + call Power.makeInput(); + post stopDone(); + return SUCCESS; + } + + uint8_t id; + + command error_t Read.read[uint8_t client]() { + id = client; + return call ActualRead.read(); + } + + event void ActualRead.readDone(error_t result, uint16_t val) { + signal Read.readDone[id](result, val); + } + + default event void Read.readDone[uint8_t x](error_t result, uint16_t val) { } +} diff --git a/tos/sensorboards/mts300/PhotoTempDeviceC.nc b/tos/sensorboards/mts300/PhotoTempDeviceC.nc new file mode 100644 index 00000000..28c1520b --- /dev/null +++ b/tos/sensorboards/mts300/PhotoTempDeviceC.nc @@ -0,0 +1,45 @@ +#include "mts300.h" + +configuration PhotoTempDeviceC +{ + provides interface Resource as PhotoResource[uint8_t client]; + provides interface Resource as TempResource[uint8_t client]; + provides interface Read as ReadPhoto[uint8_t client]; + provides interface Read as ReadTemp[uint8_t client]; +} +implementation +{ + components MicaBusC, PhotoTempP, + new RoundRobinArbiterC(UQ_PHOTOTEMP_RESOURCE) as SharingArbiter, + new RoundRobinArbiterC(UQ_PHOTO_RESOURCE) as PhotoArbiter, + new RoundRobinArbiterC(UQ_TEMP_RESOURCE) as TempArbiter, + new SplitControlPowerManagerC() as PhotoPower, + new SplitControlPowerManagerC() as TempPower, + new PhotoTempControlP() as PhotoControl, + new PhotoTempControlP() as TempControl, + new TimerMilliC() as WarmupTimer, + new AdcReadClientC() as Adc; + + PhotoResource = PhotoArbiter; + PhotoPower.ResourceDefaultOwner -> PhotoArbiter; + PhotoPower.ArbiterInfo -> PhotoArbiter; + PhotoPower.SplitControl -> PhotoControl; + PhotoControl.PhotoTempResource -> SharingArbiter.Resource[unique(UQ_PHOTOTEMP_RESOURCE)]; + PhotoControl.Timer -> WarmupTimer; + PhotoControl.Power -> MicaBusC.Int1; + ReadPhoto = PhotoControl; + PhotoControl.ActualRead -> Adc; + + TempResource = TempArbiter; + TempPower.ResourceDefaultOwner -> TempArbiter; + TempPower.ArbiterInfo -> TempArbiter; + TempPower.SplitControl -> TempControl; + TempControl.PhotoTempResource -> SharingArbiter.Resource[unique(UQ_PHOTOTEMP_RESOURCE)]; + TempControl.Timer -> WarmupTimer; + TempControl.Power -> MicaBusC.Int2; + ReadTemp = TempControl; + TempControl.ActualRead -> Adc; + + Adc.Atm128AdcConfig -> PhotoTempP; + PhotoTempP.PhotoTempAdc -> MicaBusC.Adc1; +} diff --git a/tos/sensorboards/mts300/PhotoTempP.nc b/tos/sensorboards/mts300/PhotoTempP.nc new file mode 100644 index 00000000..185f6f7a --- /dev/null +++ b/tos/sensorboards/mts300/PhotoTempP.nc @@ -0,0 +1,32 @@ +/* $Id$ + * 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. + */ +/** + * MTS300 photo and temp sensor ADC configuration. + * @author David Gay + */ +module PhotoTempP +{ + 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; + } +} diff --git a/tos/sensorboards/mts300/PhotoTempSetupP.nc b/tos/sensorboards/mts300/PhotoTempSetupP.nc new file mode 100644 index 00000000..7b9c9673 --- /dev/null +++ b/tos/sensorboards/mts300/PhotoTempSetupP.nc @@ -0,0 +1,25 @@ +generic configuration PhotoTempSetupP(const char *resname) +{ + provides interface Resource[uint8_t client]; + uses { + interface Timer; + interface Resource as SharingResource; + interface GeneralIO as Power; + } +} +implementation +{ + components + new RoundRobinArbiterC(resname) as Arbiter, + new SplitControlPowerManager() as Power, + new PhotoTempControlP() as Control; + + Resource = Arbiter; + Power.ResourceDefaultOwner -> Arbiter; + Power.ArbiterInfo -> Arbiter; + Power.SplitControl -> Control; + + Control.Resource = SharingResource; + Control.Power = Power; + Control.Timer = Timer; +} diff --git a/tos/sensorboards/mts300/SounderC.nc b/tos/sensorboards/mts300/SounderC.nc new file mode 100644 index 00000000..a121e89e --- /dev/null +++ b/tos/sensorboards/mts300/SounderC.nc @@ -0,0 +1,12 @@ +configuration SounderC +{ + provides interface Mts300Sounder; +} +implementation +{ + components SounderP, new TimerMilliC(), MicaBusC; + + Mts300Sounder = SounderP; + SounderP.Timer -> TimerMilliC; + SounderP.SounderPin -> MicaBusC.PW2; +} diff --git a/tos/sensorboards/mts300/SounderP.nc b/tos/sensorboards/mts300/SounderP.nc new file mode 100644 index 00000000..e5f2c064 --- /dev/null +++ b/tos/sensorboards/mts300/SounderP.nc @@ -0,0 +1,31 @@ +module SounderP +{ + provides interface Mts300Sounder; + uses { + interface Timer; + interface GeneralIO as SounderPin; + } +} +implementation +{ + command void Mts300Sounder.beep(uint16_t length) { + if (call Timer.isRunning()) + { + uint32_t remaining = call Timer.getdt(), + elapsed = call Timer.getNow() - call Timer.gett0(); + + /* If more time left than we are requesting, just exit */ + if (remaining > elapsed && (remaining - elapsed) > length) + return; + + /* Override timer with new duration */ + } + call Timer.startOneShot(length); + call SounderPin.makeOutput(); + call SounderPin.set(); + } + + event void Timer.fired() { + call SounderPin.clr(); + } +} diff --git a/tos/sensorboards/mts300/WireAccelP.nc b/tos/sensorboards/mts300/WireAccelP.nc new file mode 100644 index 00000000..7fa60c58 --- /dev/null +++ b/tos/sensorboards/mts300/WireAccelP.nc @@ -0,0 +1,35 @@ +/* $Id$ + * 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 + */ + +configuration WireAccelP { + provides interface Resource[uint8_t client]; +} +implementation { + components AccelP, MicaBusC, new TimerMilliC() as WarmupTimer, + new RounRobinArbiterC(UQ_ACCEL_RESOURCE) as Arbiter, + new SplitControlPowerManagerC() as PowerManager; + + Resource = Arbiter; + + PowerManager.ResourceDefaultOwner -> Arbiter; + PowerManager.ArbiterInfo -> Arbiter; + PowerManager.SplitControl -> AccelP; + + AccelP.Timer -> WarmupTimer; + AccelP.AccelPin -> MicaBusC.PW4; + AccelP.AccelAdcX -> MicaBusC.Adc3; + AccelP.AccelAdcY -> MicaBusC.Adc4; +} -- 2.39.2