[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/Deluge/TOSBoot/msp430 VoltageC.nc, NONE, 1.1

Jonathan Hui jwhui at users.sourceforge.net
Thu Jun 9 12:29:03 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/TOSBoot/msp430
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29678/msp430

Added Files:
	VoltageC.nc 
Log Message:
- Check voltage before writing to the flash. If the voltage is below
the specified operating voltage, TOSBoot will execute the currently
programmed TinyOS application. No golden gesture is allowed since the
golden image can't be programmed and detecting the gesture requires
writing to the internal flash anyways. On the msp430 platform, the
minimum voltage is 2.7V.



--- NEW FILE: VoltageC.nc ---
// $Id: VoltageC.nc,v 1.1 2005/06/09 19:29:00 jwhui Exp $

/*									tab:2
 *
 *
 * "Copyright (c) 2000-2004 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/**
 * @author Jonathan Hui <jwhui at cs.berkeley.edu>
 */

module VoltageC {
  provides {
    interface Voltage;
  }
}

implementation {

  enum {
    VTHRESH = 0xE66, // 2.7V
  };

  command bool Voltage.okToProgram() {

    int i;

    // Turn on and set up ADC12 with REF_1_5V
    ADC12CTL0 = ADC12ON + SHT0_2 + REFON;
    // Use sampling timer
    ADC12CTL1 = SHP;
    // Set up to sample voltage
    ADC12MCTL0 = SREF_1 + INCH_11;
    // Delay for reference start-up
    for ( i=0; i<0x3600; i++ );

    // Enable conversions
    ADC12CTL0 |= ENC;
    // Start conversion
    ADC12CTL0 |= ADC12SC;
    // Wait for completion
    while ((ADC12IFG & BIT0) == 0);

    // Check if voltage is greater than 2.7V
    return ( ADC12MEM0 > VTHRESH );

  }

}



More information about the Tinyos-beta-commits mailing list