[Tinyos-2-commits] [tinyos-main] r5513 committed - mts300: always use MicaBusC instead of directly accessing atmega inter...
tinyos-main at googlecode.com
tinyos-main at googlecode.com
Sun Mar 13 13:51:45 PDT 2011
Revision: 5513
Author: mmaroti at gmail.com
Date: Sun Mar 13 13:48:57 2011
Log: mts300: always use MicaBusC instead of directly accessing atmega
interfaces. Support for the tone detector.
http://code.google.com/p/tinyos-main/source/detail?r=5513
Modified:
/trunk/tos/sensorboards/mts300/MicDeviceP.nc
/trunk/tos/sensorboards/mts300/MicP.nc
/trunk/tos/sensorboards/mts300/MicSetting.nc
=======================================
--- /trunk/tos/sensorboards/mts300/MicDeviceP.nc Tue Jun 29 15:07:56 2010
+++ /trunk/tos/sensorboards/mts300/MicDeviceP.nc Sun Mar 13 13:48:57 2011
@@ -31,7 +31,7 @@
*
* @author Hu Siquan <husq at xbow.com>
*
- * $Id: MicDeviceP.nc,v 1.5 2010-06-29 22:07:56 scipio Exp $
+ * $Id: MicDeviceP.nc,v 1.2 2010-07-21 13:23:50 zkincses Exp $
*/
#include "mts300.h"
@@ -44,8 +44,7 @@
}
}
implementation {
- components MicP, MicaBusC, HplAtm128GeneralIOC as Pins,
- HplAtm128InterruptC as IntPins,
+ components MicP, MicaBusC,
new Atm128I2CMasterC() as I2CPot,
new TimerMilliC() as WarmupTimer,
new RoundRobinArbiterC(UQ_MIC_RESOURCE) as Arbiter,
@@ -62,8 +61,9 @@
MicP.Timer -> WarmupTimer;
MicP.MicPower -> MicaBusC.PW3;
MicP.MicMuxSel -> MicaBusC.PW6;
+ MicP.InterruptPin -> MicaBusC.Int3;
MicP.MicAdc -> MicaBusC.Adc2;
MicP.I2CPacket -> I2CPot;
MicP.I2CResource -> I2CPot;
- MicP.AlertInterrupt -> IntPins.Int7;
-}
+ MicP.AlertInterrupt -> MicaBusC.Int3_Interrupt;
+}
=======================================
--- /trunk/tos/sensorboards/mts300/MicP.nc Tue Jun 29 15:07:56 2010
+++ /trunk/tos/sensorboards/mts300/MicP.nc Sun Mar 13 13:48:57 2011
@@ -31,7 +31,7 @@
*
* @author Hu Siquan <husq at xbow.com>
*
- * $Id: MicP.nc,v 1.6 2010-06-29 22:07:56 scipio Exp $
+ * $Id: MicP.nc,v 1.4 2010-07-21 13:23:51 zkincses Exp $
*/
#include "Timer.h"
@@ -51,14 +51,18 @@
uses interface Timer<TMilli>;
uses interface GeneralIO as MicPower;
uses interface GeneralIO as MicMuxSel;
+ uses interface GeneralIO as InterruptPin;
uses interface MicaBusAdc as MicAdc;
uses interface I2CPacket<TI2CBasicAddr>;
uses interface Resource as I2CResource;
- uses interface HplAtm128Interrupt as AlertInterrupt;
+ uses interface GpioInterrupt as AlertInterrupt;
+
}
implementation
{
uint8_t gainData[2];
+ uint8_t lastGain = 64;
+
command error_t SplitControl.start()
{
@@ -69,7 +73,7 @@
call MicMuxSel.clr();
call MicSetting.muxSel(1); // Set the mux so that raw microhpone
output is selected
- call MicSetting.gainAdjust(64); // Set the gain of the microphone.
+ call MicSetting.gainAdjust(lastGain); // Set the gain of the
microphone.
call Timer.startOneShot(1200);
return SUCCESS;
@@ -105,20 +109,33 @@
command error_t MicSetting.muxSel(uint8_t sel)
{
if (sel == 0)
- {
- call MicMuxSel.clr();
- return SUCCESS;
- }
+ {
+ call MicMuxSel.clr();
+ return SUCCESS;
+ }
else if (sel == 1)
- {
- call MicMuxSel.set();
- return SUCCESS;
- }
+ {
+ call MicMuxSel.set();
+ return SUCCESS;
+ }
return FAIL;
}
+
+ command error_t MicSetting.startMic(){
+ call MicPower.makeOutput();
+ call MicPower.set();
+ return SUCCESS;
+ }
+
+ command error_t MicSetting.stopMic(){
+ call MicPower.makeOutput();
+ call MicPower.clr();
+ return SUCCESS;
+ }
command error_t MicSetting.gainAdjust(uint8_t val)
{
+ lastGain = val;
gainData[0] = 0; // pot subaddr
gainData[1] = val; // value to write
return call I2CResource.request();
@@ -126,17 +143,16 @@
command uint8_t MicSetting.readToneDetector()
{
- bool bVal = call AlertInterrupt.getValue();
+ bool bVal = call InterruptPin.get();
return bVal ? 1 : 0;
}
/**
* mic interrupt control
- *
*/
async command error_t MicSetting.enable()
{
- call AlertInterrupt.enable();
+ call AlertInterrupt.enableFallingEdge();
return SUCCESS;
}
@@ -155,11 +171,6 @@
{
signal MicSetting.toneDetected();
}
-
- /**
- *
- *
- */
async command uint8_t MicAtm128AdcConfig.getChannel()
{
@@ -176,10 +187,6 @@
return ATM128_ADC_PRESCALE;
}
- /**
- * I2CPot2
- *
- */
async event void I2CPacket.readDone(error_t error, uint16_t addr,
uint8_t length, uint8_t* data)
{
}
=======================================
--- /trunk/tos/sensorboards/mts300/MicSetting.nc Tue Jun 29 15:07:56 2010
+++ /trunk/tos/sensorboards/mts300/MicSetting.nc Sun Mar 13 13:48:57 2011
@@ -1,4 +1,4 @@
-// $Id: MicSetting.nc,v 1.3 2010-06-29 22:07:56 scipio Exp $
+// $Id: MicSetting.nc,v 1.1 2010-07-21 13:23:51 zkincses Exp $
/*
* Copyright (c) 2000-2003 The Regents of the University of California.
@@ -59,7 +59,6 @@
* If an audio signal at 4.3kHz is picked up by the microphone, the tone
* detect will decode it and generate a binary ouput (0 meaning tone is
detected, 1 meaning
* tone is not detected). Users can read this output simply by calling
readToneDetector().
- *
*/
/**
@@ -71,15 +70,27 @@
* Return: returns SUCCESS or FAIL
*/
command error_t muxSel(uint8_t sel);
+
/* Effect: Set the amplificatoin gain on the microphone
* Return: returns SUCCESS or FAIL
*/
command error_t gainAdjust(uint8_t val);
+ /* Effect: Power on the microphone
+ * Return: returns SUCCESS or FAIL
+ */
+ command error_t startMic();
+
+ /* Effect: Power off the microphone
+ * Return: returns SUCCESS or FAIL
+ */
+ command error_t stopMic();
+
/* Effect: returns the binary tone detector's output
* Return: 0 meaning tone is detected, 1 meanning tone is not detected
*/
command uint8_t readToneDetector();
+
/* Effects: disable interrupts
Returns: SUCCESS
*/
More information about the Tinyos-2-commits
mailing list