[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/atm128/timer
Atm128AlarmC.nc, 1.1.2.6, 1.1.2.7 HplAtm128Timer0AsyncC.nc,
1.1.2.4, 1.1.2.5
David Gay
idgay at users.sourceforge.net
Fri Sep 22 12:12:17 PDT 2006
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/atm128 Atm128Power.h,
1.1.2.3, 1.1.2.4 HplAtm128UartC.nc, 1.1.2.4,
1.1.2.5 HplAtm128UartP.nc, 1.1.2.3, 1.1.2.4 McuSleepC.nc,
1.1.2.5, 1.1.2.6
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/atm128/adc
HplAtm128AdcP.nc, NONE, 1.1.2.2 Atm128AdcC.nc, 1.1.2.12,
1.1.2.13 Atm128AdcP.nc, 1.1.2.6, 1.1.2.7 HplAtm128AdcC.nc,
1.1.2.3, 1.1.2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/timer
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv12361/timer
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
Atm128AlarmC.nc HplAtm128Timer0AsyncC.nc
Log Message:
changes from head
Index: Atm128AlarmC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/timer/Atm128AlarmC.nc,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** Atm128AlarmC.nc 27 Jan 2006 17:56:06 -0000 1.1.2.6
--- Atm128AlarmC.nc 22 Sep 2006 19:12:14 -0000 1.1.2.7
***************
*** 73,121 ****
async command void Alarm.startAt( timer_size t0, timer_size dt ) {
! timer_size now;
! timer_size expires, guardedExpires;
!
! now = call HplAtm128Timer.get();
! dbg("Atm128AlarmC", " starting timer at %llu with dt %llu\n", (uint64_t)t0, (uint64_t) dt);
! /* We require dt >= 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. It should be more than 2 if the timer's clock rate is
! very high (e.g., equal to the processor clock). */
! if (dt < mindt)
! dt = mindt;
! expires = t0 + dt;
! guardedExpires = expires - 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.
! Note also that casting compared quantities to timer_size produces
! predictable comparisons (the C integer promotion rules would make it
! hard to write correct code for the possible timer_size size's) */
! 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)
! call HplAtm128Compare.set(call HplAtm128Timer.get() + mindt);
! else
! call HplAtm128Compare.set(expires);
! }
! else
! {
! /* again, guardedExpires <= now in wrap-around arithmetic */
! if (guardedExpires >= t0 || // didn't wrap so < now
! guardedExpires <= now)
! call HplAtm128Compare.set(call HplAtm128Timer.get() + mindt);
! else
! call HplAtm128Compare.set(expires);
}
- call HplAtm128Compare.reset();
- call HplAtm128Compare.start();
}
--- 73,109 ----
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,
! because the comparisons are continuous, but the actual
! interrupt is signalled at the next timer clock cycle. */
! call HplAtm128Compare.set(expires - 1);
! call HplAtm128Compare.reset();
! call HplAtm128Compare.start();
}
}
***************
*** 123,126 ****
--- 111,115 ----
call HplAtm128Compare.stop();
dbg("Atm128AlarmC", " Compare fired, signal alarm above.\n");
+ __nesc_enable_interrupt();
signal Alarm.fired();
}
Index: HplAtm128Timer0AsyncC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/timer/HplAtm128Timer0AsyncC.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** HplAtm128Timer0AsyncC.nc 25 Apr 2006 23:52:03 -0000 1.1.2.4
--- HplAtm128Timer0AsyncC.nc 22 Sep 2006 19:12:14 -0000 1.1.2.5
***************
*** 47,52 ****
implementation
{
- bool inOverflow;
-
command error_t Init.init() {
SET_BIT(ASSR, AS0); // set Timer/Counter0 to asynchronous mode
--- 47,50 ----
***************
*** 163,167 ****
AVR_ATOMIC_HANDLER(SIG_OUTPUT_COMPARE0) {
stabiliseTimer0();
- __nesc_enable_interrupt();
signal Compare.fired();
}
--- 161,164 ----
***************
*** 170,176 ****
AVR_ATOMIC_HANDLER(SIG_OVERFLOW0) {
stabiliseTimer0();
- inOverflow = TRUE;
signal Timer.overflow();
- inOverflow = FALSE;
}
}
--- 167,171 ----
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/atm128 Atm128Power.h,
1.1.2.3, 1.1.2.4 HplAtm128UartC.nc, 1.1.2.4,
1.1.2.5 HplAtm128UartP.nc, 1.1.2.3, 1.1.2.4 McuSleepC.nc,
1.1.2.5, 1.1.2.6
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/atm128/adc
HplAtm128AdcP.nc, NONE, 1.1.2.2 Atm128AdcC.nc, 1.1.2.12,
1.1.2.13 Atm128AdcP.nc, 1.1.2.6, 1.1.2.7 HplAtm128AdcC.nc,
1.1.2.3, 1.1.2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list