]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - doc/txt/tep101.txt
Update tos-bsl for win32 python
[tinyos-2.x.git] / doc / txt / tep101.txt
index eb78fa0bc8091fbef9de45d82d4556988c37a322..9b735cc22b841a4c1052b0fb1c81a1446dbc3b6d 100644 (file)
@@ -5,15 +5,10 @@ Analog-to-Digital Converters (ADCs)
 :TEP: 101
 :Group: Core Working Group 
 :Type: Documentary
-:Status: Draft
+:Status: Final
 :TinyOS-Version: 2.x
 :Author: Jan-Hinrich Hauer, Philip Levis, Vlado Handziski, David Gay
 
-:Draft-Created: 20-Dec-2004
-:Draft-Version: $Revision$
-:Draft-Modified: $Date$
-:Draft-Discuss: TinyOS Developer List <tinyos-devel at mail.millennium.berkeley.edu>
-
 .. Note::
 
    This memo documents a part of TinyOS for the TinyOS Community, and
@@ -25,31 +20,30 @@ Analog-to-Digital Converters (ADCs)
 Abstract
 ====================================================================
 
-This TEP proposes a hardware abstraction for TinyOS 2.x analog-to-digital
-converters (ADCs). It focuses on aligning the ADC abstraction with the
-three-layer Hardware Abstraction Architecture (HAA) described in [TEP2]_, but
-addresses only the HPL and HAL, because the highest level abstraction of an
-ADC is platform-dependent.
+This TEP proposes a hardware abstraction for analog-to-digital converters (ADCs)
+in TinyOS 2.x, which is aligned to the three-layer Hardware Abstraction
+Architecture (HAA) specified in [TEP2]_. It describes some design principles and
+documents the set of hardware-independent interfaces to an ADC.
 
 1. Introduction
 ====================================================================
 
 Analog-to-digital converters (ADCs) are devices that convert analog input
-signals to discrete digital output signals, typically voltage to a digital
+signals to discrete digital output signals, typically voltage to a binary
 number.  The interested reader can refer to Appendix A for a brief overview of
 the ADC hardware on some current TinyOS platforms.  In earlier versions of
 TinyOS, the distinction between a sensor and an ADC were blurred: this led
 components that had nothing to do with an ADC to still resemble one
 programatically, even though the semantics and forms of operation were
 completely different.  To compensate for the difference non-ADC sensors
-introduced additional interfaces, such as ADCError, that were tightly bound to
-sensor acquisition but separate in wiring. The separation between the ADC and
-ADCError interface is bug prone and problematic, as is the equation of a
-sensor and an ADC. TinyOS 2.x separates the structure and interfaces of an ADC
-from those of sensors (which may be on top of an ADC, but this fact is hidden
-from higher level components). This TEP presents how TinyOS 2.x decomposes and
-structures ADC software. TEP 109 (Sensor Boards) shows how a platform can
-present actual named sensors [TEP109]_.
+introduced additional interfaces, such as ``ADCError``, that were tightly bound
+to sensor acquisition but separate in wiring. The separation between the ADC
+and ``ADCError`` interface is bug prone and problematic, as is the equation of
+a sensor and an ADC. TinyOS 2.x separates the structure and interfaces of an
+ADC from those of sensor drivers (which may be on top of an ADC stack, but
+this fact is hidden from higher level components). This TEP presents how TinyOS
+2.x structures ADC software. [TEP109]_ (Sensor Boards) shows how a platform can
+present actual named sensors
 
 As can be seen in Appendix A the ADC hardware used on TinyOS platforms differ
 in many respects, which makes it difficult to find a chip independent
@@ -58,318 +52,427 @@ configuration details of an ADC would still depend on the actual device
 producing the input signal (sensor).  Neither a platform independent
 application nor the ADC hardware stack itself has access to this information,
 as it can only be determined on a platform or sensorboard level. For example,
-determining which ADC port a sensor is attached to and how a conversion result
-is to be interpreted is a platform-specific determination. 
+determining which ADC port a sensor is attached to and how conversion results
+need to be interpreted is a platform specific determination. Although the
+actual configuration details may be different the procedure of configuring an
+ADC can be unified on all ADCs with the help of **hardware independent
+interfaces**: in a similar way as the ``Read`` interface definition does not
+predefine the type or semantics of the exchanged data (see [TEP114]_), a
+configuration interface definition can abstract from the data type and
+semantics of the involved configuration settings.  For example, like a
+component can provide a ``Read<uint8_t>`` or ``Read<uint16_t>`` interface, it
+can also provide a ``AdcConfigure<atm128_adc_config_t>`` or
+``AdcConfigure<msp430adc12_channel_config_t>`` interface depending on what ADC
+it represents.  This TEP proposes the (typed) ``AdcConfigure`` interface as the
+standard interface for configuring an ADC in TinyOS 2.x.
 
 In spite of their hardware differences, one aspect represents a common
