[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/pxa27x Clock.nc, NONE, 1.1 HPLInit.nc, 1.6, 1.7 PXA27XClockM.nc, 1.1, 1.2

Robbie Adler radler at users.sourceforge.net
Wed Sep 7 18:01:51 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8670

Modified Files:
	HPLInit.nc PXA27XClockM.nc 
Added Files:
	Clock.nc 
Log Message:
updated clock component to allow timer to function without having to interrupt us every 1ms

--- NEW FILE: Clock.nc ---
// $Id: Clock.nc,v 1.1 2005/09/08 01:01:47 radler Exp $

/*									tab:4
 * "Copyright (c) 2000-2003 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."
 *
 * Copyright (c) 2002-2003 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.
 */
/*
 * Authors:		Jason Hill, David Gay, Philip Levis, Nelson Lee
 * Date last modified:  6/25/02
 *
 *
 */



/**
 * The hardware clock interface. 
 * @author Jason Hill
 * @author David Gay
 * @author Philip Levis
 * @author Nelson Lee
 **/
includes Clock;

interface Clock {

  /**
   *  Set the clock rate.  For the specific meanings of interval
   * and scale, refer to the processor data sheet. For the mica and rene:
   * <p>
   * <pre>
   *     Clock scale
   *         0 - off
   *         1 - 32768 ticks/second
   *         2 - 4096 ticks/second
   *         3 - 1024 ticks/second
   *         4 - 512 ticks/second
   *         5 - 256 ticks/second
   *         6 - 128 ticks/second
   *         7 - 32 ticks/second
   * </pre>
   * <p>
   *
   * Interval is how many ticks per clock firing.
   * For example, setRate(160,7) will result in an event every 160/32
   * seconds.
   *
   * See also: <code>Clock.h</code> for predefined macros:
   *
   * <p>
   * <pre>
   *  interval      scale         result
   *  TOS_I1000PS   TOS_S1000PS   1000 ticks/sec
   *  TOS_I100PS    TOS_S100PS     100 ticks/sec
   *  TOS_I10PS     TOS_S10PS       10 ticks/sec
   *  TOS_I4096PS   TOS_S4096PS   4096 ticks/sec
   *  TOS_I2048PS   TOS_S2048PS   2048 ticks/sec
   *  TOS_I1024PS   TOS_S1024PS   1024 ticks/sec
   *  TOS_I512PS    TOS_S512PS     512 ticks/sec
   *  TOS_I256PS    TOS_S256PS     256 ticks/sec
   *  TOS_I128PS    TOS_S128PS     128 ticks/sec
   *  TOS_I64PS     TOS_S64PS       64 ticks/sec
   *  TOS_I32PS     TOS_S32PS       32 ticks/sec
   *  TOS_I16PS     TOS_S16PS       16 ticks/sec
   *  TOS_I8PS      TOS_S8PS         8 ticks/sec
   *  TOS_I4PS      TOS_S4PS         4 ticks/sec
   *  TOS_I2PS      TOS_S2PS         2 ticks/sec
   *  TOS_I1PS      TOS_S1PS         1 tick/sec
   *  TOS_I0PS      TOS_S0PS         0 ticks/sec (clock off)
   * </pre>
   **/
  async command result_t setRate(uint32_t interval, uint32_t scale);

  /**
   *  Set clock interval 
   * 
   *  @param value New clock interval
   *
   *  @return none
   **/
  async command void setInterval(uint32_t value);

  /**
   *  Set clock interval at next clock interrupt time
   * 
   *  @param value New clock interval
   *
   *  @return none
   **/
  async command void setNextInterval(uint32_t value);

  /**
   *  Get clock interval 
   * 
   *  @return current clock interval
   **/
  async command uint32_t getInterval();

  /**
   *  Get clock scale 
   * 
   *  @return current clock scale level
   **/  
  async command uint32_t getScale();

  /**
   *  Set clock scale at next clock interrupt time 
   * 
   *  @param scale New clock scale
   *
   *  @return none
   **/
  async command void setNextScale(uint32_t scale);

  /**
   *  Set both clock interval and scale
   * 
   *  @param interval New clock interval
   *
   *  @param scale New clock scale
   *
   *  @return SUCCESS or FAILED 
   **/
  async command result_t setIntervalAndScale(uint32_t interval, uint32_t scale);

  /**
   *  Read HW clock counter
   */
  async command uint32_t readCounter() ;

  /**
   *  Set HW clock counter to a specified value
   *
   *  @param n Value to write to TCNT0
   *
   *  @return None
   */
  async command void setCounter(uint32_t n);


  /**
   *  Disable Clock interrupt
   */
  async command void intDisable();


  /**
   *  Enable Clock interrupt
   */
  async command void intEnable() ;


  /**
   *  An event sent when the clock goes off.
   **/
  async event result_t fire();
}











Index: HPLInit.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/HPLInit.nc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** HPLInit.nc	6 Sep 2005 17:54:34 -0000	1.6
--- HPLInit.nc	8 Sep 2005 01:01:47 -0000	1.7
***************
*** 86,89 ****
--- 86,90 ----
      BluSHC,
      TrickleC,
+     HPLClock,
      Main;
    
***************
*** 91,94 ****
--- 92,96 ----
    Main.StdControl->BluSHC;
    Main.StdControl->TrickleC;
+   Main.StdControl->HPLClock;
  }
  

