[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/msp430/adc12 Msp430Adc12FastClientC.nc, NONE, 1.1.2.1 Msp430Adc12FastSingleChannel.nc, NONE, 1.1.2.1 Msp430Adc12C.nc, 1.1.2.8, 1.1.2.9 Msp430Adc12P.nc, 1.1.2.8, 1.1.2.9 Msp430Adc12SingleChannel.nc, 1.1.2.5, 1.1.2.6

Jan-Hinrich Hauer janhauer at users.sourceforge.net
Fri Jul 7 08:17:56 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/adc12
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv31853/tos/chips/msp430/adc12

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	Msp430Adc12C.nc Msp430Adc12P.nc Msp430Adc12SingleChannel.nc 
Added Files:
      Tag: tinyos-2_0_devel-BRANCH
	Msp430Adc12FastClientC.nc Msp430Adc12FastSingleChannel.nc 
Log Message:
Added another interface and wrapper component on HAL1 that separates configuration from getData to support applications with harder timing constraints (in terms of when exactly a channel is sampled).

--- NEW FILE: Msp430Adc12FastClientC.nc ---
/* 
 * Copyright (c) 2004, Technische Universitaet Berlin
 * 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 Technische Universitaet Berlin 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 THE COPYRIGHT
 * OWNER OR 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.
 *
 * - Revision -------------------------------------------------------------
 * $Revision: 1.1.2.1 $
 * $Date: 2006/07/07 15:17:54 $
 * @author: Jan Hauer <hauer at tkn.tu-berlin.de>
 * ========================================================================
 */

/** 
 * This component realizes a HAL1 representation and allows an
 * MSP430-specific client to access the MSP430 ADC12 (12-bit analog-to-digital
 * converter) via the <code>Msp430Adc12FastSingleChannel</code> and
 * <code>Resource</code> interface. 
 * 
 * @author Jan Hauer
 * @see  Please refer to TEP 101 for more information about this component and its
 *          intended use.
 */

generic configuration Msp430Adc12FastClientC()
{
  provides interface Resource;
  provides interface Msp430Adc12FastSingleChannel;
} implementation {
  components Msp430Adc12C;
   
  enum {
    ID = unique(MSP430ADC12_RESOURCE),
  };
  Resource = Msp430Adc12C.Resource[ID];
  Msp430Adc12FastSingleChannel = Msp430Adc12C.FastSingleChannel[ID];
}

--- NEW FILE: Msp430Adc12FastSingleChannel.nc ---
/* 
 * Copyright (c) 2004, Technische Universitaet Berlin
 * 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 Technische Universitaet Berlin 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 THE COPYRIGHT
 * OWNER OR 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.
 *
 * - Revision -------------------------------------------------------------
 * $Revision: 1.1.2.1 $
 * $Date: 2006/07/07 15:17:54 $
 * @author: Jan Hauer <hauer at tkn.tu-berlin.de>
 * ========================================================================
 */

/** 
 * In contrast to the Msp430Adc12SingleChannel interface this interface
 * separates between configuration and sampling of the ADC and therefore allows
 * to minimize the time between the call to getSingleData and the start of
 * the sampling.
 * 
 * @author Jan Hauer 
 * @see  Please refer to TEP 101.
 */

#include <Msp430Adc12.h> 
interface Msp430Adc12FastSingleChannel 
{   

  /** 
   * Configures the ADC hardware. If SUCCESS is returned, every subsequent call
   * to <code>getSingleData()</code> will start the sampling immediately with
   * the specified configuration.  However, the configuration is valid only
   * until the ADC is released via the Resource interface (which is provided in
   * conjunction with this interface), i.e. it must be configured every time
   * the Resource interface grants access to the ADC (otherwise the
   * configuration state is undefined).
   * 
   * @param config ADC12 configuration data.  
   *
   * @return SUCCESS means subsequent calls to <code>getSingleData()</code>
   * will use the configuration.
   */
  async command error_t configure(const msp430adc12_channel_config_t *config);
  
  /** 
   * Samples an ADC channel once with the configuration passed in
   * <code>configure()</code>. If SUCCESS is returned, an event
   * <code>singleDataReady()</code> will be signalled with the conversion
   * result. Otherwise <code>singleDataReady()</code> will not be signalled.
   *
   * @param config ADC12 configuration data.  @return SUCCESS means conversion
   * data will be signalled in <code>singleDataReady()</code>.
   */
  async command error_t getSingleData(); 
  
   /** 
    * Data from a call to <code>getSingleData()</code> is ready.
    * 
    * @param data Conversion result (lower 12 bit).  
    */  
  async event void singleDataReady(uint16_t data); 
}


Index: Msp430Adc12C.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/adc12/Attic/Msp430Adc12C.nc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** Msp430Adc12C.nc	19 Jun 2006 11:12:23 -0000	1.1.2.8
--- Msp430Adc12C.nc	7 Jul 2006 15:17:54 -0000	1.1.2.9
***************
*** 50,53 ****
--- 50,54 ----
    provides interface Resource[uint8_t id]; 
    provides interface Msp430Adc12SingleChannel as SingleChannel[uint8_t id]; 
+   provides interface Msp430Adc12FastSingleChannel as FastSingleChannel[uint8_t id]; 
  } implementation { 
    components Msp430Adc12P,HplAdc12P, Msp430TimerC, MainC, HplMsp430GeneralIOC, 
***************
*** 56,59 ****
--- 57,61 ----
    Resource = Arbiter;
    SingleChannel = Msp430Adc12P.SingleChannel;
+   FastSingleChannel = Msp430Adc12P.FastSingleChannel;
    
    Arbiter.Init <- MainC;

Index: Msp430Adc12P.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/adc12/Attic/Msp430Adc12P.nc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** Msp430Adc12P.nc	6 Jun 2006 13:45:08 -0000	1.1.2.8
--- Msp430Adc12P.nc	7 Jul 2006 15:17:54 -0000	1.1.2.9
***************
*** 40,43 ****
--- 40,44 ----
      interface Init;
      interface Msp430Adc12SingleChannel as SingleChannel[uint8_t id];
+     interface Msp430Adc12FastSingleChannel as FastSingleChannel[uint8_t id]; 
  	}
  	uses {
***************
*** 71,74 ****
--- 72,76 ----
      ADC_BUSY = 1,               /* request pending */
      TIMERA_USED = 2,            /* TimerA used for SAMPCON signal */
+     FAST_MODE = 4,
    };
  
