[Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/mica VoltageC.nc, NONE, 1.1 VoltageNowC.nc, NONE, 1.1 VoltageP.nc, NONE, 1.1 VoltageStreamC.nc, NONE, 1.1

David Gay idgay at users.sourceforge.net
Tue May 22 13:59:04 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x/tos/platforms/mica
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3400/mica

Added Files:
	VoltageC.nc VoltageNowC.nc VoltageP.nc VoltageStreamC.nc 
Log Message:
Consistent voltage stuff for mica family based on code from 
Razvan Musaloiu-E.


--- NEW FILE: VoltageC.nc ---
/**
 * Battery Voltage. The returned value represents the difference
 * between the battery voltage and V_BG (1.23V). The formula to convert
 * it to mV is: 1223 * 1024 / value.
 *
 * @author Razvan Musaloiu-E.
 */

generic configuration VoltageC()
{
  provides interface Read<uint16_t>;
}

implementation
{
  components new AdcReadClientC(), VoltageP;

  Read = AdcReadClientC;

  AdcReadClientC.Atm128AdcConfig -> VoltageP;
}

--- NEW FILE: VoltageNowC.nc ---
/* $Id: VoltageNowC.nc,v 1.1 2007/05/22 20:59:01 idgay Exp $
 * Copyright (c) 2006 Intel Corporation
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached INTEL-LICENSE     
 * file. If you do not find these files, copies can be found by writing to
 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
 * 94704.  Attention:  Intel License Inquiry.
 */
/**
 * Voltage sensor.
 * 
 * @author David Gay
 */

#include "hardware.h"

generic configuration VoltageNowC() {
  provides interface Resource;
  provides interface ReadNow<uint16_t>;
}
implementation {
  components new AdcReadNowClientC(), VoltageP;

  ReadNow = AdcReadNowClientC;
  Resource = AdcReadNowClientC;
  AdcReadNowClientC.Atm128AdcConfig -> VoltageP;
}

--- NEW FILE: VoltageP.nc ---
/**
 * Battery Voltage. The returned value represents the difference
 * between the battery voltage and V_BG (1.23V). The formula to convert
 * it to mV is: 1223 * 1024 / value.
 *
 * @author Razvan Musaloiu-E.
 */
module VoltageP
{
  provides interface Atm128AdcConfig;
}
implementation
{
  async command uint8_t Atm128AdcConfig.getChannel()
  {
    // select the 1.23V (V_BG). Reference: Table 97, page 244 from the Atmega128
    return ATM128_ADC_SNGL_1_23;
  }

  async command uint8_t Atm128AdcConfig.getRefVoltage()
  {
    return ATM128_ADC_VREF_OFF;
  }

  async command uint8_t Atm128AdcConfig.getPrescaler()
  {
    return ATM128_ADC_PRESCALE;
  }
}

--- NEW FILE: VoltageStreamC.nc ---
/* $Id: VoltageStreamC.nc,v 1.1 2007/05/22 20:59:01 idgay Exp $
 * Copyright (c) 2006 Intel Corporation
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached INTEL-LICENSE     
 * file. If you do not find these files, copies can be found by writing to
 * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, 
 * 94704.  Attention:  Intel License Inquiry.
 */
/**
 * Voltage sensor.
 * 
 * @author David Gay
 */

#include "hardware.h"

generic configuration VoltageStreamC() {
  provides interface ReadStream<uint16_t>;
}
implementation {
  components VoltageP, new AdcReadStreamClientC();

  ReadStream = AdcReadStreamClientC;
  AdcReadStreamClientC.Atm128AdcConfig -> VoltageP;
}



More information about the Tinyos-2-commits mailing list