Index: PXA27XClockM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/PXA27XClockM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PXA27XClockM.nc	13 Nov 2004 01:12:40 -0000	1.1
--- PXA27XClockM.nc	8 Sep 2005 01:01:47 -0000	1.2
***************
*** 60,64 ****
   */
  /* @author Phil Buonadonna
!  */
  
  module PXA27XClockM {
--- 60,66 ----
   */
  /* @author Phil Buonadonna
!  * @author Robbie Adler   
! */
! includes trace;
  
  module PXA27XClockM {
***************
*** 74,77 ****
--- 76,80 ----
     * supports the use of TimerM. 
     */
+ #define USE_NEW_TIMER 1
  
    uint8_t gmScale;
***************
*** 80,86 ****
  
    async event void OSTIrq.fired() {
      bool fFireEvent = FALSE;
! 
      if (OSSR & OIER_E5) {
        atomic {
  	gmCounter++;
--- 83,96 ----
  
    async event void OSTIrq.fired() {
+     
+ #if !USE_NEW_TIMER
      bool fFireEvent = FALSE;
! #endif
      if (OSSR & OIER_E5) {
+       //trace("int");
+       OSSR = (OIER_E5);  // Reset the Status register bit.
+ #if USE_NEW_TIMER
+       signal Clock.fire();
+ #else
        atomic {
  	gmCounter++;
***************
*** 89,102 ****
  	  fFireEvent = TRUE;
  	}
- 	OSSR = (OIER_E5);  // Reset the Status register bit.
        }
-       
        if (fFireEvent) {
  	signal Clock.fire();
        }
      }
    }
  
    command result_t StdControl.init() {
      atomic {
        gmScale = DEFAULT_SCALE;
--- 99,112 ----
  	  fFireEvent = TRUE;
  	}
        }
        if (fFireEvent) {
  	signal Clock.fire();
        }
+ #endif
      }
    }
  
    command result_t StdControl.init() {
+ #if !USE_NEW_TIMER
      atomic {
        gmScale = DEFAULT_SCALE;
***************
*** 104,108 ****
        gmCounter = 0;
      }
!     
      /* Disable all clock interrupts */
      //OIER = 0x0UL;
--- 114,118 ----
        gmCounter = 0;
      }
! #endif
      /* Disable all clock interrupts */
      //OIER = 0x0UL;
***************
*** 113,116 ****
--- 123,135 ----
  
    command result_t StdControl.start() {
+ #if USE_NEW_TIMER
+     //we want a simple match based timer...i.e. Not periodic, interrupt at match
+     OMCR5 = (OMCR_C | OMCR_CRES(0x2));  // Resolution = 1 ms...should change in the future to be 1/32768
+     atomic {
+       OIER |= (OIER_E5); // Enable the channel 5 interrupt
+       OSCR5 = 0x1;  // start the  counter
+     }
+     call OSTIrq.enable(); //enable the main interrupt
+ #else
      uint8_t mInt, mScl;
      atomic {
***************
*** 128,133 ****
      }
      call OSTIrq.enable();
!     OSCR5 = 0x0UL;  // Start the counter
!  
      return SUCCESS;
    }
--- 147,153 ----
      }
      call OSTIrq.enable();
!     //OSCR5 = 0x0UL;  // Start the counter
! #endif
!     
      return SUCCESS;
    }