***************
*** 76,81 ****
    uint16_t resultBufferLength;   /* length of buffer */
    uint16_t resultBufferIndex;    /* offset into buffer */
!   uint8_t clientID;              /* ID of interface that issued current request */
!   uint8_t flags;                 /* current state, see above */
  
    // norace is safe, because Resource interface resolves conflicts  
--- 78,83 ----
    uint16_t resultBufferLength;   /* length of buffer */
    uint16_t resultBufferIndex;    /* offset into buffer */
!   norace uint8_t clientID;              /* ID of interface that issued current request */
!   norace uint8_t flags;                 /* current state, see above */
  
    // norace is safe, because Resource interface resolves conflicts  
***************
*** 191,196 ****
    }
  
!   async command error_t SingleChannel.getSingleData[uint8_t id](
!       const msp430adc12_channel_config_t *config)
    {
      error_t result;
--- 193,197 ----
    }
  
!   error_t configureSingleData(uint8_t id, const msp430adc12_channel_config_t *config)
    {
      error_t result;
***************
*** 234,242 ****
        call HplAdc12.setMCtl(0, memctl);
        call HplAdc12.setIEFlags(0x01);
!       call HplAdc12.startConversion();
      }
      return result;
    }
  
    async command error_t SingleChannel.getSingleDataRepeat[uint8_t id](
        const msp430adc12_channel_config_t *config,
--- 235,267 ----
        call HplAdc12.setMCtl(0, memctl);
        call HplAdc12.setIEFlags(0x01);
!       //call HplAdc12.startConversion();
      }
      return result;
    }
  
+   async command error_t SingleChannel.getSingleData[uint8_t id](
+       const msp430adc12_channel_config_t *config)
+   {
+     error_t result = configureSingleData(id, config);
+     if (result == SUCCESS)
+       call HplAdc12.startConversion();
+     return result;
+   }
+ 
+   async command error_t FastSingleChannel.configure[uint8_t id](const msp430adc12_channel_config_t *config)
+   {
+     return configureSingleData(id, config);
+   }
+   
+   async command error_t FastSingleChannel.getSingleData[uint8_t id]()
+   {
+     if (clientID == id){
+       flags |= FAST_MODE;
+       call HplAdc12.startConversion();
+       return SUCCESS;
+     }
+     return FAIL;
+   }
+ 
    async command error_t SingleChannel.getSingleDataRepeat[uint8_t id](
        const msp430adc12_channel_config_t *config,
***************
*** 434,439 ****
      { 
        case SINGLE_DATA:
!         stopConversionSingleChannel();
!         signal SingleChannel.singleDataReady[clientID](call HplAdc12.getMem(0));
          break;
        case SINGLE_DATA_REPEAT:
--- 459,474 ----
      { 
        case SINGLE_DATA:
!         if (flags & FAST_MODE){
! #ifdef P6PIN_AUTO_CONFIGURE
!           adc12memctl_t memctl = call HplAdc12.getMCtl(0);
!           resetAdcPin( memctl.inch );
! #endif
!           clientAccessFinished();
!           // stopConversionSingleChannel()
!           signal FastSingleChannel.singleDataReady[clientID](call HplAdc12.getMem(0));
!         } else {
!           stopConversionSingleChannel();
!           signal SingleChannel.singleDataReady[clientID](call HplAdc12.getMem(0));
!         }
          break;
        case SINGLE_DATA_REPEAT:
***************
*** 493,496 ****
--- 528,536 ----
    }
    
+   default async event void FastSingleChannel.singleDataReady[uint8_t id](uint16_t data)
+   {
+     return;
+   }
+   
    default async event uint16_t* SingleChannel.multipleDataReady[uint8_t id](
        uint16_t *buf, uint16_t length)

Index: Msp430Adc12SingleChannel.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/adc12/Attic/Msp430Adc12SingleChannel.nc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** Msp430Adc12SingleChannel.nc	19 Jun 2006 11:12:23 -0000	1.1.2.5
--- Msp430Adc12SingleChannel.nc	7 Jul 2006 15:17:54 -0000	1.1.2.6
***************
*** 165,168 ****
     */    
    async event uint16_t* multipleDataReady(uint16_t *buffer, uint16_t
!       numSamples); }
  
--- 165,169 ----
     */    
    async event uint16_t* multipleDataReady(uint16_t *buffer, uint16_t
!       numSamples); 
! }
  



More information about the Tinyos-2-commits mailing list