[Tinyos-commits] CVS: tinyos-1.x/tos/platform/msp430 MSP430TimerAExclusiveC.nc, NONE, 1.1 MSP430TimerAExclusiveM.nc, NONE, 1.1 TimerExclusive.nc, NONE, 1.1 ADCC.nc, 1.8, NONE ADCHIL.h, 1.2, NONE ADCM.nc, 1.17, NONE ADCMultiple.nc, 1.1, NONE ADCSingle.nc, 1.1, NONE ADC_README, 1.9, NONE DMA.nc, 1.1, NONE DMAControl.nc, 1.1, NONE DemoSensorC.nc, 1.3, NONE HALDMAM.nc, 1.1, NONE HPLADC12.nc, 1.6, NONE HPLADC12M.nc, 1.8, NONE InternalTemp.h, 1.2, NONE InternalTempC.nc, 1.4, NONE InternalTempM.nc, 1.2, NONE InternalVoltage.h, 1.2, NONE InternalVoltageC.nc, 1.4, NONE InternalVoltageM.nc, 1.2, NONE MSP430ADC12.h, 1.15, NONE MSP430ADC12C.nc, 1.8, NONE MSP430ADC12M.nc, 1.16, NONE MSP430ADC12Multiple.nc, 1.1, NONE MSP430ADC12Single.nc, 1.1, NONE MSP430DMA.h, 1.2, NONE MSP430DMAC.nc, 1.1, NONE MSP430DMAChannelControl.nc, 1.2, NONE MSP430DMAControl.nc, 1.2, NONE MSP430DMAM.nc, 1.2, NONE Voltage.h, 1.1, NONE VoltageM.nc, 1.2, NONE

Joe Polastre jpolastre at users.sourceforge.net
Wed Sep 28 03:41:13 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/platform/msp430
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30738/msp430

Added Files:
	MSP430TimerAExclusiveC.nc MSP430TimerAExclusiveM.nc 
	TimerExclusive.nc 
Removed Files:
	ADCC.nc ADCHIL.h ADCM.nc ADCMultiple.nc ADCSingle.nc 
	ADC_README DMA.nc DMAControl.nc DemoSensorC.nc HALDMAM.nc 
	HPLADC12.nc HPLADC12M.nc InternalTemp.h InternalTempC.nc 
	InternalTempM.nc InternalVoltage.h InternalVoltageC.nc 
	InternalVoltageM.nc MSP430ADC12.h MSP430ADC12C.nc 
	MSP430ADC12M.nc MSP430ADC12Multiple.nc MSP430ADC12Single.nc 
	MSP430DMA.h MSP430DMAC.nc MSP430DMAChannelControl.nc 
	MSP430DMAControl.nc MSP430DMAM.nc Voltage.h VoltageM.nc 
Log Message:
complete reorganization of ADC to support DMA and DAC modules   

Changes to the ADC include:

The ADC no longer directly accesses TimerA.  Instead it uses
the TimerExclusive interface in MSP430TimerAExclusive to gain
exclusive lock on TimerA.  It releases TimerA when it is done.
This is necessary for other components that would like to use
TimerA to do so, such as the DAC.

Commands for the DMA have been added to the MSP430Single and
MSP430Multiple ADC interfaces.  These include startSampling,
stopSampling, pauseSampling, and resumeSampling.  They should only
be used in conjunction with the DMA and never as standalone functions.

A TinyOS driver for the DAC is being committed that uses the
newly created TimerExclusive interface to get access to TimerA.
It also supports DMA use.

The DMA has been rearchitected to follow the namespace of the other
components with minor bug fixes.  

The ADC, DAC, and DMA have been moved to their own subdirectories to
make life easier when viewing the msp430 platform.  Platforms that
rely on these components must now include the following lines in the
@opts section of their .platform file:
-I%T/platform/msp430/adc
-I%T/platform/msp430/dac
-I%T/platform/msp430/dma

A sample application is being checked in to 
apps/TestMSP430DMA/
that includes TestADC12DMAC for reading multiple samples from the ADC
and also TestDAC12DMAC for sending multiple readings via the DAC

Although I spearheaded much of the DAC efforts, credit goes to
Ben Greenstein for fixes to the ADC and much of the DMA code that I based
this new implementation on.



--- NEW FILE: MSP430TimerAExclusiveC.nc ---
// $Id: MSP430TimerAExclusiveC.nc,v 1.1 2005/09/28 10:41:11 jpolastre Exp $
/*
 * 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.
 */