***************
*** 145,152 ****
  
  
!   async command result_t Clock.setRate(char interval, char scale) {
      // roughly translate mica's clock since it sits in the common interface 
      // directory.  Base on interfaces/Clock.h the following mapping is ~correct.
! 
      uint32_t rate;
  
--- 165,177 ----
  
  
!   async command result_t Clock.setRate(uint32_t interval, uint32_t scale) {
      // roughly translate mica's clock since it sits in the common interface 
      // directory.  Base on interfaces/Clock.h the following mapping is ~correct.
!     
! #if USE_NEW_TIMER
!     //don't really want to do anything here.  For now, our low level clock will always be based on the LPO @ 1/32768th sec
!     //all settings are determined in init/start
!     call Clock.setInterval(interval);
! #else
      uint32_t rate;
  
***************
*** 177,185 ****
      }
      OSCR5 = 0x0UL;  // Start the counter
! 
      return SUCCESS;
    }
  
!   async command void Clock.setInterval(uint8_t value) {
      atomic {
        gmInterval = value;
--- 202,216 ----
      }
      OSCR5 = 0x0UL;  // Start the counter
! #endif
      return SUCCESS;
    }
  
!   async command void Clock.setInterval(uint32_t value) {
! #if USE_NEW_TIMER
!     //In the future, we probably set to some number of microseconds based on val and how long it typically take to config...multiply by 32 for now
!     OSMR5 = value;
!     OSCR5 = 0x0;  // start the  counter
!     
! #endif    
      atomic {
        gmInterval = value;
***************
*** 188,197 ****
    }
  
!   async command void Clock.setNextInterval(uint8_t value) {
  
    }
  
!   async command uint8_t Clock.getInterval() {
!     uint8_t ItvlVal;
      atomic {
        ItvlVal = gmInterval;
--- 219,228 ----
    }
  
!   async command void Clock.setNextInterval(uint32_t value) {
  
    }
  
!   async command uint32_t Clock.getInterval() {
!    uint8_t ItvlVal;
      atomic {
        ItvlVal = gmInterval;
***************
*** 200,224 ****
    }
  
!   async command uint8_t Clock.getScale() {
  
    }
  
!   async command void Clock.setNextScale(uint8_t scale) {
  
    }
  
!   async command result_t Clock.setIntervalAndScale(uint8_t interval, uint8_t scale) {
  
    }
  
!   async command uint8_t Clock.readCounter() {
!     uint8_t CntrVal;
      atomic {
        CntrVal = gmCounter;
      }
      return CntrVal;
    }
  
!   async command void Clock.setCounter(uint8_t n) {
  
    }
--- 231,262 ----
    }
  
!   async command uint32_t Clock.getScale() {
  
    }
  
!   async command void Clock.setNextScale(uint32_t scale) {
  
    }
  
!   async command result_t Clock.setIntervalAndScale(uint32_t interval, uint32_t scale) {
  
    }
  
!   async command uint32_t Clock.readCounter() {
!  #if USE_NEW_TIMER
!     //need to return 0 due to a check in the upper layer
!     return 0;
! #else
!     uint32_t CntrVal;
!        
      atomic {
        CntrVal = gmCounter;
      }
      return CntrVal;
+ #endif
+ 
    }
  
!   async command void Clock.setCounter(uint32_t n) {
  
    }



More information about the Tinyos-beta-commits mailing list