-denominator of all ADCs: they produce conversion results. In order to
-facilitate sensor software development this capability can be made available
-via chip-independent interfaces for every ADC. However, conversion results
-depend on and have to be interpreted with respect to the platform-specific
-configuration settings (the ADC channel, the applied reference voltage, etc.).
-Therefore the highest level of ADC abstraction consists of
-platform-independent interfaces for ADC data collection and chip-specific
-interfaces for ADC hardware configuration.  The top layer of the ADC stack
-thus remains platform-dependent and consequently the ADC abstraction does not
-include an HIL, but ends with the HAL. Following the principles of the
-HAA [TEP2]_ the HAL of an ADC should also expose the chip-specific capabilities
-for ADC data collection. For example, the ADC12 on the MSP430 MCU supports a
-complex repeat conversion mode for a set of different input channels, which is
-too specific to be represented by a platform-independent data collection
-interface.  Therefore the HAL of an ADC abstraction is broken into two
-sublayers: The bottom HAL layer, called HAL1, exposes the full capabilities of
-the respective ADC in a chip-specific way. It realizes the standard HAL in the
-HAA [TEP2]_ and the HPL lies below it.  On top of the HAL1 sits the HAL2 which
-maps the interfaces it uses from HAL1 to a set of platform-independent
-interfaces for data collection and chip-specific configuration interfaces.
+denominator of ADCs: they all produce conversion results. To facilitate sensor
+software development conversion results are returned by the ADC stack through
+the interfaces ``Read``, ``ReadStream`` and ``ReadNow`` (see `2.  Interfaces`_
+and [TEP114]_).  Conversion results are returned as uninterpreted values and
+translating them to engineering units can only be done with the configuration
+knowledge of the respective platform, for example, the reference voltage or the
+resistance of a reference resistor in ratiometric measurements.  Translating
+uninterpreted values to engineering units may be performed by components
+located on top of the ADC stack and is out of the scope of this TEP.
+
+The top layer of abstraction of an ADC - the Hardware Interface Layer (HIL) -
+thus provides the interfaces ``Read``, ``ReadNow`` and ``ReadStream`` and uses
+the ``AdcConfigure`` interface for hardware configuration (why it **uses** and
+does not **provide** ``AdcConfigure`` is explained below).  Since the type and
+semantics of the parameters passed through these interfaces is dependent on the
+actual ADC implementation, it is only a "weak" HIL (see [TEP2]_).
+
+Following the principles of the HAA [TEP2]_ the Hardware Adaptation Layer (HAL,
+which resides below the HIL) of an ADC should expose all the chip-specific
+capabilities of the chip.  For example, the ADC12 on the MSP430 MCU supports a
+"Repeat-Sequence-of-Channels Mode" and therefore this function should be
+accessible on the HAL of the MSP430 ADC12 hardware abstraction.  Other ADCs
+might not exhibit such functionality and might therefore - on the level of HAL
+- provide only an interface to perform single conversions. Since all ADCs have
+the same HIL representation it may be necessary to perform some degree of
+software emulation in the HIL implementation.  For example, a ``ReadStream``
+command can be emulated by multiple single conversion commands. Below the HAL
+resides the Hardware Presentation Layer (HPL), a stateless component that
+provides access to the hardware registers (see [TEP2]_). The general structure
+(without virtualization) of the ADC stack is as follows ::
+
+
+        ^                     |
+        |                     |
+        |                   Read,
+  AdcConfigure              ReadNow (+ Resource),
+        |                   ReadStream
+        |                     |
+        |                     V
+  +----------------------------------+
+  |  Hardware Interface Layer (HIL)  |
+  |  (chip-specific implementation)  |
+  +----------------------------------+
+                   |
+                   |
+    chip-specific interface(s) + Resource
+ (e.g. Msp430Adc12SingleChannel + Resource)
+                   |
+                   V
+  +----------------------------------+
+  |  Hardware Adaptation Layer (HAL) |
+  |  (chip-specific implementation)  |
+  +----------------------------------+
+                   |
+                   |
+         chip-specific interface(s)
+             (e.g. HplAdc12)
+                   |
+                   V
+  +----------------------------------+
+  | Hardware Presentation Layer (HPL)|
+  | (chip-specific implementation)   |
+  +----------------------------------+
+
 
 The rest of this TEP specifies:
 
-* the set of platform-independent interfaces for the collection of ADC
-  conversion results (`2. Interfaces`_)
-* guidelines on how an ADC's HAL SHOULD should be split into HAL1 and HAL2 and
-  how the HAL1 SHOULD expose chip-specific interfaces (`3. HAL1 guidelines`_)
-* what components an ADC's HAL2 MUST implement (`4. HAL2 requirements`_)
-* guidelines on how the HAL2 may be structured (`5. HAL2 implementation guidelines`_)
+* the set of standard TinyOS interfaces for collecting ADC conversion
+  results and for configuring an ADC (`2. Interfaces`_)
+* guidelines on how an ADC's HAL should expose chip-specific 
+  interfaces (`3. HAL guidelines`_)
+* what components an ADC's HIL MUST implement (`4. HIL requirements`_)
+* guidelines on how the HIL should be implemented 
+  (`5. HIL guidelines`_)
+* a section pointing to current implementations (`6. Implementation`_)
 
-This TEP ends with appendices documenting, as an example, the ADC
-implementation for the TI MSP430 MCU.
+This TEP ends with appendices documenting, as an example, the ADC implementation
+for the TI MSP430 MCU.
 
 
 2. Interfaces
 ====================================================================
 
