[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/atm128/timer Atm128AlarmC.nc, 1.4, 1.5

David Gay idgay at users.sourceforge.net
Fri Aug 11 13:46:26 PDT 2006


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

Modified Files:
	Atm128AlarmC.nc 
Log Message:
a bug fix got lost
simplify logic


Index: Atm128AlarmC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/timer/Atm128AlarmC.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Atm128AlarmC.nc	10 Aug 2006 00:00:59 -0000	1.4
--- Atm128AlarmC.nc	11 Aug 2006 20:46:23 -0000	1.5
***************
*** 73,113 ****
  
    async command void Alarm.startAt( timer_size t0, timer_size dt ) {
!     /* We don't set an interrupt before "now" + mindt to avoid setting an
!        interrupt which is in the past by the time we actually set
!        it. mindt should always be at least 2, because you cannot set an
!        interrupt one cycle in the future. mindt should also be large enough
!        to cover the execution time of this function. */
      atomic
        {
! 	timer_size now, expires, minExpires, guardedExpires;
  
! 	dbg("Atm128AlarmC", "   starting timer at %llu with dt %llu\n", (uint64_t)t0, (uint64_t) dt);
  
- 	if (dt < mindt) /* guardedExpires should not be less than t0 */
- 	  dt = mindt;
- 	expires = t0 + dt;
- 	guardedExpires = expires - mindt;
  	now = call HplAtm128Timer.get();
! 	minExpires = now + mindt;
! 
! 	/* t0 is assumed to be in the past. If it's numerically greater
! 	   than now, that just represents a time one wrap-around
! 	   ago. This requires handling the t0 <= now and t0 > now cases
! 	   separately. */
! 	if (t0 <= now)
! 	  {
! 	    /* if it's in the past or the near future, fire now (i.e., test
! 	       guardedExpires <= now in wrap-around arithmetic). */
! 	    if (guardedExpires >= t0 && // if it wraps, it's > now
! 		guardedExpires <= now)
! 	      expires = minExpires;
! 	  }
  	else
! 	  {
! 	    /* again, guardedExpires <= now in wrap-around arithmetic */
! 	    if (guardedExpires >= t0 || // didn't wrap so < now
! 		guardedExpires <= now)
! 	      expires = minExpires;
! 	  }
  
  	/* Note: all HplAtm128Compare.set values have one subtracted,
--- 73,101 ----
  
    async command void Alarm.startAt( timer_size t0, timer_size dt ) {
!     /* We don't set an interrupt before "now" + mindt to avoid setting
!        an interrupt which is in the past by the time we actually set
!        it. mindt should always be at least 2, because you cannot
!        reliably set an interrupt one cycle in the future. mindt should
!        also be large enough to cover the execution time of this
!        function. */
      atomic
        {
! 	timer_size now, elapsed, expires;
  
! 	dbg("Atm128AlarmC", "   starting timer at %llu with dt %llu\n",
! 	    (uint64_t)t0, (uint64_t) dt);
  
  	now = call HplAtm128Timer.get();
! 	elapsed = now + mindt - t0;
! 	if (elapsed >= dt)
! 	  expires = now + mindt;
  	else
! 	  expires = t0 + dt;
! 
! 	/* Setting the compare register to "-1" is a bad idea
! 	   (interrupt fires before counter overflow is detected, and all
! 	   the "current time" stuff goes bad) */
! 	if (expires == 0)
! 	  expires = 1;
  
  	/* Note: all HplAtm128Compare.set values have one subtracted,



More information about the Tinyos-2-commits mailing list