[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/pxa27x/timer HalPXA27xSleep.nc, 1.1.2.2, 1.1.2.3 HalPXA27xSleepM.nc, 1.1.2.2, 1.1.2.3

Philip Buonadonna philipb at users.sourceforge.net
Wed Oct 18 12:29:37 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/pxa27x/timer
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv14352

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	HalPXA27xSleep.nc HalPXA27xSleepM.nc 
Log Message:
Updated sleep components for the PXA27x

Index: HalPXA27xSleep.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/pxa27x/timer/Attic/HalPXA27xSleep.nc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** HalPXA27xSleep.nc	8 Aug 2006 22:39:15 -0000	1.1.2.2
--- HalPXA27xSleep.nc	18 Oct 2006 19:29:35 -0000	1.1.2.3
***************
*** 29,32 ****
--- 29,35 ----
   */
  /**
+  *
+  * This interfaces provides HAL level sleep functionality for the PXA27x. 
+  *
   * @author Kaisen Lin
   * @author Phil Buonadonna
***************
*** 35,42 ****
  
  interface HalPXA27xSleep {
!   // sleep for 'time' milliseconds
    async command void sleepMillis(uint16_t time);
!   // sleep for 'time' minutes
!   async command void sleepMinutes(uint16_t time);
    async command void sleepHours(uint16_t time);
  }
--- 38,77 ----
  
  interface HalPXA27xSleep {
!   /**
!    * Sleep for a given number of milliseconds. This function supports
!    * sleep times up to 65534ms.  Larger sleep durations must
!    * use one of the other methods.
!    *
!    * @param time Sleep duration in milliseconds up to 65534.
!    * 
!    */
    async command void sleepMillis(uint16_t time);
! 
!   /**
!    * Sleep for a given number of seconds up to 62859 sec.
!    * If the function is passed a value greater than 62859, it
!    * will default to the maximum.
!    *
!    * @param time Sleep duration in seconds.
!    *
!    */
!   async command void sleepSeconds(uint32_t time);
! 
!   /**
!    * Sleep for a given number of minutes up to 1439 min.
!    * If the function is passed a value greater than 1439, it
!    * will default to the maximum.
!    *
!    * @param time Sleep duration in minutes.
!    */
!   async command void sleepMinutes(uint32_t time);
! 
!   /**
!    * Sleep for a given number of hours up to 23 hours
!    * If the function is passed a value greater than 23, it
!    * will default to the maximum.
!    *
!    * @param time Sleep duration in hours
!    */
    async command void sleepHours(uint16_t time);
  }

Index: HalPXA27xSleepM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/pxa27x/timer/Attic/HalPXA27xSleepM.nc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** HalPXA27xSleepM.nc	8 Aug 2006 22:39:15 -0000	1.1.2.2
--- HalPXA27xSleepM.nc	18 Oct 2006 19:29:35 -0000	1.1.2.3
***************
*** 43,66 ****
  
  implementation {
-   
-   async command void HalPXA27xSleep.sleepMillis(uint16_t time) {
-     int i;
-     call HplPXA27xPower.setPWER(PWER_WERTC);
-     // let it wrap around itself if necessary
-     call HplPXA27xRTC.setPIAR(time); // implicitly resets RTCPICR
-     for(i = 0; i < 10; i++); // spin for a bit
-     call HplPXA27xRTC.setRTSR(RTSR_PICE);
-     for(i = 0; i < 5000; i++); // spin for a bit
  
!     call HplPXA27xPower.setPWRMode(PWRMODE_M_SLEEP);
!     // this call never returns
!   }
! 
!   async command void HalPXA27xSleep.sleepMinutes(uint16_t time) {
      int i;
      call HplPXA27xPower.setPWER(PWER_WERTC);
      // let it wrap around itself if necessary
      call HplPXA27xRTC.setSWCR(0);
!     call HplPXA27xRTC.setSWAR1((time << 13) & 0x7E000); // minutes
      call HplPXA27xRTC.setSWAR2(0x00FFFFFF);
      for(i = 0; i < 10; i++); // spin for a bit
--- 43,53 ----
  
  implementation {
  
!   void doSleep(uint32_t swRegVal) {
      int i;
      call HplPXA27xPower.setPWER(PWER_WERTC);
      // let it wrap around itself if necessary
      call HplPXA27xRTC.setSWCR(0);
!     call HplPXA27xRTC.setSWAR1(swRegVal); // minutes
      call HplPXA27xRTC.setSWAR2(0x00FFFFFF);
      for(i = 0; i < 10; i++); // spin for a bit
***************
*** 72,84 ****
    }
  
!   async command void HalPXA27xSleep.sleepHours(uint16_t time) {
      int i;
      call HplPXA27xPower.setPWER(PWER_WERTC);
      // let it wrap around itself if necessary
!     call HplPXA27xRTC.setSWCR(0);
!     call HplPXA27xRTC.setSWAR1((time << 19) & 0xF80000); // hours
!     call HplPXA27xRTC.setSWAR2(0x00FFFFFF);
      for(i = 0; i < 10; i++); // spin for a bit
!     call HplPXA27xRTC.setRTSR(RTSR_SWCE);
      for(i = 0; i < 5000; i++); // spin for a bit
  
--- 59,70 ----
    }
  
!    
!   async command void HalPXA27xSleep.sleepMillis(uint16_t time) {
      int i;
      call HplPXA27xPower.setPWER(PWER_WERTC);
      // let it wrap around itself if necessary
!     call HplPXA27xRTC.setPIAR(time); // implicitly resets RTCPICR
      for(i = 0; i < 10; i++); // spin for a bit
!     call HplPXA27xRTC.setRTSR(RTSR_PICE);
      for(i = 0; i < 5000; i++); // spin for a bit
  
***************
*** 86,88 ****
--- 72,119 ----
      // this call never returns
    }
+ 
+   async command void HalPXA27xSleep.sleepSeconds(uint32_t time) {
+     uint32_t hrs = time / 3600;
+     uint32_t mins = (time / 60) % 60;
+     uint32_t secs = time % 60;
+     uint32_t swReg;
+ 
+       if (hrs > 23) {
+ 	hrs = 23;
+ 	mins = 59;
+ 	secs = 59;
+       }
+ 
+     swReg = ((hrs << 19) | (mins << 13) | (secs << 7));
+     doSleep(swReg);
+     return;
+   }
+ 
+   async command void HalPXA27xSleep.sleepMinutes(uint32_t time) {
+     uint32_t hrs = time / 60;
+     uint32_t mins = time % 60;
+     uint32_t swReg;
+ 
+     if (hrs > 23) {
+       hrs = 23;
+       mins = 59;
+     }
+     swReg = ((hrs << 19) | (mins << 13));
+ 
+     doSleep(swReg);
+     return;
+   }
+ 
+   async command void HalPXA27xSleep.sleepHours(uint16_t time) {
+     uint32_t hrs = time;
+     uint32_t swReg;
+ 
+     if (hrs > 23) {
+       hrs = 23;
+     }
+     swReg = (hrs << 19);
+ 
+     doSleep(swReg);
+     return;
+   }
  }



More information about the Tinyos-2-commits mailing list