-This TEP proposes to adopt the following three generic, source-independent
-data collection interfaces from [TEP114]_ for the collection of ADC conversion
-results::
+This TEP proposes the ``AdcConfigure`` interface for ADC hardware configuration
+and the ``Read``, ``ReadStream`` and ``ReadNow`` interfaces to acquire
+conversion results. The ``Read`` and ``ReadStream`` interfaces are documented
+in [TEP114]_ and the ``ReadNow`` interface is documented in this TEP.  A
+``Read[Now|Stream]`` interface is always provided in conjunction with a
+``AdcConfigure`` interface.
+
+Interface for configuring the ADC hardware
+--------------------------------------------------------------------
+
+The ``AdcConfigure`` interface is defined as follows::
+
+  interface AdcConfigure< config_type > 
+  {
+    async command config_type getConfiguration(); 
+  }
+
+This interface is used by the ADC stack to retrieve the hardware configuration
+of an ADC HIL client. ``config_type`` is a chip-specific data type (simple or
+structured) that contains all information necessary to configure the respective
+ADC hardware. For example, on the ADC12 of the MSP430 the ``AdcConfigure``
+interface will be instantiated with the ``const msp430adc12_channel_config_t*``
+data type. A client MUST always return the same configuration through a
+``AdcConfigure`` interface and, if configuration data is passed as a pointer,
+the HIL component (see `4. HIL requirements`_) MUST NOT reference it after the
+return of the ``getConfiguration()`` command. If a client wants to use the ADC
+with different configurations it must provide multiple instances of the
+``AdcConfigure`` interface.
+
+Note that the ``AdcConfigure`` interface is **provided** by an ADC HIL client
+and it is **used** by the ADC HIL implementation. Therefore an ADC HIL client
+cannot initiate the configuration of the ADC hardware itself. Instead it is the
+ADC HIL implementation that can "pull" the client's ADC configuration just
+before it initates a conversion based on the respective client's configuration.
+The rationale is that the ADC HIL implementation does not have to store an ADC
+configuration per client - instead the ADC client can, for example, store its
+configuration in program memory.
+
+Interfaces for acquiring conversion results
+--------------------------------------------------------------------
+   
+This TEP proposes to adopt the following two source-independent data
+collection interfaces from [TEP114]_ for the collection of ADC conversion
+results on the level of HIL::
 
   interface Read< size_type >
-  interface ReadNow< size_type >
   interface ReadStream< size_type >
 
-Every data collection interface is associated with certain chip-specific
-configuration data (e.g. input channel, sample-hold-time, etc.).  How this
-association can be realized is explained in Section `4.  HAL2 requirements`_.
-As the resolution of conversion results is chip-specific, the 'size_type'
-parameter reflects an upper bound for the chip-specific resolution of the
-conversion results - the actual resolution may be smaller, depending on the
-ADC and/or data source (e.g.  uint16_t for a 12-bit ADC). The above interfaces
-are specified in [TEP114]_, in the following their usage is explained with
-respect to ADCs.
+In addition it proposes the following data collection interface for low-latency
+reading of conversion results::
+
+  interface ReadNow< size_type >
+  
+Every data collection interface is associated with an ``AdcConfigure``
+interface (how this association is realized is explained in Section `4.  HIL
+requirements`_).  As the resolution of conversion results is chip-specific, the
+``size_type`` parameter reflects an upper bound for the chip-specific
+resolution of the conversion results - the actual resolution may be smaller
+(e.g.  uint16_t for a 12-bit ADC).
 
 Read
---------------------------------------------------------------------
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-The Read interface can be used to sample an ADC channel and return a single
-conversion result. It provides no guarantees about when exactly the sampling
-occurs (the request may be buffered). 
+The ``Read`` interface can be used to sample an ADC channel once and return a
+single conversion result as an uninterpreted value. The ``Read`` interface is
+documented in [TEP114]_.
+
+ReadStream
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``ReadStream`` interface can be used to sample an ADC channel multiple
+times with a specified sampling period. The ``ReadStream`` interface is
+documented in [TEP114]_ .
 
 ReadNow
---------------------------------------------------------------------
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-The ReadNow interface provides more precise control over the time of the
-sampling: If a call to ReadNow.read() succeeds, the ADC starts to sample the
-channel immediately (the request is not buffered). Due to its timing
-constraints the ReadNow interface is always provided in conjunction with an
-instance of the Resource interface. A client MUST request access to the ADC
-via the Resource interface before it can call ReadNow.read() and it MUST
-release access via the Resource interface when it is finished (see [TEP108]_).
+The ``ReadNow`` interface is intended for split-phase low-latency
+reading of small values::
 
-ReadStream
---------------------------------------------------------------------
+  interface ReadNow<val_t> 
+  {
+    async command error_t read();
+    async event void readDone( error_t result, val_t val );
+  }
 
