[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/tsb AccelDriverM.nc, 1.3, 1.4 Mic.h, 1.1, 1.2 MicDriverC.nc, 1.2, 1.3 MicDriverM.nc, 1.2, 1.3 PhotoDriverM.nc, 1.2, 1.3

Joe Polastre jpolastre at users.sourceforge.net
Thu Aug 4 14:59:21 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/tsb
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27218

Modified Files:
	AccelDriverM.nc Mic.h MicDriverC.nc MicDriverM.nc 
	PhotoDriverM.nc 
Log Message:
modify to work with tsb v2.0 and new ad524x abstraction


Index: AccelDriverM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/tsb/AccelDriverM.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AccelDriverM.nc	4 Aug 2005 00:13:14 -0000	1.3
--- AccelDriverM.nc	4 Aug 2005 21:59:18 -0000	1.4
***************
*** 135,142 ****
      }
      if (_state == STOP) {
-       // questionable whether this should be here...
-       call ADCStdControl.stop();
-       TOSH_SEL_ADC0_IOFUNC();
-       TOSH_SEL_ADC1_IOFUNC();
        return call AD524X.stop(ACCEL_ADDR, ACCEL_TYPE);
      }
--- 135,138 ----

Index: Mic.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/tsb/Mic.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Mic.h	24 Jun 2005 00:14:39 -0000	1.1
--- Mic.h	4 Aug 2005 21:59:19 -0000	1.2
***************
*** 1,12 ****
  #ifndef _H_MIC_H
  #define _H_MIC_H
  
  #include "MSP430ADC12.h"
  
  enum {
!   AD5242_MIC1_ADDR = 0x00,
!   AD5242_MIC2_ADDR = 0x01,
!   AD5242_MIC_PWR_ADDR = 0x00,
!   AD5242_MIC_FLT_ADDR = 0x00,
  };
  
--- 1,40 ----
+ /*
+  * Copyright (c) 2005 Moteiv Corporation
+  * All rights reserved.
+  *
+  * This file is distributed under the terms in the attached MOTEIV-LICENSE     
+  * file. If you do not find these files, copies can be found at
+  * http://www.moteiv.com/MOTEIV-LICENSE.txt and by emailing info at moteiv.com.
+  */
  #ifndef _H_MIC_H
  #define _H_MIC_H
  
  #include "MSP430ADC12.h"
+ #include "AD524X.h"
  
  enum {
!   MIC_ADDR1 = 0x00,
!   MIC_TYPE1 = TYPE_AD5242,
!   MIC_ADDR2 = 0x01,
!   MIC_TYPE2 = TYPE_AD5242,
! 
!   MIC_ON_ADDR = 0x00,
!   MIC_ON_OUTPUT = 0x00,
!   MIC_ON_TYPE = TYPE_AD5242,
! 
!   MIC_VRG_ADDR = 0x00,
!   MIC_VRC_ADDR = 0x01,
!   MIC_INT_DRAIN_ADDR = 0x00,
!   MIC_INT_THRESH_ADDR = 0x01,
! 
!   MIC_VRG_RDAC = 0,
!   MIC_VRC_RDAC = 0,
!   MIC_INT_DRAIN_RDAC = 1,
!   MIC_INT_THRESH_RDAC = 1,
! 
!   MIC_VRG_TYPE = TYPE_AD5242,
!   MIC_VRC_TYPE = TYPE_AD5242,
!   MIC_INT_DRAIN_TYPE = TYPE_AD5242,
!   MIC_INT_THRESH_TYPE = TYPE_AD5242,
  };
  

Index: MicDriverC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/tsb/MicDriverC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MicDriverC.nc	17 Jul 2005 20:53:50 -0000	1.2
--- MicDriverC.nc	4 Aug 2005 21:59:19 -0000	1.3
***************
*** 1,2 ****
--- 1,3 ----
+ // $Id$
  /*									tab:4
   * "Copyright (c) 2000-2003 The Regents of the University  of California.  
***************
*** 19,28 ****
   * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
   *
!  */
! /*
   *
!  * Authors:		Joe Polastre
   *
!  * $Id$
   */
  