configuration MSP430TimerAExclusiveC {
  provides {
    interface StdControl;
    interface TimerExclusive[uint8_t id];
  }
}
implementation {
  components MSP430TimerAExclusiveM as Impl, MSP430TimerC, LedsC;

  StdControl = Impl;
  TimerExclusive = Impl;

  Impl.TimerA -> MSP430TimerC.TimerA;
  Impl.ControlA0 -> MSP430TimerC.ControlA0;
  Impl.ControlA1 -> MSP430TimerC.ControlA1;
  Impl.CompareA0 -> MSP430TimerC.CompareA0;
  Impl.CompareA1 -> MSP430TimerC.CompareA1;
  Impl.Leds -> LedsC;
}

--- NEW FILE: MSP430TimerAExclusiveM.nc ---
// $Id: MSP430TimerAExclusiveM.nc,v 1.1 2005/09/28 10:41:11 jpolastre Exp $
/*
 * 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.
 *
 * 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.
 */
module MSP430TimerAExclusiveM {
  provides {
    interface StdControl;
    interface TimerExclusive[uint8_t id];
  }
  uses {
    interface MSP430Timer as TimerA;
    interface MSP430TimerControl as ControlA0;
    interface MSP430TimerControl as ControlA1;
    interface MSP430Compare as CompareA0;
    interface MSP430Compare as CompareA1;
    interface Leds;
  }
}
implementation {

  uint8_t state;
  uint8_t busid;
  bool isBusReleasedPending;
  enum { BUS_IDLE, BUS_BUSY, BUS_OFF };

  async command result_t TimerExclusive.prepareTimer[uint8_t id](uint16_t interval, uint16_t csSAMPCON, uint16_t cdSAMPCON)
  {

    MSP430CompareControl_t ccResetSHI = {
      ccifg : 0, cov : 0, out : 0, cci : 0, ccie : 0,
      outmod : 0, cap : 0, clld : 0, scs : 0, ccis : 0, cm : 0 };

    result_t success = FAIL;

    atomic {
      if (id == busid) {
	success = SUCCESS;
      }
    }

    if (!success)
      return FAIL;

    call TimerA.disableEvents();
    call TimerA.setMode(MSP430TIMER_STOP_MODE);
    call TimerA.clear();
    call TimerA.setClockSource(csSAMPCON);
    call TimerA.setInputDivider(cdSAMPCON);
    call ControlA0.setControl(ccResetSHI);
    call CompareA0.setEvent(interval-1);
    call CompareA1.setEvent((interval-1)/2);
    return SUCCESS;
  }
    
  async command result_t TimerExclusive.startTimer[uint8_t id]()
  {
    MSP430CompareControl_t ccSetSHI = {
      ccifg : 0, cov : 0, out : 1, cci : 0, ccie : 0,
      outmod : 0, cap : 0, clld : 0, scs : 0, ccis : 0, cm : 0 };
    MSP430CompareControl_t ccResetSHI = {
      ccifg : 0, cov : 0, out : 0, cci : 0, ccie : 0,
      outmod : 0, cap : 0, clld : 0, scs : 0, ccis : 0, cm : 0 };
    MSP430CompareControl_t ccRSOutmod = {
      ccifg : 0, cov : 0, out : 0, cci : 0, ccie : 0,
      outmod : 7, cap : 0, clld : 0, scs : 0, ccis : 0, cm : 0 };


    result_t success = FAIL;

    atomic {
      if (id == busid) {
	success = SUCCESS;
      }
    }

    if (!success)
      return FAIL;

    // manually trigger first conversion, then switch to Reset/set mode
    call ControlA1.setControl(ccResetSHI);
    call ControlA1.setControl(ccSetSHI);
    call ControlA1.setControl(ccResetSHI); 
    call ControlA1.setControl(ccRSOutmod);
    call TimerA.setMode(MSP430TIMER_UP_MODE); // go!
    return SUCCESS;
  }    

  async command result_t TimerExclusive.stopTimer[uint8_t id]() {
    result_t success = FAIL;
    atomic {
      if (id == busid) {
	call TimerA.setMode(MSP430TIMER_STOP_MODE);
	success = SUCCESS;
      }
    }
    return success;
  }

  task void busReleased() {
    uint8_t i;
    uint8_t currentstate;
    // tell everyone the bus has been released
    atomic isBusReleasedPending = FALSE;
    for (i = 0; i < uniqueCount("TimerA"); i++) {
      atomic currentstate = state;
      if (currentstate == BUS_IDLE) 
        signal TimerExclusive.free[i]();
    }
  }
 
  command result_t StdControl.init() {
    atomic {
      state = BUS_OFF;
      busid = 0xff;
      isBusReleasedPending = FALSE;
    }
    return SUCCESS;
  }

  command result_t StdControl.start() {
    uint8_t _state;
    atomic {
      if (state == BUS_OFF) {
	state = BUS_IDLE;
	isBusReleasedPending = FALSE;
      }
      _state = state;
    }

    if (_state == BUS_IDLE)
      return SUCCESS;

    return FAIL;
  }

  command result_t StdControl.stop() {
    uint8_t _state;
    atomic {
      if (state == BUS_IDLE) {
	state = BUS_OFF;
	isBusReleasedPending = FALSE;
      }
      _state = state;
    }

    if (_state == BUS_OFF) {
      return SUCCESS;
    }
    return FAIL;
  }

  async command result_t TimerExclusive.get[uint8_t id]() {
    bool gotbus = FALSE;
    atomic {
      if (state == BUS_IDLE) {
        state = BUS_BUSY;
        gotbus = TRUE;
        busid = id;
      }
      else if ((state == BUS_BUSY) && (id == busid)) {
	gotbus = TRUE;
      }
    }
    if (gotbus)
      return SUCCESS;
    return FAIL;
  }
 
  async command result_t TimerExclusive.release[uint8_t id]() {
    atomic {
      if ((state == BUS_BUSY) && (busid == id)) {
	busid = 0xff;
        state = BUS_IDLE;

	// Post busReleased inside the if-statement so it's only posted if the
	// bus has actually been released.  And, only post if the task isn't
	// already pending.  And, it's inside the atomic because
	// isBusReleasedPending is a state variable that must be guarded.
	if( (isBusReleasedPending == FALSE) && (post busReleased() == TRUE) )
	  isBusReleasedPending = TRUE;

      }
    }
    return SUCCESS;
  }

  default event void TimerExclusive.free[uint8_t id]() { }

  async event void TimerA.overflow(){ }
  async event void CompareA0.fired(){ }
  async event void CompareA1.fired(){ }

}