-The ReadStream interface can be used to sample an ADC channel multiple times
-with a specified sampling period. It provides no guarantees about when exactly
-the first sampling occurs, but all subsequent samplings occur with the
-specified sampling period.
+This interface is similar to the ``Read`` interface, but works in asynchronous
+context. A successful call to ``ReadNow.read()`` means that the ADC hardware
+has started the sampling process and that ``ReadNow.readDone()`` will be
+signalled once it has finished (note that the asynchronous
+``ReadNow.readDone()`` might be signalled even before the call to
+``ReadNow.read()`` has returned).  Due to its timing constraints the
+``ReadNow`` interface is always provided in conjunction with an instance of the
+``Resource`` interface and a client must reserve the ADC through the
+``Resource`` interface before the client may call ``ReadNow.read()``.  Please
+refer to [TEP108]_ on how the ``Resource`` interface should be used by a client
+component.
 
 
-3. HAL1 guidelines
+3. HAL guidelines
 ====================================================================
 
-As explained in `1. Introduction`_ the HAL of an ADC abstraction consists of
-two sublayers, HAL1 and HAL2. In the ADC component stack the HAL1 resides
-below HAL2 and above the HPL. It exposes the full capabilities of the ADC in a
-chip-specific way and has the same function as the 'traditional' HAL in the
-HAA [TEP2]_. Therefore only chip- and platform-dependent clients MAY wire to
-the HAL1. Although the HAL1 is chip-specific, both, in terms of implementation
-and representation, its design SHOULD follow the guidelines described below to
-facilitate the mapping to platform-independent interfaces on the level of
-HAL2. Appendix B shows the HAL1 specification for the TI MSP430 MCU.
+As explained in `1. Introduction`_ the HAL exposes the full capabilities of the
+ADC hardware. Therefore only chip- and platform-dependent clients can wire to
+the HAL. Although the HAL is chip-specific, both, in terms of implementation
+and representation, its design should follow the guidelines described in this
+section to facilitate the mapping to the HIL representation. Appendix B shows
+the signature of the HAL for the MSP430.
 
 Resource reservation
 --------------------------------------------------------------------
 
-As the ADC hardware is a shared resource that is multiplexed between several
-clients, it requires access arbitration. Therefore the HAL1 configuration
-component SHOULD provide a parameterized 'Resource' interface, instantiate a
-generic arbiter component and connect the 'Resource' interface to the arbiter
-as described in [TEP108]_. To provide a uniform arbitration service for all
-platforms on the level of HAL2 (see `4. HAL2 requirements`_), all ADCs should
-be arbitrated in round robin fashion, i.e. the HAL1 SHOULD instantiate the
-standard round robin arbiter. On the level of HAL1 a client MUST have
-successfully requested access to the ADC via the 'Resource' interface before
-it can configure / sample a channel. After use it MUST release the ADC via the
-'Resource' interface (see [TEP108]_).
+As the ADC hardware is a shared resource that is usually multiplexed between
+several clients some form of access arbitration is necessary.  The HAL should
+therefore provide a parameterized ``Resource`` interface, instantiate a
+standard arbiter component and connect the ``Resource`` interface to the
+arbiter as described in [TEP108]_. To ensure fair and uniform arbitration on
+all platforms the standard round robin arbiter is recommended. Resource
+arbiters and the ``Resource`` interface are the topic of [TEP108]_.
 
 Configuration and sampling
 --------------------------------------------------------------------
 
-As the ADC hardware is a shared resource the HAL1 SHOULD support hardware
-configuration and sampling on a per-client basis (although per-port
-configuration is possible, it is not recommended, because it forces all
-clients to use the same settings for a given port). Therefore an HAL1 SHOULD
-provide "sampling interfaces" parameterized by a client identifier. An HAL1
-client can use its instance of the sampling interface to configure the ADC
-hardware, start the sampling process and get conversion results. It wires to a
-sampling interface using a unique client identifier. All commands and events
-in the sampling interface SHOULD be 'async' to reflect the potential timing
-requirements of clients. An HAL1 MAY provide multiple different parameterized
-sampling interfaces, depending on the hardware capabilities.  This allows to
+As the ADC hardware is a shared resource the HAL should support hardware
+configuration and sampling per client (although per-port configuration is
+possible, it is not recommended, because it forces all clients to use the same
+configuration for a given port).  Therefore the HAL should provide sampling
+interfaces parameterized by a client identifier. A HAL client can use its
+instance of the sampling interface to configure the ADC hardware, start the
+sampling process and acquire conversion results. It wires to a sampling
+interface using a unique client identifier (this may be hidden by a
+virtualization component). All commands and events in the sampling interface
+should be 'async' to reflect the potential timing requirements of clients on
+the level of HAL. A HAL may provide multiple different parameterized sampling
+interfaces, depending on the hardware capabilities.  This allows to
 differentiate/group ADC functionality, for example single vs.  repeated
-sampling, single channel vs. multiple channels or low-frequency vs.
-high-frequency sampling.  Every sampling interface SHOULD allow the client to
+sampling, single channel vs.  multiple channels or low-frequency vs.
+high-frequency sampling.  Every sampling interface should allow the client to
 individually configure the ADC hardware, for example by including the
 configuration data as parameters in the sampling commands.  However, if
-configuration data is passed as a pointer, the HAL1 component MUST NOT
-reference it after the return of the respective command. Appendix B shows the
-HAL1 interfaces for the TI MSP430 MCU.
+configuration data is passed as a pointer, the HAL component MUST NOT reference
+it after the return of the respective command.  Appendix B shows the HAL
+interfaces for the MSP430.
 
-HAL1 virtualization
+HAL virtualization
 --------------------------------------------------------------------
 
 In order to hide wiring complexities and/or export only a subset of all ADC