--- 20,34 ----
   * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
   *
!  * Copyright (c) 2005 Moteiv Corporation
!  * All rights reserved.
   *
!  * This file is distributed under the terms in the attached MOTEIV-LICENSE     
!  * file. If you do not find these files, copies can be found at
!  * http://www.moteiv.com/MOTEIV-LICENSE.txt and by emailing info at moteiv.com.
!  */
! /**
!  * @author Joe Polastre <info at moteiv.com>
   *
!  * Revision: $Revision $
   */
  
***************
*** 38,47 ****
      interface Potentiometer as Vrc;
      interface Potentiometer as Vrg;
!     interface Potentiometer as MicInterruptSettings;
    }
  }
  implementation
  {
!   components MicDriverM, ADCC, AD5242C, MSP430InterruptC, LedsC;
    
    MicDriverM.Leds -> LedsC;
--- 44,54 ----
      interface Potentiometer as Vrc;
      interface Potentiometer as Vrg;
!     interface Potentiometer as MicInterruptDrain;
!     interface Potentiometer as MicInterruptThreshold;    
    }
  }
  implementation
  {
!   components MicDriverM, ADCC, AD524XC, MSP430InterruptC, LedsC;
    
    MicDriverM.Leds -> LedsC;
***************
*** 50,54 ****
    Mic = ADCC.ADC[TOS_ADC_MIC_PORT];
    MicInterrupt = MicDriverM;
!   MicInterruptSettings = MicDriverM.MicInterruptSettings;
    Vrc = MicDriverM.Vrc;
    Vrg = MicDriverM.Vrg;
--- 57,62 ----
    Mic = ADCC.ADC[TOS_ADC_MIC_PORT];
    MicInterrupt = MicDriverM;
!   MicInterruptDrain = MicDriverM.MicInterruptDrain;
!   MicInterruptThreshold = MicDriverM.MicInterruptThreshold;
    Vrc = MicDriverM.Vrc;
    Vrg = MicDriverM.Vrg;
***************
*** 56,61 ****
    MicDriverM.ADCStdControl -> ADCC;
    MicDriverM.ADCControl -> ADCC;
!   MicDriverM.AD5242 -> AD5242C;
!   MicDriverM.AD5242Control -> AD5242C;
    MicDriverM.MicInt -> MSP430InterruptC.Port26; // GIO3
  
--- 64,69 ----
    MicDriverM.ADCStdControl -> ADCC;
    MicDriverM.ADCControl -> ADCC;
!   MicDriverM.AD524X -> AD524XC;
!   MicDriverM.AD524XControl -> AD524XC;
    MicDriverM.MicInt -> MSP430InterruptC.Port26; // GIO3
  

Index: MicDriverM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/tsb/MicDriverM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MicDriverM.nc	17 Jul 2005 20:53:50 -0000	1.2
--- MicDriverM.nc	4 Aug 2005 21:59:19 -0000	1.3
***************
*** 19,26 ****
   * 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$
   *
--- 19,33 ----
   * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
   * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+  *
+  * Copyright (c) 2005 Moteiv Corporation
+  * All rights reserved.
+  *
+  * This file is distributed under the terms in the attached MOTEIV-LICENSE     
+  * file. If you do not find these files, copies can be found at
+  * http://www.moteiv.com/MOTEIV-LICENSE.txt and by emailing info at moteiv.com.
   */
  
  /**
!  * @author Joe Polastre <info at moteiv.com>
   * Revision:  $Revision$
   *
***************
*** 36,47 ****
      interface Potentiometer as Vrc;
      interface Potentiometer as Vrg;
!     interface Potentiometer as MicInterruptSettings;
    }
    uses {
!     interface AD5242;
      interface ADCControl;
      interface StdControl as ADCStdControl;
      interface StdControl as PotControl;
!     interface StdControl as AD5242Control;
      interface MSP430Interrupt as MicInt;
      interface Leds;
--- 43,55 ----
      interface Potentiometer as Vrc;
      interface Potentiometer as Vrg;
!     interface Potentiometer as MicInterruptDrain;
!     interface Potentiometer as MicInterruptThreshold;
    }
    uses {
!     interface AD524X;
      interface ADCControl;
      interface StdControl as ADCStdControl;
      interface StdControl as PotControl;
!     interface StdControl as AD524XControl;
      interface MSP430Interrupt as MicInt;
      interface Leds;
***************
*** 57,66 ****
      START1,
      START2,
!     START_O1, // mic circuit power on
!     START_O2, // filter circuit power on
!     STOP,
!     STOP_O1,
!     STOP_O2,
!     GAIN,
      VRG,
      VRC,
--- 65,74 ----
      START1,
      START2,
!     START_O, // mic circuit power on
!     STOP1,
!     STOP2,
!     STOP_O,
!     DRAIN,
!     THRESH,
      VRG,
      VRC,
***************
*** 68,72 ****
  
    uint8_t state;
!   uint8_t gain;
    uint8_t vrg, vrc;
  
--- 76,80 ----
  
    uint8_t state;
!   uint8_t drain, thresh;
    uint8_t vrg, vrc;
  
***************
*** 81,85 ****
      }
      call ADCStdControl.init();
!     call AD5242Control.init();
      return post initDone();
    }
--- 89,93 ----
      }
      call ADCStdControl.init();
!     call AD524XControl.init();
      return post initDone();
    }
***************
*** 103,113 ****
        TOSH_MAKE_ADC2_INPUT();
        TOSH_SEL_ADC2_MODFUNC();
!       call AD5242Control.start();
!       return call AD5242.start(AD5242_MIC1_ADDR);
      }
      return FAIL;
    }
  
!   event void AD5242.startDone(uint8_t _addr, result_t _result) {
      uint8_t _state = OFF;
      atomic {
--- 111,121 ----
        TOSH_MAKE_ADC2_INPUT();
        TOSH_SEL_ADC2_MODFUNC();
!       call AD524XControl.start();
!       return call AD524X.start(MIC_ADDR1, MIC_TYPE1);
      }
      return FAIL;
    }
  
!   event void AD524X.startDone(uint8_t _addr, result_t _result, ad524x_type_t _type) {
      uint8_t _state = OFF;
      atomic {
***************
*** 116,125 ****
        }
        else if (state == START2) {
! 	state = START_O1;
        }
        _state = state;
      }
      if (_state == START2) {
!       if (!(call AD5242.start(AD5242_MIC2_ADDR))) {
  	atomic state = IDLE;
  	signal SplitControl.startDone();
--- 124,133 ----
        }
        else if (state == START2) {
! 	state = START_O;
        }
        _state = state;
      }
      if (_state == START2) {
!       if (!(call AD524X.start(MIC_ADDR2, MIC_TYPE2))) {
  	atomic state = IDLE;
  	signal SplitControl.startDone();
***************
*** 127,132 ****
      }
      // turn on the microphone circuit
!     else if (_state == START_O1) {
!       if (!(call AD5242.setOutput1(AD5242_MIC_PWR_ADDR, TRUE))) {
  	atomic state = IDLE;
  	signal SplitControl.startDone();
--- 135,140 ----
      }
      // turn on the microphone circuit
!     else if (_state == START_O) {
!       if (!(call AD524X.setOutput(MIC_ON_ADDR, MIC_ON_OUTPUT, TRUE, MIC_ON_TYPE))) {
  	atomic state = IDLE;
  	signal SplitControl.startDone();
***************
*** 139,194 ****
      atomic {
        if (state == IDLE) {
! 	state = STOP;
  	_state = state;
        }
      }
!     if (_state == STOP) {
        // questionable whether this should be here...
        call ADCStdControl.stop();
!       TOSH_SEL_ADC2_IOFUNC();
!       return call AD5242.stop(AD5242_MIC_PWR_ADDR);
      }
      return FAIL;
    }
  
!   event void AD5242.stopDone(uint8_t _addr, result_t _result) {
!     uint8_t _state = OFF;
!     atomic {
!       if (state == STOP) {
! 	state = STOP_O1;
! 	_state = state;
!       }
!     }
!     if (_state == STOP_O1) {
!       if (!(call AD5242.setOutput1(AD5242_MIC_PWR_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_O1) {
! 	state = START_O2;
  	_state = state;
        }
!       else if (state == STOP_O1) {
! 	state = STOP_O2;
  	_state = state;
        }
      }
  
!     // turn on the filter
!     if (_state == START_O2) {
!       if (!(call AD5242.setOutput2(AD5242_MIC_PWR_ADDR, TRUE))) {
  	atomic state = IDLE;
  	signal SplitControl.startDone();
        }
      }
!     // turn on the filter
!     else if (_state == STOP_O2) {
!       if (!(call AD5242.setOutput2(AD5242_MIC_PWR_ADDR, FALSE))) {
  	atomic state = IDLE;
  	signal SplitControl.stopDone();
--- 147,183 ----
      atomic {
        if (state == IDLE) {
! 	state = STOP1;
  	_state = state;
        }
      }
!     if (_state == STOP1) {
        // questionable whether this should be here...
        call ADCStdControl.stop();
!       return call AD524X.stop(MIC_ADDR1, MIC_TYPE1);
      }
      return FAIL;
    }
  
!   event void AD524X.stopDone(uint8_t _addr, result_t _result, ad524x_type_t _type) {
      uint8_t _state = OFF;
      atomic {
!       if (state == STOP1) {
! 	state = STOP1;
  	_state = state;
        }
!       else if (state == STOP2) {
! 	state = STOP_O;
  	_state = state;
        }
      }
  
!     if (_state == STOP2) {
!       if (!(call AD524X.stop(MIC_ADDR2, MIC_TYPE2))) {
  	atomic state = IDLE;
  	signal SplitControl.startDone();
        }
      }
!     if (_state == STOP_O) {
!       if (!(call AD524X.setOutput(MIC_ON_ADDR, MIC_ON_OUTPUT, FALSE, MIC_ON_TYPE))) { 
  	atomic state = IDLE;
  	signal SplitControl.stopDone();
***************
*** 197,226 ****
    }
  
!   event void AD5242.setOutput2Done(uint8_t _addr, result_t _result) { 
      uint8_t _state = OFF;
- 
      atomic {
!       if ((state == START_O2) || (state == STOP_O2)) {
  	_state = state;
  	state = IDLE;
        }
      }
!     if (_state == START_O2) 
        signal SplitControl.startDone();
!     else if (_state == STOP_O2) {
!       call AD5242Control.stop();
        signal SplitControl.stopDone();
      }
    }
  
!   event void AD5242.setPot1Done(uint8_t _addr, result_t _result) { 
      uint8_t _state = OFF;
  
      atomic {
!       if (state == VRC) {
!         _state = state;
!         state = IDLE;
!       }
!       else if (state == VRG) {
          _state = state;
          state = IDLE;
--- 186,215 ----
    }
  
!   event void AD524X.setOutputDone(uint8_t _addr, bool _output, result_t _result, ad524x_type_t _type) { 
      uint8_t _state = OFF;
      atomic {
!       if (state == START_O) {
! 	_state = state;
! 	state = IDLE;
!       }
!       else if (state == STOP_O) {
  	_state = state;
  	state = IDLE;
        }
      }
! 
!     if (_state == START_O) 
        signal SplitControl.startDone();
!     else if (_state == STOP_O) {
!       call AD524XControl.stop();
        signal SplitControl.stopDone();
      }
    }
  
!   event void AD524X.setPotDone(uint8_t _addr, bool _rdac, result_t _result, ad524x_type_t _type) { 
      uint8_t _state = OFF;
  
      atomic {
!       if ((state == VRC) || (state == VRG) || (state == THRESH) || (state == DRAIN)) {
          _state = state;
          state = IDLE;
***************
*** 234,254 ****
        signal Vrg.setDone(vrc, _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 MicInterruptSettings.setDone(gain, _result);
      }
    }
  
    command result_t Vrg.set(uint8_t _value) {
      uint8_t _state = OFF;
--- 223,236 ----
        signal Vrg.setDone(vrc, _result);
      }
!     if (_state == DRAIN) {
!       signal MicInterruptDrain.setDone(drain, _result);
      }
!     if (_state == THRESH) {
!       signal MicInterruptThreshold.setDone(thresh, _result);
      }
    }
  
+   event void AD524X.getPotDone(uint8_t _addr, bool _rdac, uint8_t _val, result_t _result, ad524x_type_t _type) { }
+ 
    command result_t Vrg.set(uint8_t _value) {
      uint8_t _state = OFF;
***************
*** 261,265 ****
      if (_state == VRG) {
        atomic vrg = _value;
!       return call AD5242.setPot1(AD5242_MIC1_ADDR, vrg);
      }
      return FAIL;
--- 243,247 ----
      if (_state == VRG) {
        atomic vrg = _value;
!       return call AD524X.setPot(MIC_VRG_ADDR, MIC_VRG_RDAC, vrg, MIC_VRG_TYPE);
      }
      return FAIL;
***************
*** 282,286 ****
      if (_state == VRC) {
        atomic vrc = _value;
!       return call AD5242.setPot1(AD5242_MIC2_ADDR, vrc);
      }
      return FAIL;
--- 264,268 ----
      if (_state == VRC) {
        atomic vrc = _value;
!       return call AD524X.setPot(MIC_VRC_ADDR, MIC_VRC_RDAC, vrc, MIC_VRC_TYPE);
      }
      return FAIL;
***************
*** 293,315 ****
    default event void Vrc.setDone(uint8_t value, result_t result) { }
  
!   command result_t MicInterruptSettings.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_MIC1_ADDR, gain);
      }
      return FAIL;
    }
  
!   default event void MicInterruptSettings.setDone(uint8_t _gain, result_t _result) { }
  
!   command uint8_t MicInterruptSettings.get() {
!     return gain;
    }
  
--- 275,318 ----
    default event void Vrc.setDone(uint8_t value, result_t result) { }
  
!   command result_t MicInterruptDrain.set(uint8_t _drain) {
      uint8_t _state = OFF;
      atomic {
        if (state == IDLE) {
!         state = DRAIN;
          _state = state;
        }
      }
!     if (_state == DRAIN) {
!       atomic drain = _drain;
!       return call AD524X.setPot(MIC_INT_DRAIN_ADDR, MIC_INT_DRAIN_RDAC, thresh, MIC_INT_DRAIN_TYPE);
      }
      return FAIL;
    }
  
!   default event void MicInterruptDrain.setDone(uint8_t _gain, result_t _result) { }
  
!   command uint8_t MicInterruptDrain.get() {
!     return drain;
!   }
! 
!   command result_t MicInterruptThreshold.set(uint8_t _thresh) {
!     uint8_t _state = OFF;
!     atomic {
!       if (state == IDLE) {
!         state = THRESH;
!         _state = state;
!       }
!     }
!     if (_state == THRESH) {
!       atomic thresh = _thresh;
!       return call AD524X.setPot(MIC_INT_THRESH_ADDR, MIC_INT_THRESH_RDAC, thresh, MIC_INT_THRESH_TYPE);
!     }
!     return FAIL;
!   }
! 
!   default event void MicInterruptThreshold.setDone(uint8_t _gain, result_t _result) { }
! 
!   command uint8_t MicInterruptThreshold.get() {
!     return thresh;
    }
  

Index: PhotoDriverM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/tsb/PhotoDriverM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PhotoDriverM.nc	4 Aug 2005 21:20:38 -0000	1.2
--- PhotoDriverM.nc	4 Aug 2005 21:59:19 -0000	1.3
***************
*** 131,138 ****
      }
      if (_state == STOP) {
-       // questionable whether this should be here...
-       // call ADCStdControl.stop();
-       TOSH_SEL_ADC0_IOFUNC();
-       TOSH_SEL_ADC1_IOFUNC();
        return call AD524X.stop(PHOTO_ADDR, PHOTO_TYPE);
      }
--- 131,134 ----



More information about the Tinyos-beta-commits mailing list