--- NEW FILE: TimerExclusive.nc ---
// $Id: TimerExclusive.nc,v 1.1 2005/09/28 10:41:11 jpolastre Exp $
/*
 * 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.
 */
interface TimerExclusive {
  /**
   * Prepare Timer to be set with an interval, cs, and cd
   */
  async command result_t prepareTimer(uint16_t interval, uint16_t csSAMPCON, uint16_t cdSAMPCON);
  /**
   * Start Timer
   */
  async command result_t startTimer();
  /**
   * Stop Timer
   */
  async command result_t stopTimer();

  /**
   * Request exclusive access to Timer
   */
  async command result_t get();
  /**
   * Release control over Timer
   */
  async command result_t release();
  /**
   * Notification that someone else has released Timer
   */
  event void free();
}

--- ADCC.nc DELETED ---

--- ADCHIL.h DELETED ---

--- ADCM.nc DELETED ---

--- ADCMultiple.nc DELETED ---

--- ADCSingle.nc DELETED ---

--- ADC_README DELETED ---

--- DMA.nc DELETED ---

--- DMAControl.nc DELETED ---

--- DemoSensorC.nc DELETED ---

--- HALDMAM.nc DELETED ---

--- HPLADC12.nc DELETED ---

--- HPLADC12M.nc DELETED ---

--- InternalTemp.h DELETED ---

--- InternalTempC.nc DELETED ---

--- InternalTempM.nc DELETED ---

--- InternalVoltage.h DELETED ---

--- InternalVoltageC.nc DELETED ---

--- InternalVoltageM.nc DELETED ---

--- MSP430ADC12.h DELETED ---

--- MSP430ADC12C.nc DELETED ---

--- MSP430ADC12M.nc DELETED ---

--- MSP430ADC12Multiple.nc DELETED ---

--- MSP430ADC12Single.nc DELETED ---

--- MSP430DMA.h DELETED ---

--- MSP430DMAC.nc DELETED ---

--- MSP430DMAChannelControl.nc DELETED ---

--- MSP430DMAControl.nc DELETED ---

--- MSP430DMAM.nc DELETED ---

--- Voltage.h DELETED ---

--- VoltageM.nc DELETED ---



More information about the Tinyos-commits mailing list