-functions generic ADC wrapper components MAY be provided on the level of HAL1
-to be instantiated by chip- and platform-dependent clients.
+functions generic ADC wrapper components may be provided on the level of HAL.
+Such components can also be used to ensure that a sampling interface is always
+provided with a ``Resource`` interface and both are instantiated with the same
+client ID if this is required by the HAL implementation.
 
 
-4. HAL2 requirements
+4. HIL requirements
 ====================================================================
 
-The following components MUST be provided on all platforms that have an ADC::
+The following generic components MUST be provided on all platforms that have an
+ADC::
 
-  AdcReadClient 
-  AdcReadNowClient 
-  AdcReadStreamClient 
+  AdcReadClientC 
+  AdcReadNowClientC 
+  AdcReadStreamClientC 
 
-These generic components are instantiated and provide access to the ADC  on a
-per-client basis via a platform-independent interface for data collection and
-a chip-specific ADC configuration interface. This section describes the
-representation of the HAL2. Guidelines on how the HAL2 can be implemented are
-discussed in Section `5. HAL2 implementation guidelines`_.  Appendix C shows
-the AdcReadClient for the TI MSP430 MCU.  
+These components provide virtualized access to the HIL of an ADC. They are
+instantiated by an ADC client and provide/use the four interfaces described in
+Section `2.  Interfaces`_. An ADC client may instantiate multiple such
+components. The following paragraphs describe their signatures. Note that this
+TEP does not address the issue of how to deal with multiple ADCs on the same
+platform (the question of how to deal with multiple devices of the same class
+is a general one in TinyOS 2.x). Appendix C shows the ``AdcReadClientC`` for
+the MSP430.
 
-The fact that the components use chip-specific ADC configuration interfaces
-(see below) and the fact that the provided interfaces for data-collection must
-be interpreted with respect to the configuration data - for example the
-reference voltage - makes the HAL2 representation chip dependent. Therefore
-the ADC abstraction does not include an HIL.
 
-AdcReadClient
+AdcReadClientC
 --------------------------------------------------------------------
 ::
 
-  generic configuration AdcReadClient() {
+  generic configuration AdcReadClientC() {
     provides {
       interface Read< size_type >;
     }
     uses {
-      // chip-dependent configuration interface
+      interface AdcConfigure< config_type >;
     }
   }
 
-The AdcReadClient provides platform-independent access for data collection via
-the 'Read' interface. The actual ADC channel (port) and further configuration
-details are determined by a chip-dependent configuration interface. It is the
-task of the client to wire this interface to a component that provides its ADC
-configuration.  The HAL2 implementation will use this interface to "pull" the
-client's ADC settings when it translates the 'Read.read()' command to a
-chip-specific sampling command. The resolution of the conversion result is
-chip-specific, the 'size_type' parameter represents an upper bound for the
-resolution of the conversion results.
-
-AdcReadNowClient
+The ``AdcReadClientC`` component provides a ``Read`` interface for acquiring
+single conversion results. The associated ADC channel (port) and further
+configuration details are returned by the ``AdcConfigure.getConfiguration()``
+command. It is the task of the client to wire this interface to a component
+that provides the client's ADC configuration. The HIL implementation will use
+the ``AdcConfigure`` interface to dynamically "pull" the client's ADC settings
+when it translates the ``Read.read()`` command to a chip-specific sampling
+command.  Note that both, ``size_type`` and ``config_type``, are only
+placeholders and will be instantiated by the respective HIL implementation (for
+an example, see the AdcReadClientC for the MSP430 in Appendix C).
+
+AdcReadNowClientC
 --------------------------------------------------------------------
 ::
 
-  generic configuration AdcReadNowClient() {
+  generic configuration AdcReadNowClientC() {
     provides {
       interface Resource;
       interface ReadNow< size_type >;
     }
     uses {
-       // chip-dependent configuration interface
+      interface AdcConfigure< config_type >;
     }
   }
 
-The AdcReadNowClient provides platform-independent access for data collection
-via the 'ReadNow' and 'Resource' interface. The actual ADC channel (port) and
-further configuration details are determined by a chip-dependent configuration
-interface. It is the task of the client to wire this interface to a component
-that provides its ADC configuration.  The HAL2 implementation will use this
-interface to "pull" the client's ADC settings when it translates the
-'ReadNow.read()' command to a chip-specific sampling command. A client MUST
-use the 'Resource' interface to request access to the ADC as described in
-[TEP108]_ (the HAL2 implementation SHOULD return the error code 'ERESERVE' if
-the client has not reserved access). The resolution of the conversion result
-is chip-specific, the 'size_type' parameter represents an upper bound for the
-resolution of the conversion result.
-
-AdcReadStreamClient
+The ``AdcReadNowClientC`` component provides a ``ReadNow`` interface for
+acquiring single conversion results. In contrast to ``Read.read()`` when a call
+to ``ReadNow.read()`` succeeds, the ADC starts to sample the channel
+immediately (a successful ``Read.read()`` command may not have this
+implication, see [TEP114]_ and `2. Interfaces`_). A client MUST reserve the ADC
+through the ``Resource`` interface before the client may call
+``ReadNow.read()`` and it MUST release the ADC through the ``Resource``
+interface when it no longer needs to access it (for more details on how to use
+the ``Resource`` interface please refer to [TEP108]_).  The associated ADC
+channel (port) and further configuration details are returned by the
+``AdcConfigure.getConfiguration()`` command. It is the task of the client to
+wire this interface to a component that provides the client's ADC
+configuration.  The HIL implementation will use the ``AdcConfigure`` interface
+to dynamically "pull" the client's ADC settings when it translates the
+``ReadNow.read()`` command to a chip-specific sampling command. Note that both,
+``size_type`` and ``config_type``, are only placeholders and will be
+instantiated by the respective HIL implementation (for an example how this is
+done for the AdcReadClientC see Appendix C).
+
+AdcReadStreamClientC
 --------------------------------------------------------------------
 ::
 
-  generic configuration AdcReadStreamClient() {
+  generic configuration AdcReadStreamClientC() {
     provides {
       interface ReadStream< size_type >;
     }
     uses {
-       // chip-dependent configuration interface
+      interface AdcConfigure< config_type>;
     }
   }
 
-The AdcReadStreamClient provides platform-independent access for data
-collection via the 'ReadStream' interface. The actual ADC channel (port) and
-further configuration details are determined by a chip-dependent configuration
-interface. It is the task of the client to wire this interface to a component
-that provides its ADC configuration.  The HAL2 implementation will use this
-interface to "pull" the client's ADC settings when it translates the
-'ReadStream.read()' command to a chip-specific sampling command. The
-resolution of the conversion results is chip-specific, the 'size_type'
-parameter represents an upper bound for the resolution of the conversion
-results.
-
-5. HAL2 implementation guidelines
+The ``AdcReadStreamClientC`` component provides a ``ReadStream`` interface for
+acquiring multiple conversion results at once. The ``ReadStream`` interface is
+explained in [TEP114]_ and `2. Interfaces`_. The ``AdcConfigure`` interface is
+used in the same way as described in the section on the ``AdcReadClientC``.
+Note that both, ``size_type`` and ``config_type``, are only placeholders and
+will be instantiated by the respective HIL implementation (for an example how
+this is done for the AdcReadClientC see Appendix C).
+
+5. HIL guidelines
 ====================================================================
 
-The HAL2 implementation of an ADC stack has two main tasks: It translates a
-platform-independent HAL2 request (from the 'Read', 'ReadNow' or 'ReadStream'
-interface) to a chip-specific HAL1 sampling command and it abstracts from the
-'Resource' interface. The first task cannot be solved in a chip-independent
-way, because it involves chip-specific configuration data. The second task MAY
-be performed by the following library components: ArbitratedReadC, and
-ArbitratedReadStreamC (in tinyos-2.x/tos/system) - refer to the Atmel Atmega
-128 HAL2 implementation (in tinyos-2.x/tos/chips/atm128/adc), for an example.
-Note that since the 'ReadNow' interface is always provided in conjunction with
-a 'Resource' interface the HAL2 implementation does not have to perform the
-ADC resource reservation in this case, but can simply forward an instance of
-the 'Resource' interface from the HAL1 (to AdcReadNowClient).
-
-To support multiple ADC clients the HAL2 implementation should provide
-parameterized 'Read', 'ReadNow' and 'ReadStream' interfaces as well as a
-parameterized chip-specific configuration interface. It should also use an
-instance of the 'Resource' interface (provided by the HAL1) per provided
-'Read' and 'ReadStream' interface to perform automatic resource reservation.
-The HAL2 representation ('AdcReadClient', 'AdcReadNowClient' and
-'AdcReadStreamClient') should ensure the correct wiring between the HAL1 and
-HAL2.
-
-From the perspective of the HAL2 the typical sequence of events is as follows:
-After a client has requested data via the 'Read' or 'ReadStream' interface the
-HAL2 will request access to the HAL1 via the 'Resource' interface, e.g. using
-the library components mentioned above.  When it is signalled the 'granted'
-event, the HAL2 will 'pull' the client's ADC settings and translate the
-client's command to a chip-specific HAL1 sampling command. Once it is
-signalled the conversion result(s) it releases the ADC via the 'Resource'
-interface and forwards the conversion result(s) to the client. When a client
-has requested data via the 'ReadNow' interface the HAL2 translates the
-client's command to the chip-specific HAL1 sampling command without using the
-'Resource' interface (it may check ownership of the client via the
-'ArbiterInfo' interface). In order to reduce state in the HAL2 and facilitate
-the mapping between used and provided interfaces the 'AdcReadClient',
-'AdcReadNowClient' and 'AdcReadStreamClient' should use the same interface
-identifier when it connects the HAL2 to HAL1 (see, for example, the MSP430
-ADC12 implementation in Appendix C).
+The HIL implementation of an ADC stack has two main tasks: it translates a
+``Read``, ``ReadNow`` or ``ReadStream`` request to a chip-specific HAL sampling
+command and it abstracts from the ``Resource`` interface (the latter only for
+the ``AdcReadClientC`` and ``AdcReadStreamClientC``). The first task is solved
+with the help of the ``AdcConfigure`` interface which is used by the HIL
+implementation to retrieve a client's ADC configuration.  The second task MAY
+be performed by the following library components: ``ArbitratedReadC``, and
+``ArbitratedReadStreamC`` (in tinyos-2.x/tos/system) - please refer to the
+Atmel Atmega 128 HAL implementation (in tinyos-2.x/tos/chips/atm128/adc) for an
+example.  Note that since the ``ReadNow`` interface is always provided in
+conjunction with a ``Resource`` interface the HIL implementation does not have
+to perform the ADC resource reservation for an ``AdcReadNowClientC``, but may
+simply forward an instance of the ``Resource`` interface from the HAL to the
+``AdcReadNowClientC``.
+
+The typical sequence of events is as follows: when a client requests data
+through the ``Read`` or ``ReadStream`` interface the HIL will request access to
+the HAL using the ``Resource`` interface.  After the HIL has been granted
+access, it will "pull" the client's ADC configuration using the
+``AdcConfigure`` interface and translate the client's ``Read`` or
+``ReadStream`` command to a chip-specific HAL command. Once the HIL is
+signalled the conversion result(s) from the HAL it releases the ADC through the
+``Resource`` interface and signals the conversion result(s) to the client
+though the ``Read`` or ``ReadStream`` interface.  When a client requests data
+through the ``ReadNow`` interface the HIL translates the client's command to
+the chip-specific HAL command without using the ``Resource`` interface (it may
+check ownership of the client through the ``ArbiterInfo`` interface - this
+check can also be done in the HAL implementation). Once the HIL is signalled
+the conversion result(s) it forwards it to the respective ``ReadNow`` client.
 
 6. Implementation
 ====================================================================
 
+TestAdc application
+--------------------------------------------------------------------
+
+An ADC HIL test application can be found in ``tinyos-2.x/apps/tests/TestAdc``.
+Note that this application instantiates generic DemoSensorC, DemoSensorStreamC
+and DemoSensorNowC components (see [TEP114]_) and assumes that these components
+are actually wired to an ADC HIL. Please refer to
+``tinyos-2.x/apps/tests/TestAdc/README.txt`` for more information.
+
+
+HAA on the MSP430 and Atmega 128
+--------------------------------------------------------------------
+
 The implementation of the ADC12 stack on the MSP430 can be found in
 ``tinyos-2.x/tos/chips/msp430/adc12``:
 
   * ``HplAdc12P.nc`` is the HPL implementation
-  * ``Msp430Adc12P.nc`` is the HAL1 implementation
-  * ``AdcC.nc`` is the HAL2 implementation
+  * ``Msp430Adc12P.nc`` is the HAL implementation
+  * ``AdcP.nc`` is the HIL implementation
   * ``AdcReadClientC.nc``, ``AdcReadNowClientC.nc`` and
-    ``AdcReadStreamClientC.nc`` provide access to the ADC on a per-client
-    basis via the interfaces 'Read', 'ReadNow' and 'ReadStream', 
-    respectively, and the msp430-specific ADC configuration 
-    interface ``Msp430Adc12Config.nc``
+    ``AdcReadStreamClientC.nc`` provide virtualized access to the HIL
+  * the use of DMA or the reference voltage generator and the
+    HAL virtualization components are explained in ``README.txt``
 
 The Atmel Atmega 128 ADC implementation can be found in
 ``tinyos-2.x/tos/chips/atm128/adc``:
 
   * ``HplAtm128AdcC.nc`` is the HPL implementation
-  * ``Atm128AdcP.nc`` is the HAL1 implementation
-  * ``WireAdcP.nc`` and the library components for arbitrating 'Read', 
-    'ReadNow' and 'ReadStream', ``ArbitratedReadC`` and
+  * ``Atm128AdcP.nc`` is the HAL implementation
+  * ``AdcP.nc``, ``WireAdcP.nc`` and the library components for arbitrating 
+    'Read', 'ReadNow' and 'ReadStream', ``ArbitratedReadC`` and
     ``ArbitratedReadStreamC`` (in ``tinyos-2.x/tos/system``), realize
-    the HAL2
+    the HIL
   * ``AdcReadClientC.nc``, ``AdcReadNowClientC.nc`` and
-    ``AdcReadStreamClientC.nc`` provide access to the ADC on a per-client
-    basis via the platform-independent interfaces 'Read', 'ReadNow' and
-    'ReadStream', respectively, and the atmega-specific ADC configuration 
-    interface ``Atm128AdcConfig.nc``
+    ``AdcReadStreamClientC.nc`` provide virtualized access to the HIL
 
 
 Appendix A: Hardware differences between platforms
@@ -438,78 +541,63 @@ commonly used in TinyOS platforms:
 +----------------------+----------------------+---------------------+
 
 
-Appendix B: an HAL1 representation: MSP430 ADC12
+Appendix B: a HAL representation: MSP430 ADC12
 ====================================================================
 
-The following shows the HAL1 representation for the ADC12 of the TI MSP430
-MCU. It reflects the four MSP430 ADC12 conversion modes as it lets a client
-sample an ADC channel once ("Single-channel-single-conversion") or repeatedly
+This section shows the HAL signature for the ADC12 of the TI MSP430 MCU. It
+reflects the four MSP430 ADC12 conversion modes as it lets a client sample an
+ADC channel once ("Single-channel-single-conversion") or repeatedly
 ("Repeat-single-channel"), multiple times ("Sequence-of-channels") or multiple
 times repeatedly ("Repeat-sequence-of-channels"). In contrast to the single
 channel conversion modes the sequence conversion modes trigger a single
-interrupt after multiple samples and thus enable high-frequency sampling (a
-sequence conversion mode for multiple different channels is not (yet)
-implemented).::
+interrupt after multiple samples and thus enable high-frequency sampling. The
+``DMAExtension`` interface is used to reset the state machine when the DMA is
+responsible for data transfer (managed in an exterior component)::
 
-  configuration Msp430Adc12C 
+  configuration Msp430Adc12P 
   { 
-    provides interface Resource[uint8_t id]; 
-    provides interface Msp430Adc12SingleChannel as SingleChannel[uint8_t id]; 
-  }  
+    provides {
+      interface Resource[uint8_t id]; 
+      interface Msp430Adc12SingleChannel as SingleChannel[uint8_t id]; 
+      interface AsyncStdControl as DMAExtension[uint8_t id];
+    }
+  }
 
   interface Msp430Adc12SingleChannel 
   {   
-    async command error_t getSingleData(const msp430adc12_channel_config_t *config);
-    async command error_t getSingleDataRepeat(const msp430adc12_channel_config_t *config, 
-      uint16_t jiffies);
-    async command error_t getMultipleData( const msp430adc12_channel_config_t *config,
-      uint16_t *buffer, uint16_t numSamples, uint16_t jiffies);
-    async command error_t getMultipleDataRepeat(const msp430adc12_channel_config_t *config, 
-      uint16_t *buffer, uint8_t numSamples, uint16_t jiffies);
+    async command error_t configureSingle(const msp430adc12_channel_config_t *config);
+    async command error_t configureSingleRepeat(const msp430adc12_channel_config_t *config, uint16_t jiffies);
+    async command error_t configureMultiple( const msp430adc12_channel_config_t *config, uint16_t buffer[], uint16_t numSamples, uint16_t jiffies);
+    async command error_t configureMultipleRepeat(const msp430adc12_channel_config_t *config, uint16_t buffer[], uint8_t numSamples, uint16_t jiffies);
+    async command error_t getData();
     async event error_t singleDataReady(uint16_t data);
-    async event uint16_t* multipleDataReady(uint16_t *buffer, uint16_t
-      numSamples); 
+    async event uint16_t* multipleDataReady(uint16_t buffer[], uint16_t numSamples); 
   }
 
-There exist two wrapper components, Msp430Adc12ClientC and
-Msp430Adc12RefVoltAutoClientC, which SHOULD be used to eliminate wiring
-errors.
-
-Appendix C: an HAL2 representation: MSP430 ADC12
+  typedef struct 
+  { 
+    unsigned int inch: 4;            // input channel 
+    unsigned int sref: 3;            // reference voltage 
+    unsigned int ref2_5v: 1;         // reference voltage level 
+    unsigned int adc12ssel: 2;       // clock source sample-hold-time 
+    unsigned int adc12div: 3;        // clock divider sample-hold-time 
+    unsigned int sht: 4;             // sample-hold-time
+    unsigned int sampcon_ssel: 2;    // clock source sampcon signal 
+    unsigned int sampcon_id: 2;      // clock divider sampcon signal
+  } msp430adc12_channel_config_t;
+
+
+Appendix C: a HIL representation: MSP430 ADC12
 ====================================================================
 
-The AdcReadClientC component for the MSP430 ADC12 is implemented as follows:
-::
+The signature of the AdcReadClientC component for the MSP430 ADC12 is as
+follows::
 
   generic configuration AdcReadClientC() {
     provides interface Read<uint16_t>;
-    uses interface Msp430Adc12Config;
-  } implementation {
-    components AdcC;
-  #ifdef REF_VOLT_AUTO_CONFIGURE     
-    components new Msp430Adc12RefVoltAutoClientC() as Msp430AdcClient;
-  #else
-    components new Msp430Adc12ClientC() as Msp430AdcClient;
-  #endif
-
-    enum {
-      CLIENT = unique(ADCC_SERVICE),
-    };
-
-    Read = AdcC.Read[CLIENT];
-    Msp430Adc12Config = AdcC.Config[CLIENT];
-    AdcC.SingleChannel[CLIENT] -> Msp430AdcClient.Msp430Adc12SingleChannel;
-    AdcC.Resource[CLIENT] -> Msp430AdcClient.Resource;
-  #ifdef REF_VOLT_AUTO_CONFIGURE
-    Msp430Adc12Config = Msp430AdcClient.Msp430Adc12Config;
-  #endif 
+    uses interface AdcConfigure<const msp430adc12_channel_config_t*>;
   }
 
-Note that the same CLIENT identifier is used for all involved interfaces to
-facilitate the mapping between the HAL2 and HAL1 interfaces. The conditional
-compile directive REF_VOLT_AUTO_CONFIGURE can be used to automatically enable
-the internal reference voltage generator during the sampling process.
-
 .. [TEP1] TEP 1: TEP Structure and Keywords. 
 .. [TEP2] TEP 2: Hardware Abstraction Architecture. 
 .. [TEP108] TEP 108: Resource Arbitration.